You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "squallmat ." <sq...@gmail.com> on 2014/07/07 10:58:30 UTC
embedded components form in "if"
I have two t:form embedded components defined in my java class with the
good ids.
And in my template file I have defined them also, but each one surrounded
by a t:if, and at the page launch only one of the these t:if will be true,
so only one of my two embedded forms will be rendered.
When I tried to launch that I got this message error :
"Embedded component(s) sendFilesClientForm, sendFilesCollaboratorForm are
defined within component class atos.smt.livraison.pages.EnvoiFichiers (or a
super-class of EnvoiFichiers), but are not present in the component
template (classpath:atos/smt/livraison/pages/EnvoiFichiers.tml)."
So it seems that embedded components search for the corresponding template
definition after rendering preparation, then How could I achieve what I
want : Define two forms embedded components, but only one will be rendered
on display ?
Re: embedded components form in "if"
Posted by Geoff Callender <ge...@gmail.com>.
Are you sure? Here's a working example:
http://jumpstart.doublenegative.com.au/jumpstart7/together/filtercrud/persons
Cheers,
Geoff
On 7 Jul 2014, at 6:58 pm, squallmat . <sq...@gmail.com> wrote:
> I have two t:form embedded components defined in my java class with the
> good ids.
> And in my template file I have defined them also, but each one surrounded
> by a t:if, and at the page launch only one of the these t:if will be true,
> so only one of my two embedded forms will be rendered.
>
> When I tried to launch that I got this message error :
> "Embedded component(s) sendFilesClientForm, sendFilesCollaboratorForm are
> defined within component class atos.smt.livraison.pages.EnvoiFichiers (or a
> super-class of EnvoiFichiers), but are not present in the component
> template (classpath:atos/smt/livraison/pages/EnvoiFichiers.tml)."
>
> So it seems that embedded components search for the corresponding template
> definition after rendering preparation, then How could I achieve what I
> want : Define two forms embedded components, but only one will be rendered
> on display ?
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: embedded components form in "if"
Posted by Geoff Callender <ge...@gmail.com>.
On 7 Jul 2014, at 11:01 pm, Thiago H de Paula Figueiredo <th...@gmail.com> wrote:
> On Mon, 07 Jul 2014 09:41:35 -0300, squallmat . <sq...@gmail.com> wrote:
>
>> here's my code to be more clear :
>>
>> In EnvoiFichiers.java :
>> .....
>> // Client sending files form
>> @Component(id = "sendFilesClientForm")
>> private Form formClient;
>
> If you use @Component, you're declaring the component in the class, not in the template. If you want to just inject the component, you should use @InjectComponent instead. Otherwise, you should remove the parameters from the template and pass them using the @Component annotation. From your template, it seems you should be using @InjectComponent.
Good point Thiago. @Component works, but it's not really the right annotation to use if you're not actually declaring the component . I'll have to fix that in the JumpStart examples where this misuse has crept in over time.
Geoff
Re: embedded components form in "if"
Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Mon, 07 Jul 2014 09:41:35 -0300, squallmat . <sq...@gmail.com>
wrote:
> here's my code to be more clear :
>
> In EnvoiFichiers.java :
> .....
> // Client sending files form
> @Component(id = "sendFilesClientForm")
> private Form formClient;
If you use @Component, you're declaring the component in the class, not in
the template. If you want to just inject the component, you should use
@InjectComponent instead. Otherwise, you should remove the parameters from
the template and pass them using the @Component annotation. From your
template, it seems you should be using @InjectComponent.
> <t:if test="${userConnected.isClient()}">
Never, never, never eve use ${} expansions in component parameters. In
100% of the time, it's either wrong or useless. It should be <t:if
test="userConnected.isClient()">
> <t:Form id="sendFilesClientForm">
You haven't declared the Tapestry id (t:id) for the component, just the
client-side HTML one, and they're different. It would work if you used
<t:Form t:id="sendFilesClientForm"> instead.
--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: embedded components form in "if"
Posted by "squallmat ." <sq...@gmail.com>.
here's my code to be more clear :
In EnvoiFichiers.java :
.....
// Client sending files form
@Component(id = "sendFilesClientForm")
private Form formClient;
// Collaborator sending files form
@Component(id = "sendFilesCollaboratorForm")
private Form formCollaborator;
.....
In EnvoiFichiers.tml :
....
<!-- If connected user is a client -->
<t:if test="${userConnected.isClient()}">
<fieldset>
<legend align="left">${message:sendFiles}</legend>
<t:Form id="sendFilesClientForm">
<t:Label t:for="uploadedFilesClient" /> :
<input t:type="Upload" t:value="uploadedFilesClient"
t:id="uploadedFilesClient" />
<br />
<t:submit value="${message:sendingFiles}" class="button" />
</t:Form>
</fieldset>
</t:if>
<!-- If connected user is a collaborator -->
<t:if test="${userConnected.isCollaborator()}">
<fieldset>
<legend align="left">${message:sendFiles}</legend>
<t:Form id="sendFilesCollaboratorForm">
<t:Label t:for="uploadedFilesCollaborator" /> :
<input t:type="Upload" t:value="uploadedFilesCollaborator"
t:id="uploadedFilesCollaborator" />
<br />
<br />
${message:clients} :
<table>
<tr>
<td><t:checkbox t:id="client1" /> Client 1. <br /> <t:checkbox
t:id="client2" /> Client 2. <br /></td>
</tr>
</table>
${message:collaborators} :
<table>
<tr>
<td><t:checkbox t:id="collaborator1" /> Client 1. <br /> <t:checkbox
t:id="collaborator2" /> Client 2. <br /></td>
</tr>
</table>
<t:submit value="${message:sendingFiles}" class="button" />
</t:Form>
</fieldset>
</t:if>
...
And when I try to display this page I got :
Embedded component(s) sendFilesClientForm, sendFilesCollaboratorForm are
defined within component class atos.smt.livraison.pages.EnvoiFichiers (or a
super-class of EnvoiFichiers), but are not present in the component
template (classpath:atos/smt/livraison/pages/EnvoiFichiers.tml).
2014-07-07 14:13 GMT+02:00 Thiago H de Paula Figueiredo <th...@gmail.com>
:
> On Mon, 07 Jul 2014 05:58:30 -0300, squallmat . <sq...@gmail.com>
> wrote:
>
> I have two t:form embedded components defined in my java class with the
>> good ids.
>>
>
> What do you mean by good ids?
>
>
> When I tried to launch that I got this message error :
>> "Embedded component(s) sendFilesClientForm, sendFilesCollaboratorForm are
>> defined within component class atos.smt.livraison.pages.EnvoiFichiers
>> (or a super-class of EnvoiFichiers), but are not present in the component
>> template (classpath:atos/smt/livraison/pages/EnvoiFichiers.tml)."
>>
>
> You cannot inject a component declared in a template which isn't its own,
> even if this template is the one from a superclass. In other words, page or
> class Example can only @InjectComponent components declared inside its
> corresponding template (Example.tml).
>
>
> So it seems that embedded components search for the corresponding
>> template definition after rendering preparation,
>>
>
> That's 100% incorrect. Tapestry templates have a strictly static
> structure. Only rendering is dynamic.
>
> --
> Thiago H. de Paula Figueiredo
> Tapestry, Java and Hibernate consultant and developer
> http://machina.com.br
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
Re: embedded components form in "if"
Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Mon, 07 Jul 2014 05:58:30 -0300, squallmat . <sq...@gmail.com>
wrote:
> I have two t:form embedded components defined in my java class with the
> good ids.
What do you mean by good ids?
> When I tried to launch that I got this message error :
> "Embedded component(s) sendFilesClientForm, sendFilesCollaboratorForm are
> defined within component class atos.smt.livraison.pages.EnvoiFichiers
> (or a super-class of EnvoiFichiers), but are not present in the component
> template (classpath:atos/smt/livraison/pages/EnvoiFichiers.tml)."
You cannot inject a component declared in a template which isn't its own,
even if this template is the one from a superclass. In other words, page
or class Example can only @InjectComponent components declared inside its
corresponding template (Example.tml).
> So it seems that embedded components search for the corresponding
> template definition after rendering preparation,
That's 100% incorrect. Tapestry templates have a strictly static
structure. Only rendering is dynamic.
--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org