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/05 17:43:46 UTC

Show and hide fields based on boolean dynamic property?

Hi,

how can I show and hide files of a <t:beanEditor object="car"> based on a
boolean variable within the object that is displayed?

class Car {
   boolean flag;
   String name;
}

How can I tell Tapestry to only display the name is flag is marked. And if I
uncheck the checkbox in beanEditor, I want the name to disappear.

Any hints?



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Show-and-hide-fields-based-on-boolean-dynamic-property-tp5717668.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: Show and hide fields based on boolean dynamic property?

Posted by Lance Java <la...@googlemail.com>.
To me, it sounds like you can achieve most of this with javascript. Attach a
listener to the "change" event on the checkbox which toggles the visibility
of the field. On the serverside, you will check he value of the boolean flag
to determine if the field is initially hidden or visible.

In jquery, this would look something like:
$('#checkboxId').on('change', function(event) { $('#fieldId').toggle(); });

This will need to be adapted to the equivelant protoype if you are NOT using
tapestry-jquery.



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Show-and-hide-fields-based-on-boolean-dynamic-property-tp5717668p5717692.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: Show and hide fields based on boolean dynamic property?

Posted by membersound <me...@web.de>.
What do I need the beanmodel for? I mean, the boolean checkbox is already
displayed, as well as the property that I want to hide by checking the box.
Both fields are in the same object.
Can I apply conditions somehow on a object??

Is there any example that I did not find yet?

At the moment I could just imagine something like this in tml file:
<t:zone t:id="myform" id="myform">
<t:beanEditor object="object">
<p:propertyCell><t:if
test="!object.flag">${object.name}</t:if><p:propertyCell>
<p:flagCell><t:checkbox value="object.flag"
zone="myform"/></t:if><p:flagCell>
</t:beanEditor>
</t:zone>

Is that overcomplicating things? Are there better approaches?



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Show-and-hide-fields-based-on-boolean-dynamic-property-tp5717668p5717687.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: Show and hide fields based on boolean dynamic property?

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Mon, 05 Nov 2012 14:43:46 -0200, membersound <me...@web.de> wrote:

> Hi,

Hi!

> how can I show and hide files of a <t:beanEditor object="car"> based on a
> boolean variable within the object that is displayed?

You need to use provide a BeanModel for that. Besides that, just pretty  
boring Java logic.

-- 
Thiago H. de Paula Figueiredo

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