You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Ryan Owens <ry...@infoether.com> on 2005/03/30 23:39:46 UTC

Conditional Formatting with Forms

I have a pretty simple component with some input fields and a dropdown.
I would like to be able to present the form components in different 
ways by setting a boolean parameter.
Specifically I'd like to organize the fields in a table sometimes, and 
not in a table other times.
note that my example code only shows one field to keep things concise.

--------------------------------
ATTEMPT 1:  Make the table cells conditional:
- - - - - - - - - - - - - - - - -
(HTML TEMPLATE)
<span jwcid="@Conditional" condition="ognl:useTableCells == true">
   <td valign="top" align="left" class="formtext" nowrap>
</span>
     <input type="textfield" jwcid="inputPhone"/>
<span jwcid="@Conditional" condition="ognl:useTableCells == true">
   </td>
</span>
- - - - - - - - - - - - - - - - -
This failed with the error:
Closing tag </td> on line 7 is improperly nested with tag <span> on 
line 6.

So this approach doesn't work because of weird tag nesting.


-----------------------------
ATTEMPT 2:  Use 2 separate 'views' selected conditionally:
- - - - - - - - - - - - - - - - -
(HTML TEMPLATE)
<span jwcid="@contrib:FormConditional" condition="ognl:useTableCells == 
false">
     <input type="textfield" jwcid="inputPhone"/>
</span>

<span jwcid="@contrib:FormConditional" condition="ognl:useTableCells == 
true">
   <td valign="top" align="left" class="formtext" nowrap>
     <input type="textfield" jwcid="inputPhone"/>
   </td>
</span>
- - - - - - - - - - - - - - - - -
This failed with the error:
Template for component EditClient/phoneForm contains multiple 
references to embedded component inputPhone.

So this approach doesn't work because you can't reuse components 
defined in the .page file.


-----------------------------
ATTEMPT 3:  (works) Use 2 separate 'views' selected conditionally and 
define 2 separate 'inputPhone' components.
- - - - - - - - - - - - - - - - -
(HTML TEMPLATE)
<span jwcid="@contrib:FormConditional" condition="ognl:useTableCells == 
false">
     <input type="textfield" jwcid="inputPhone"/>
</span>

<span jwcid="@contrib:FormConditional" condition="ognl:useTableCells == 
true">
   <td valign="top" align="left" class="formtext" nowrap>
     <input type="textfield" jwcid="inputPhone2"/>
   </td>
</span>

(JWC FILE)
   <component id="inputPhone" type="ValidField">
     <static-binding name="displayName" value="Phone Number"/>
     <binding name="validator" expression="beans.validator"/>
     <binding name="value" expression="phone.clientPhoneNumber"/>
   </component>

   <component id="inputPhone2" type="ValidField">
     <static-binding name="displayName" value="Phone Number"/>
     <binding name="validator" expression="beans.validator"/>
     <binding name="value" expression="phone.clientPhoneNumber"/>
   </component>

===========================

This seems like a lot of duplication, especially when I have more than 
1 input field.

Is there a better way to do this?

Ultimately having this component is still a big win since everything is 
contained within this component, and I can reuse all the components 
validators, parameters, properties, and most importantly the 
initialization code in the Component java class.

Any ideas are greatly appreciated.

Thanks,

     Ryan Owens




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


Re: Conditional Formatting with Forms

Posted by Ron Piterman <mp...@vollbio.de>.
If you do go on this one, and you need it really to work well, use the 
code of the Any component, and add a java "if" there instead of using 
(1) conditional, (2) any, (3) render body, (4) conditional (5) render 
body again - 5 components to do the work of one... it will speed things 
up...


