You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by membersound <me...@web.de> on 2012/11/21 22:37:34 UTC

How to reuse a form?

Hi,

I have a form that I want to reuse for another action of a page.
Q1) How can I define a t:form and just reuse the exact definitions without
having to copy/paste the whole form all the time?
Q2) How can I place an additional field (I require a dropdown t:select) into
that form? Without having to copy/paste the whole form code again (which
would cause a lot of dublication)?

It is similar to this:

<t:form>
<div class="t-beaneditor">
<t:beaneditor object="myObj" >
<div class="t-beaneditor-row">
 
 <t:label for="checkbox">
 <t:checkbox t:id="checkbox" t:mixings="frag1" />
</div>
<t:formfragment t:id="frag1 />
</t:beaneditor>


Could someone help?`
Thanks!





--
View this message in context: http://tapestry.1045711.n5.nabble.com/How-to-reuse-a-form-tp5718166.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: How to reuse a form?

Posted by Chris Poulsen <ma...@nesluop.dk>.
Ad 1) Wrap it in a component
Ad 2) I'm not sure, but my guess would be that you can supply extra
stuff as a block

-- 
Chris

On Wed, Nov 21, 2012 at 10:37 PM, membersound <me...@web.de> wrote:
> Hi,
>
> I have a form that I want to reuse for another action of a page.
> Q1) How can I define a t:form and just reuse the exact definitions without
> having to copy/paste the whole form all the time?
> Q2) How can I place an additional field (I require a dropdown t:select) into
> that form? Without having to copy/paste the whole form code again (which
> would cause a lot of dublication)?
>
> It is similar to this:
>
> <t:form>
> <div class="t-beaneditor">
> <t:beaneditor object="myObj" >
> <div class="t-beaneditor-row">
>
>  <t:label for="checkbox">
>  <t:checkbox t:id="checkbox" t:mixings="frag1" />
> </div>
> <t:formfragment t:id="frag1 />
> </t:beaneditor>
>
>
> Could someone help?`
> Thanks!
>
>
>
>
>
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/How-to-reuse-a-form-tp5718166.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: How to reuse a form?

Posted by Lance Java <la...@googlemail.com>.
In addition to Thiago's suggestion, I often set a default for the block:

@Parameter(value="block:defaultAdditionalStuff", defaultPrefix =
BindingConstants.LITERAL)
@Property
private Block additionalStuff;

<t:form>
        ...
        <t:delegate to="additionalStuff"/>
        ...
</t:form> 
<t:block t:id="defaultAdditionalStuff">
   Only show this when an additionalStuff parameter has not been supplied
</t:block>



--
View this message in context: http://tapestry.1045711.n5.nabble.com/How-to-reuse-a-form-tp5718166p5718189.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: How to reuse a form?

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Thu, 22 Nov 2012 09:09:53 -0200, membersound <me...@web.de> wrote:

> So am I doing it this way?
>
> <t:if test="isSelectDrowdownToBeShown">
>    <t:delegate to="selectBlock" />
> </t:if>
>
>
> <t:block t:id="selectBlock">
>    <t:select .../>
> </t:block>
>
>
> Is this the proper way of using blocks for my need in Q2?

Nope if you want to add stuff to your form when using the component your  
created. You don't need blocks for just using the If component in the way  
you used above.

One example, not tested:

In the component class:

@Parameter(defaultPrefix = BindingConstants.LITERAL)
@Property
private Block additionalStuff;

In the component template:

<t:form>
	...
	<t:delegate to="additionalStuff"/>
	...
</t:form>

Usage:

<t:thecomponentyoucreatedwiththeforminside>
	<p:additionalStuff>
		anything you want
	</p:additionalStuff>
</t:thecomponentyoucreatedwiththeforminside>

-- 
Thiago H. de Paula Figueiredo

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: How to reuse a form?

Posted by membersound <me...@web.de>.
So am I doing it this way?

<t:if test="isSelectDrowdownToBeShown">
   <t:delegate to="selectBlock" />
</t:if>


<t:block t:id="selectBlock">
   <t:select .../>
</t:block>


Is this the proper way of using blocks for my need in Q2?



--
View this message in context: http://tapestry.1045711.n5.nabble.com/How-to-reuse-a-form-tp5718166p5718187.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: How to reuse a form?

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Wed, 21 Nov 2012 19:37:34 -0200, membersound <me...@web.de> wrote:

> Hi,

Hi!

> I have a form that I want to reuse for another action of a page.
> Q1) How can I define a t:form and just reuse the exact definitions  
> without having to copy/paste the whole form all the time?

Put it inside a component, use this component anywhere you want. :)

> Q2) How can I place an additional field (I require a dropdown t:select)  
> into that form? Without having to copy/paste the whole form code again  
> (which
> would cause a lot of dublication)?

Block parameters. Check  
http://tapestry.apache.org/component-templates.html for <t:block> and the  
parameter namespace.

-- 
Thiago H. de Paula Figueiredo

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org