ציטוט Ryan Owens:
> hmm, interesting idea.
> 
> I think I like this better than duplicating the entire view.
> The no-duplicate view (with conditionals around table tags) is how I'd 
> have done it in JSP or Velocity,
> but then again having the views separate does let me make more precise 
> tweaks to either view as needed.
> And since it's all in a Tapestry component, it's super easy to use.
> This would have been a huge pain elsewhere, but now all I do is set a 
> parameter to choose my layout. Pretty darn cool.
> Your copy-of tip makes this pretty clean too.
> 
> Good example of readjusting thought processes as your tools improve.
> 
> Thanks for both replies!  I'll have to play around a bit to see what is 
> most intuitive.
> 
>   -Ryan Owens
> 
> 
> On Mar 30, 2005, at 4:50 PM, Ron Piterman wrote:
> 
>> an idea: make a conditional any component:
>> <table jwcid="@ConditionalAny" tag="table" condition="bla">
>>     <tr jwcid="@ConditionalAny" tag="tr" condition="bla">
>>     etc.
>>
>> Now, this is not very elegant, but I could be a start.
>>
>> The component itself seems quite straitforward for me...
>>
>> <span jwcid="condition">
>>     <span jwcid="any">
>>         <span jwcid="@RenderBody"/>
>>     </>
>> </>
>> <span jwcid="invertcondition">
>>     <span jwcid="@RenderBody"/>
>> </>
>>
>>
>>
>>
>>
>>  Ryan Owens:
>>
>>> I have a pretty simple component with some input fields and a dropdown.
>>> I would like to be able to present the form components in different 
>>> ways by setting a boolean parameter.
>>> Specifically I'd like to organize the fields in a table sometimes, 
>>> and not in a table other times.
>>> note that my example code only shows one field to keep things concise.
>>> --------------------------------
>>> ATTEMPT 1:  Make the table cells conditional:
>>> - - - - - - - - - - - - - - - - -
>>> (HTML TEMPLATE)
>>> <span jwcid="@Conditional" condition="ognl:useTableCells == true">
>>>   <td valign="top" align="left" class="formtext" nowrap>
>>> </span>
>>>     <input type="textfield" jwcid="inputPhone"/>
>>> <span jwcid="@Conditional" condition="ognl:useTableCells == true">
>>>   </td>
>>> </span>
>>> - - - - - - - - - - - - - - - - -
>>> This failed with the error:
>>> Closing tag </td> on line 7 is improperly nested with tag <span> on 
>>> line 6.
>>> So this approach doesn't work because of weird tag nesting.
>>> -----------------------------
>>> ATTEMPT 2:  Use 2 separate 'views' selected conditionally:
>>> - - - - - - - - - - - - - - - - -
>>> (HTML TEMPLATE)
>>> <span jwcid="@contrib:FormConditional" condition="ognl:useTableCells 
>>> == false">
>>>     <input type="textfield" jwcid="inputPhone"/>
>>> </span>
>>> <span jwcid="@contrib:FormConditional" condition="ognl:useTableCells 
>>> == true">
>>>   <td valign="top" align="left" class="formtext" nowrap>
>>>     <input type="textfield" jwcid="inputPhone"/>
>>>   </td>
>>> </span>
>>> - - - - - - - - - - - - - - - - -
>>> This failed with the error:
>>> Template for component EditClient/phoneForm contains multiple 
>>> references to embedded component inputPhone.
>>> So this approach doesn't work because you can't reuse components 
>>> defined in the .page file.
>>> -----------------------------
>>> ATTEMPT 3:  (works) Use 2 separate 'views' selected conditionally and 
>>> define 2 separate 'inputPhone' components.
>>> - - - - - - - - - - - - - - - - -
>>> (HTML TEMPLATE)
>>> <span jwcid="@contrib:FormConditional" condition="ognl:useTableCells 
>>> == false">
>>>     <input type="textfield" jwcid="inputPhone"/>
>>> </span>
>>> <span jwcid="@contrib:FormConditional" condition="ognl:useTableCells 
>>> == true">
>>>   <td valign="top" align="left" class="formtext" nowrap>
>>>     <input type="textfield" jwcid="inputPhone2"/>
>>>   </td>
>>> </span>
>>> (JWC FILE)
>>>   <component id="inputPhone" type="ValidField">
>>>     <static-binding name="displayName" value="Phone Number"/>
>>>     <binding name="validator" expression="beans.validator"/>
>>>     <binding name="value" expression="phone.clientPhoneNumber"/>
>>>   </component>
>>>   <component id="inputPhone2" type="ValidField">
>>>     <static-binding name="displayName" value="Phone Number"/>
>>>     <binding name="validator" expression="beans.validator"/>
>>>     <binding name="value" expression="phone.clientPhoneNumber"/>
>>>   </component>
>>> ===========================
>>> This seems like a lot of duplication, especially when I have more 
>>> than 1 input field.
>>> Is there a better way to do this?
>>> Ultimately having this component is still a big win since everything 
>>> is contained within this component, and I can reuse all the 
>>> components validators, parameters, properties, and most importantly 
>>> the initialization code in the Component java class.
>>> Any ideas are greatly appreciated.
>>> Thanks,
>>>     Ryan Owens
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 


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


Re: Conditional Formatting with Forms

Posted by Ryan Owens <ry...@infoether.com>.
hmm, interesting idea.

I think I like this better than duplicating the entire view.
The no-duplicate view (with conditionals around table tags) is how I'd 
have done it in JSP or Velocity,
but then again having the views separate does let me make more precise 
tweaks to either view as needed.
And since it's all in a Tapestry component, it's super easy to use.
This would have been a huge pain elsewhere, but now all I do is set a 
parameter to choose my layout. Pretty darn cool.
Your copy-of tip makes this pretty clean too.

Good example of readjusting thought processes as your tools improve.

Thanks for both replies!  I'll have to play around a bit to see what is 
most intuitive.

   -Ryan Owens


On Mar 30, 2005, at 4:50 PM, Ron Piterman wrote:

> an idea: make a conditional any component:
> <table jwcid="@ConditionalAny" tag="table" condition="bla">
> 	<tr jwcid="@ConditionalAny" tag="tr" condition="bla">
> 	etc.
>
> Now, this is not very elegant, but I could be a start.
>
> The component itself seems quite straitforward for me...
>
> <span jwcid="condition">
> 	<span jwcid="any">
> 		<span jwcid="@RenderBody"/>
> 	</>
> </>
> <span jwcid="invertcondition">
> 	<span jwcid="@RenderBody"/>
> </>
>
>
>
>
>
>  Ryan Owens:
>> I have a pretty simple component with some input fields and a 
>> dropdown.
>> I would like to be able to present the form components in different 
>> ways by setting a boolean parameter.
>> Specifically I'd like to organize the fields in a table sometimes, 
>> and not in a table other times.
>> note that my example code only shows one field to keep things concise.
>> --------------------------------
>> ATTEMPT 1:  Make the table cells conditional:
>> - - - - - - - - - - - - - - - - -
>> (HTML TEMPLATE)
>> <span jwcid="@Conditional" condition="ognl:useTableCells == true">
>>   <td valign="top" align="left" class="formtext" nowrap>
>> </span>
>>     <input type="textfield" jwcid="inputPhone"/>
>> <span jwcid="@Conditional" condition="ognl:useTableCells == true">
>>   </td>
>> </span>
>> - - - - - - - - - - - - - - - - -
>> This failed with the error:
>> Closing tag </td> on line 7 is improperly nested with tag <span> on 
>> line 6.
>> So this approach doesn't work because of weird tag nesting.
>> -----------------------------
>> ATTEMPT 2:  Use 2 separate 'views' selected conditionally:
>> - - - - - - - - - - - - - - - - -
>> (HTML TEMPLATE)
>> <span jwcid="@contrib:FormConditional" condition="ognl:useTableCells 
>> == false">
>>     <input type="textfield" jwcid="inputPhone"/>
>> </span>
>> <span jwcid="@contrib:FormConditional" condition="ognl:useTableCells 
>> == true">
>>   <td valign="top" align="left" class="formtext" nowrap>
>>     <input type="textfield" jwcid="inputPhone"/>
>>   </td>
>> </span>
>> - - - - - - - - - - - - - - - - -
>> This failed with the error:
>> Template for component EditClient/phoneForm contains multiple 
>> references to embedded component inputPhone.
>> So this approach doesn't work because you can't reuse components 
>> defined in the .page file.
>> -----------------------------
>> ATTEMPT 3:  (works) Use 2 separate 'views' selected conditionally and 
>> define 2 separate 'inputPhone' components.
>> - - - - - - - - - - - - - - - - -
>> (HTML TEMPLATE)
>> <span jwcid="@contrib:FormConditional" condition="ognl:useTableCells 
>> == false">
>>     <input type="textfield" jwcid="inputPhone"/>
>> </span>
>> <span jwcid="@contrib:FormConditional" condition="ognl:useTableCells 
>> == true">
>>   <td valign="top" align="left" class="formtext" nowrap>
>>     <input type="textfield" jwcid="inputPhone2"/>
>>   </td>
>> </span>
>> (JWC FILE)
>>   <component id="inputPhone" type="ValidField">
>>     <static-binding name="displayName" value="Phone Number"/>
>>     <binding name="validator" expression="beans.validator"/>
>>     <binding name="value" expression="phone.clientPhoneNumber"/>
>>   </component>
>>   <component id="inputPhone2" type="ValidField">
>>     <static-binding name="displayName" value="Phone Number"/>
>>     <binding name="validator" expression="beans.validator"/>
>>     <binding name="value" expression="phone.clientPhoneNumber"/>
>>   </component>
>> ===========================
>> This seems like a lot of duplication, especially when I have more 
>> than 1 input field.
>> Is there a better way to do this?
>> Ultimately having this component is still a big win since everything 
>> is contained within this component, and I can reuse all the 
>> components validators, parameters, properties, and most importantly 
>> the initialization code in the Component java class.
>> Any ideas are greatly appreciated.
>> Thanks,
>>     Ryan Owens
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>


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


Re: Conditional Formatting with Forms

Posted by Ron Piterman <mp...@vollbio.de>.
an idea: make a conditional any component:
<table jwcid="@ConditionalAny" tag="table" condition="bla">
	<tr jwcid="@ConditionalAny" tag="tr" condition="bla">
	etc.

Now, this is not very elegant, but I could be a start.

The component itself seems quite straitforward for me...

<span jwcid="condition">
	<span jwcid="any">
		<span jwcid="@RenderBody"/>
	</>
</>
<span jwcid="invertcondition">
	<span jwcid="@RenderBody"/>
</>





  Ryan Owens:
> I have a pretty simple component with some input fields and a dropdown.
> I would like to be able to present the form components in different ways 
> by setting a boolean parameter.
> Specifically I'd like to organize the fields in a table sometimes, and 
> not in a table other times.
> note that my example code only shows one field to keep things concise.
> 
> --------------------------------
> ATTEMPT 1:  Make the table cells conditional:
> - - - - - - - - - - - - - - - - -
> (HTML TEMPLATE)
> <span jwcid="@Conditional" condition="ognl:useTableCells == true">
>   <td valign="top" align="left" class="formtext" nowrap>
> </span>
>     <input type="textfield" jwcid="inputPhone"/>
> <span jwcid="@Conditional" condition="ognl:useTableCells == true">
>   </td>
> </span>
> - - - - - - - - - - - - - - - - -
> This failed with the error:
> Closing tag </td> on line 7 is improperly nested with tag <span> on line 6.
> 
> So this approach doesn't work because of weird tag nesting.
> 
> 
> -----------------------------
> ATTEMPT 2:  Use 2 separate 'views' selected conditionally:
> - - - - - - - - - - - - - - - - -
> (HTML TEMPLATE)
> <span jwcid="@contrib:FormConditional" condition="ognl:useTableCells == 
> false">
>     <input type="textfield" jwcid="inputPhone"/>
> </span>
> 
> <span jwcid="@contrib:FormConditional" condition="ognl:useTableCells == 
> true">
>   <td valign="top" align="left" class="formtext" nowrap>
>     <input type="textfield" jwcid="inputPhone"/>
>   </td>
> </span>
> - - - - - - - - - - - - - - - - -
> This failed with the error:
> Template for component EditClient/phoneForm contains multiple references 
> to embedded component inputPhone.
> 
> So this approach doesn't work because you can't reuse components defined 
> in the .page file.
> 
> 
> -----------------------------
> ATTEMPT 3:  (works) Use 2 separate 'views' selected conditionally and 
> define 2 separate 'inputPhone' components.
> - - - - - - - - - - - - - - - - -
> (HTML TEMPLATE)
> <span jwcid="@contrib:FormConditional" condition="ognl:useTableCells == 
> false">
>     <input type="textfield" jwcid="inputPhone"/>
> </span>
> 
> <span jwcid="@contrib:FormConditional" condition="ognl:useTableCells == 
> true">
>   <td valign="top" align="left" class="formtext" nowrap>
>     <input type="textfield" jwcid="inputPhone2"/>
>   </td>
> </span>
> 
> (JWC FILE)
>   <component id="inputPhone" type="ValidField">
>     <static-binding name="displayName" value="Phone Number"/>
>     <binding name="validator" expression="beans.validator"/>
>     <binding name="value" expression="phone.clientPhoneNumber"/>
>   </component>
> 
>   <component id="inputPhone2" type="ValidField">
>     <static-binding name="displayName" value="Phone Number"/>
>     <binding name="validator" expression="beans.validator"/>
>     <binding name="value" expression="phone.clientPhoneNumber"/>
>   </component>
> 
> ===========================
> 
> This seems like a lot of duplication, especially when I have more than 1 
> input field.
> 
> Is there a better way to do this?
> 
> Ultimately having this component is still a big win since everything is 
> contained within this component, and I can reuse all the components 
> validators, parameters, properties, and most importantly the 
> initialization code in the Component java class.
> 
> Any ideas are greatly appreciated.
> 
> Thanks,
> 
>     Ryan Owens
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 


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


Re: Conditional Formatting with Forms

Posted by Ryan Owens <ry...@infoether.com>.
wow, that's extremely cool, and perfect for this. I don't think I've 
ever heard of 'copy-of' before.
Now to go look for other places to use it.  :)

Thanks!!!

     Ryan Owens


On Mar 30, 2005, at 4:52 PM, Ron Piterman wrote:

> Now, if you want to keep it in double layout, and separate it using a 
> conditional, you can use copy-of:
> (taken out of your example no. 4)
>
> >   <component id="inputPhone" type="ValidField">
> >     <static-binding name="displayName" value="Phone Number"/>
> >     <binding name="validator" expression="beans.validator"/>
> >     <binding name="value" expression="phone.clientPhoneNumber"/>
> >   </component>
> >
> >   <component id="inputPhone2" copy-of="inputPhone"/>
> >
>
> So you don't really have to repeat the whole definition...
>
>
> ציטוט Ryan Owens:
>> I have a pretty simple component with some input fields and a 
>> dropdown.
>> I would like to be able to present the form components in different 
>> ways by setting a boolean parameter.
>> Specifically I'd like to organize the fields in a table sometimes, 
>> and not in a table other times.
>> note that my example code only shows one field to keep things concise.
>> --------------------------------
>> ATTEMPT 1:  Make the table cells conditional:
>> - - - - - - - - - - - - - - - - -
>> (HTML TEMPLATE)
>> <span jwcid="@Conditional" condition="ognl:useTableCells == true">
>>   <td valign="top" align="left" class="formtext" nowrap>
>> </span>
>>     <input type="textfield" jwcid="inputPhone"/>
>> <span jwcid="@Conditional" condition="ognl:useTableCells == true">
>>   </td>
>> </span>
>> - - - - - - - - - - - - - - - - -
>> This failed with the error:
>> Closing tag </td> on line 7 is improperly nested with tag <span> on 
>> line 6.
>> So this approach doesn't work because of weird tag nesting.
>> -----------------------------
>> ATTEMPT 2:  Use 2 separate 'views' selected conditionally:
>> - - - - - - - - - - - - - - - - -
>> (HTML TEMPLATE)
>> <span jwcid="@contrib:FormConditional" condition="ognl:useTableCells 
>> == false">
>>     <input type="textfield" jwcid="inputPhone"/>
>> </span>
>> <span jwcid="@contrib:FormConditional" condition="ognl:useTableCells 
>> == true">
>>   <td valign="top" align="left" class="formtext" nowrap>
>>     <input type="textfield" jwcid="inputPhone"/>
>>   </td>
>> </span>
>> - - - - - - - - - - - - - - - - -
>> This failed with the error:
>> Template for component EditClient/phoneForm contains multiple 
>> references to embedded component inputPhone.
>> So this approach doesn't work because you can't reuse components 
>> defined in the .page file.
>> -----------------------------
>> ATTEMPT 3:  (works) Use 2 separate 'views' selected conditionally and 
>> define 2 separate 'inputPhone' components.
>> - - - - - - - - - - - - - - - - -
>> (HTML TEMPLATE)
>> <span jwcid="@contrib:FormConditional" condition="ognl:useTableCells 
>> == false">
>>     <input type="textfield" jwcid="inputPhone"/>
>> </span>
>> <span jwcid="@contrib:FormConditional" condition="ognl:useTableCells 
>> == true">
>>   <td valign="top" align="left" class="formtext" nowrap>
>>     <input type="textfield" jwcid="inputPhone2"/>
>>   </td>
>> </span>
>> (JWC FILE)
>>   <component id="inputPhone" type="ValidField">
>>     <static-binding name="displayName" value="Phone Number"/>
>>     <binding name="validator" expression="beans.validator"/>
>>     <binding name="value" expression="phone.clientPhoneNumber"/>
>>   </component>
>>   <component id="inputPhone2" type="ValidField">
>>     <static-binding name="displayName" value="Phone Number"/>
>>     <binding name="validator" expression="beans.validator"/>
>>     <binding name="value" expression="phone.clientPhoneNumber"/>
>>   </component>
>> ===========================
>> This seems like a lot of duplication, especially when I have more 
>> than 1 input field.
>> Is there a better way to do this?
>> Ultimately having this component is still a big win since everything 
>> is contained within this component, and I can reuse all the 
>> components validators, parameters, properties, and most importantly 
>> the initialization code in the Component java class.
>> Any ideas are greatly appreciated.
>> Thanks,
>>     Ryan Owens
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>


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


Re: Conditional Formatting with Forms

Posted by Ron Piterman <mp...@vollbio.de>.
Now, if you want to keep it in double layout, and separate it using a 
conditional, you can use copy-of:
(taken out of your example no. 4)

 >   <component id="inputPhone" type="ValidField">
 >     <static-binding name="displayName" value="Phone Number"/>
 >     <binding name="validator" expression="beans.validator"/>
 >     <binding name="value" expression="phone.clientPhoneNumber"/>
 >   </component>
 >
 >   <component id="inputPhone2" copy-of="inputPhone"/>
 >

So you don't really have to repeat the whole definition...


ציטוט Ryan Owens:
> I have a pretty simple component with some input fields and a dropdown.
> I would like to be able to present the form components in different ways 
> by setting a boolean parameter.
> Specifically I'd like to organize the fields in a table sometimes, and 
> not in a table other times.
> note that my example code only shows one field to keep things concise.
> 
> --------------------------------
> ATTEMPT 1:  Make the table cells conditional:
> - - - - - - - - - - - - - - - - -
> (HTML TEMPLATE)
> <span jwcid="@Conditional" condition="ognl:useTableCells == true">
>   <td valign="top" align="left" class="formtext" nowrap>
> </span>
>     <input type="textfield" jwcid="inputPhone"/>
> <span jwcid="@Conditional" condition="ognl:useTableCells == true">
>   </td>
> </span>
> - - - - - - - - - - - - - - - - -
> This failed with the error:
> Closing tag </td> on line 7 is improperly nested with tag <span> on line 6.
> 
> So this approach doesn't work because of weird tag nesting.
> 
> 
> -----------------------------
> ATTEMPT 2:  Use 2 separate 'views' selected conditionally:
> - - - - - - - - - - - - - - - - -
> (HTML TEMPLATE)
> <span jwcid="@contrib:FormConditional" condition="ognl:useTableCells == 
> false">
>     <input type="textfield" jwcid="inputPhone"/>
> </span>
> 
> <span jwcid="@contrib:FormConditional" condition="ognl:useTableCells == 
> true">
>   <td valign="top" align="left" class="formtext" nowrap>
>     <input type="textfield" jwcid="inputPhone"/>
>   </td>
> </span>
> - - - - - - - - - - - - - - - - -
> This failed with the error:
> Template for component EditClient/phoneForm contains multiple references 
> to embedded component inputPhone.
> 
> So this approach doesn't work because you can't reuse components defined 
> in the .page file.
> 
> 
> -----------------------------
> ATTEMPT 3:  (works) Use 2 separate 'views' selected conditionally and 
> define 2 separate 'inputPhone' components.
> - - - - - - - - - - - - - - - - -
> (HTML TEMPLATE)
> <span jwcid="@contrib:FormConditional" condition="ognl:useTableCells == 
> false">
>     <input type="textfield" jwcid="inputPhone"/>
> </span>
> 
> <span jwcid="@contrib:FormConditional" condition="ognl:useTableCells == 
> true">
>   <td valign="top" align="left" class="formtext" nowrap>
>     <input type="textfield" jwcid="inputPhone2"/>
>   </td>
> </span>
> 
> (JWC FILE)
>   <component id="inputPhone" type="ValidField">
>     <static-binding name="displayName" value="Phone Number"/>
>     <binding name="validator" expression="beans.validator"/>
>     <binding name="value" expression="phone.clientPhoneNumber"/>
>   </component>
> 
>   <component id="inputPhone2" type="ValidField">
>     <static-binding name="displayName" value="Phone Number"/>
>     <binding name="validator" expression="beans.validator"/>
>     <binding name="value" expression="phone.clientPhoneNumber"/>
>   </component>
> 
> ===========================
> 
> This seems like a lot of duplication, especially when I have more than 1 
> input field.
> 
> Is there a better way to do this?
> 
> Ultimately having this component is still a big win since everything is 
> contained within this component, and I can reuse all the components 
> validators, parameters, properties, and most importantly the 
> initialization code in the Component java class.
> 
> Any ideas are greatly appreciated.
> 
> Thanks,
> 
>     Ryan Owens
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 


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


Re: Conditional Formatting with Forms

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
I recommend separate components for this scenario, so that you can have 
separate templates to keep things simple in the layout.  Most of the 
rest can be shared, like the backing component class and such.

	Erik

On Mar 30, 2005, at 5:22 PM, Ryan Owens wrote:

>> I don't have any advice for this situation, but I'm curious why you 
>> need to have a component morph that way rather than use CSS somehow.
>>
>> 	Erik
>>
>
>
> Normally I would use css, however in this case there are 2 separate 
> pages where I have to edit phone numbers.
>
> In one the client wants the various input fields organized one way, 
> and on the other page a very different way.
>
> Basically, it's just one of those cases where I have to use a table 
> instead of plain ol css.
>
> for instance:
>
> ------------------------------------------
> INPUT 1                        INPUT 2
> INPUT 3                        INPUT 4
>                DROPDOWN
>
>
> versus
>
> ------------------------------------------
> INPUT 1                        INPUT 3                   DROPDOWN
> INPUT 2                        INPUT 4
>
> versus
>
> ------------------------------------------
> INPUT 1         INPUT 2           INPUT 3         INPUT 4          
> DROPDOWN
>
>
> As far as I know I have to use tables for this, though I'd love to be 
> wrong. :)
>
> -Ryan Owens
>
>
>
>> On Mar 30, 2005, at 4:39 PM, Ryan Owens wrote:
>>
>>> I have a pretty simple component with some input fields and a 
>>> dropdown.
>>> I would like to be able to present the form components in different 
>>> ways by setting a boolean parameter.
>>> Specifically I'd like to organize the fields in a table sometimes, 
>>> and not in a table other times.
>>> note that my example code only shows one field to keep things 
>>> concise.
>>>
>>> --------------------------------
>>> ATTEMPT 1:  Make the table cells conditional:
>>> - - - - - - - - - - - - - - - - -
>>> (HTML TEMPLATE)
>>> <span jwcid="@Conditional" condition="ognl:useTableCells == true">
>>>   <td valign="top" align="left" class="formtext" nowrap>
>>> </span>
>>>     <input type="textfield" jwcid="inputPhone"/>
>>> <span jwcid="@Conditional" condition="ognl:useTableCells == true">
>>>   </td>
>>> </span>
>>> - - - - - - - - - - - - - - - - -
>>> This failed with the error:
>>> Closing tag </td> on line 7 is improperly nested with tag <span> on 
>>> line 6.
>>>
>>> So this approach doesn't work because of weird tag nesting.
>>>
>>>
>>> -----------------------------
>>> ATTEMPT 2:  Use 2 separate 'views' selected conditionally:
>>> - - - - - - - - - - - - - - - - -
>>> (HTML TEMPLATE)
>>> <span jwcid="@contrib:FormConditional" condition="ognl:useTableCells 
>>> == false">
>>>     <input type="textfield" jwcid="inputPhone"/>
>>> </span>
>>>
>>> <span jwcid="@contrib:FormConditional" condition="ognl:useTableCells 
>>> == true">
>>>   <td valign="top" align="left" class="formtext" nowrap>
>>>     <input type="textfield" jwcid="inputPhone"/>
>>>   </td>
>>> </span>
>>> - - - - - - - - - - - - - - - - -
>>> This failed with the error:
>>> Template for component EditClient/phoneForm contains multiple 
>>> references to embedded component inputPhone.
>>>
>>> So this approach doesn't work because you can't reuse components 
>>> defined in the .page file.
>>>
>>>
>>> -----------------------------
>>> ATTEMPT 3:  (works) Use 2 separate 'views' selected conditionally 
>>> and define 2 separate 'inputPhone' components.
>>> - - - - - - - - - - - - - - - - -
>>> (HTML TEMPLATE)
>>> <span jwcid="@contrib:FormConditional" condition="ognl:useTableCells 
>>> == false">
>>>     <input type="textfield" jwcid="inputPhone"/>
>>> </span>
>>>
>>> <span jwcid="@contrib:FormConditional" condition="ognl:useTableCells 
>>> == true">
>>>   <td valign="top" align="left" class="formtext" nowrap>
>>>     <input type="textfield" jwcid="inputPhone2"/>
>>>   </td>
>>> </span>
>>>
>>> (JWC FILE)
>>>   <component id="inputPhone" type="ValidField">
>>>     <static-binding name="displayName" value="Phone Number"/>
>>>     <binding name="validator" expression="beans.validator"/>
>>>     <binding name="value" expression="phone.clientPhoneNumber"/>
>>>   </component>
>>>
>>>   <component id="inputPhone2" type="ValidField">
>>>     <static-binding name="displayName" value="Phone Number"/>
>>>     <binding name="validator" expression="beans.validator"/>
>>>     <binding name="value" expression="phone.clientPhoneNumber"/>
>>>   </component>
>>>
>>> ===========================
>>>
>>> This seems like a lot of duplication, especially when I have more 
>>> than 1 input field.
>>>
>>> Is there a better way to do this?
>>>
>>> Ultimately having this component is still a big win since everything 
>>> is contained within this component, and I can reuse all the 
>>> components validators, parameters, properties, and most importantly 
>>> the initialization code in the Component java class.
>>>
>>> Any ideas are greatly appreciated.
>>>
>>> Thanks,
>>>
>>>     Ryan Owens
>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>> For additional commands, e-mail: 
>>> tapestry-user-help@jakarta.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


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


Re: Conditional Formatting with Forms

Posted by Ryan Owens <ry...@infoether.com>.
> I don't have any advice for this situation, but I'm curious why you 
> need to have a component morph that way rather than use CSS somehow.
>
> 	Erik
>


Normally I would use css, however in this case there are 2 separate 
pages where I have to edit phone numbers.

In one the client wants the various input fields organized one way, and 
on the other page a very different way.

Basically, it's just one of those cases where I have to use a table 
instead of plain ol css.

for instance:

------------------------------------------
INPUT 1                        INPUT 2
INPUT 3                        INPUT 4
                DROPDOWN


versus

------------------------------------------
INPUT 1                        INPUT 3                   DROPDOWN
INPUT 2                        INPUT 4

versus

------------------------------------------
INPUT 1         INPUT 2           INPUT 3         INPUT 4          
DROPDOWN


As far as I know I have to use tables for this, though I'd love to be 
wrong. :)

-Ryan Owens



> On Mar 30, 2005, at 4:39 PM, Ryan Owens wrote:
>
>> I have a pretty simple component with some input fields and a 
>> dropdown.
>> I would like to be able to present the form components in different 
>> ways by setting a boolean parameter.
>> Specifically I'd like to organize the fields in a table sometimes, 
>> and not in a table other times.
>> note that my example code only shows one field to keep things concise.
>>
>> --------------------------------
>> ATTEMPT 1:  Make the table cells conditional:
>> - - - - - - - - - - - - - - - - -
>> (HTML TEMPLATE)
>> <span jwcid="@Conditional" condition="ognl:useTableCells == true">
>>   <td valign="top" align="left" class="formtext" nowrap>
>> </span>
>>     <input type="textfield" jwcid="inputPhone"/>
>> <span jwcid="@Conditional" condition="ognl:useTableCells == true">
>>   </td>
>> </span>
>> - - - - - - - - - - - - - - - - -
>> This failed with the error:
>> Closing tag </td> on line 7 is improperly nested with tag <span> on 
>> line 6.
>>
>> So this approach doesn't work because of weird tag nesting.
>>
>>
>> -----------------------------
>> ATTEMPT 2:  Use 2 separate 'views' selected conditionally:
>> - - - - - - - - - - - - - - - - -
>> (HTML TEMPLATE)
>> <span jwcid="@contrib:FormConditional" condition="ognl:useTableCells 
>> == false">
>>     <input type="textfield" jwcid="inputPhone"/>
>> </span>
>>
>> <span jwcid="@contrib:FormConditional" condition="ognl:useTableCells 
>> == true">
>>   <td valign="top" align="left" class="formtext" nowrap>
>>     <input type="textfield" jwcid="inputPhone"/>
>>   </td>
>> </span>
>> - - - - - - - - - - - - - - - - -
>> This failed with the error:
>> Template for component EditClient/phoneForm contains multiple 
>> references to embedded component inputPhone.
>>
>> So this approach doesn't work because you can't reuse components 
>> defined in the .page file.
>>
>>
>> -----------------------------
>> ATTEMPT 3:  (works) Use 2 separate 'views' selected conditionally and 
>> define 2 separate 'inputPhone' components.
>> - - - - - - - - - - - - - - - - -
>> (HTML TEMPLATE)
>> <span jwcid="@contrib:FormConditional" condition="ognl:useTableCells 
>> == false">
>>     <input type="textfield" jwcid="inputPhone"/>
>> </span>
>>
>> <span jwcid="@contrib:FormConditional" condition="ognl:useTableCells 
>> == true">
>>   <td valign="top" align="left" class="formtext" nowrap>
>>     <input type="textfield" jwcid="inputPhone2"/>
>>   </td>
>> </span>
>>
>> (JWC FILE)
>>   <component id="inputPhone" type="ValidField">
>>     <static-binding name="displayName" value="Phone Number"/>
>>     <binding name="validator" expression="beans.validator"/>
>>     <binding name="value" expression="phone.clientPhoneNumber"/>
>>   </component>
>>
>>   <component id="inputPhone2" type="ValidField">
>>     <static-binding name="displayName" value="Phone Number"/>
>>     <binding name="validator" expression="beans.validator"/>
>>     <binding name="value" expression="phone.clientPhoneNumber"/>
>>   </component>
>>
>> ===========================
>>
>> This seems like a lot of duplication, especially when I have more 
>> than 1 input field.
>>
>> Is there a better way to do this?
>>
>> Ultimately having this component is still a big win since everything 
>> is contained within this component, and I can reuse all the 
>> components validators, parameters, properties, and most importantly 
>> the initialization code in the Component java class.
>>
>> Any ideas are greatly appreciated.
>>
>> Thanks,
>>
>>     Ryan Owens
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>


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


Re: Conditional Formatting with Forms

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
I don't have any advice for this situation, but I'm curious why you 
need to have a component morph that way rather than use CSS somehow.

	Erik

On Mar 30, 2005, at 4:39 PM, Ryan Owens wrote:

> I have a pretty simple component with some input fields and a dropdown.
> I would like to be able to present the form components in different 
> ways by setting a boolean parameter.
> Specifically I'd like to organize the fields in a table sometimes, and 
> not in a table other times.
> note that my example code only shows one field to keep things concise.
>
> --------------------------------
> ATTEMPT 1:  Make the table cells conditional:
> - - - - - - - - - - - - - - - - -
> (HTML TEMPLATE)
> <span jwcid="@Conditional" condition="ognl:useTableCells == true">
>   <td valign="top" align="left" class="formtext" nowrap>
> </span>
>     <input type="textfield" jwcid="inputPhone"/>
> <span jwcid="@Conditional" condition="ognl:useTableCells == true">
>   </td>
> </span>
> - - - - - - - - - - - - - - - - -
> This failed with the error:
> Closing tag </td> on line 7 is improperly nested with tag <span> on 
> line 6.
>
> So this approach doesn't work because of weird tag nesting.
>
>
> -----------------------------
> ATTEMPT 2:  Use 2 separate 'views' selected conditionally:
> - - - - - - - - - - - - - - - - -
> (HTML TEMPLATE)
> <span jwcid="@contrib:FormConditional" condition="ognl:useTableCells 
> == false">
>     <input type="textfield" jwcid="inputPhone"/>
> </span>
>
> <span jwcid="@contrib:FormConditional" condition="ognl:useTableCells 
> == true">
>   <td valign="top" align="left" class="formtext" nowrap>
>     <input type="textfield" jwcid="inputPhone"/>
>   </td>
> </span>
> - - - - - - - - - - - - - - - - -
> This failed with the error:
> Template for component EditClient/phoneForm contains multiple 
> references to embedded component inputPhone.
>
> So this approach doesn't work because you can't reuse components 
> defined in the .page file.
>
>
> -----------------------------
> ATTEMPT 3:  (works) Use 2 separate 'views' selected conditionally and 
> define 2 separate 'inputPhone' components.
> - - - - - - - - - - - - - - - - -
> (HTML TEMPLATE)
> <span jwcid="@contrib:FormConditional" condition="ognl:useTableCells 
> == false">
>     <input type="textfield" jwcid="inputPhone"/>
> </span>
>
> <span jwcid="@contrib:FormConditional" condition="ognl:useTableCells 
> == true">
>   <td valign="top" align="left" class="formtext" nowrap>
>     <input type="textfield" jwcid="inputPhone2"/>
>   </td>
> </span>
>
> (JWC FILE)
>   <component id="inputPhone" type="ValidField">
>     <static-binding name="displayName" value="Phone Number"/>
>     <binding name="validator" expression="beans.validator"/>
>     <binding name="value" expression="phone.clientPhoneNumber"/>
>   </component>
>
>   <component id="inputPhone2" type="ValidField">
>     <static-binding name="displayName" value="Phone Number"/>
>     <binding name="validator" expression="beans.validator"/>
>     <binding name="value" expression="phone.clientPhoneNumber"/>
>   </component>
>
> ===========================
>
> This seems like a lot of duplication, especially when I have more than 
> 1 input field.
>
> Is there a better way to do this?
>
> Ultimately having this component is still a big win since everything 
> is contained within this component, and I can reuse all the components 
> validators, parameters, properties, and most importantly the 
> initialization code in the Component java class.
>
> Any ideas are greatly appreciated.
>
> Thanks,
>
>     Ryan Owens
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


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


RE: IExternalPage

Posted by Steven Porter <sp...@yahoo.co.uk>.
Alternatively, if you would prefer to "tell your pages" what their
properties are, rather than have them "discover" there properties in
pageRenderListener, then it's as simple as:

public void onCancel(IRequestCycle cycle) {
   ViewProfile page = (ViewProfile) cycle.getPage("ViewProfile");
   page.setMyProperty(...);
   page.setMyProperty2(...);
   cycle.activate(page);
}

The two different approaches are thought of as "push" versus "pull".

If you have property setters such as above, then the implementation of
activateExternalPage should use them as well, extracting the values from the
parameters.

sp

> -----Original Message-----
> From: Jamie Orchard-Hays [mailto:jamie@dang.com]
> Sent: 30 March 2005 23:26
> To: Tapestry users
> Subject: Re: IExternalPage
>
>
> You can implement pageBeginRener() of PageRenderListener interface and
> put all the work in there. Just set the parameters you need in
> activateExternalPage() and let pageBeginRender() handle the rest.
>
> david joffrin wrote:
>
> > Hi,
> >
> > All my pages are implementing the IExternalPage interface as I decided
> > that all my pages will be accessed via the ExternalLink component,
> > but, how do I implement the activation of a page inside my application
> > code:
> >    public void onCancel(IRequestCycle cycle) {
> >        ViewProfile page = (ViewProfile) cycle.getPage("ViewProfile");
> >        cycle.activate(page);
> >    }
> > The ViewProfile needs date loaded in the activateExternalPage method.
> > Shall I move the code to a common method? Or is there a way to
> > activate the external link?
> >
> > Thanks.
> > David
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>



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


Re: IExternalPage

Posted by Jamie Orchard-Hays <ja...@dang.com>.
You can implement pageBeginRener() of PageRenderListener interface and 
put all the work in there. Just set the parameters you need in 
activateExternalPage() and let pageBeginRender() handle the rest.

david joffrin wrote:

> Hi,
>
> All my pages are implementing the IExternalPage interface as I decided 
> that all my pages will be accessed via the ExternalLink component, 
> but, how do I implement the activation of a page inside my application 
> code:
>    public void onCancel(IRequestCycle cycle) {
>        ViewProfile page = (ViewProfile) cycle.getPage("ViewProfile");
>        cycle.activate(page);
>    }
> The ViewProfile needs date loaded in the activateExternalPage method. 
> Shall I move the code to a common method? Or is there a way to 
> activate the external link?
>
> Thanks.
> David
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>

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


IExternalPage

Posted by david joffrin <da...@hotmail.com>.
Hi,

All my pages are implementing the IExternalPage interface as I decided that 
all my pages will be accessed via the ExternalLink component, but, how do I 
implement the activation of a page inside my application code:
    public void onCancel(IRequestCycle cycle) {
        ViewProfile page = (ViewProfile) cycle.getPage("ViewProfile");
        cycle.activate(page);
    }
The ViewProfile needs date loaded in the activateExternalPage method. Shall 
I move the code to a common method? Or is there a way to activate the 
external link?

Thanks.
David



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