On Fri, 08 Nov 2013 08:59:14 -0200, thegreatmewel
<thegreatme...@gmail.com> wrote:
Hi Thiago, it works now, thanks a lot. So the t:id attribute is bound to
the component and the value attribute is bound to the property.
Yep, but, actually, t:id isn't bound to anything: it's not a parameter,
it's a component id, nothing more than that.
I think thats all a little bit confusing for new tapestry users like me.
First of all the "value" attribute. In standard HTML the value attribute
of an input field defines its predefined value. This is pretty obvious,
the component gets its value from the "value"-attribute and you can
access it with getVal() in js. But using this attribute to bind it to a
tapestry property makes no sense to me, because thats a different
thing. Why not name it t:property? This would make it a lot clearer.
In this case, my perception is the opposite: the value attribute of HTML
form fields will be populated by the bound property when it's rendered and
then used to populate the property when the form submission is done, so
it's very natural to have the property binding to be named 'value'.
Second, why do I need to define a component and a property binding? Why
cannot the component itself has a getValue() method? Well maybe thats a
design decision and I don't see the advantage. But for me its extra code
which confuses me.
Because then you'd need write code to copy the current value from edited
property to component, so the field is populated with the current property
value, and from component to edited property, so the property you editing
gets the value the user typed, yourself. Just like you do in Struts 1, and
it sucks big time. It also provides Tapestry the chance to automatically
convert values (you can use a TextField to edit any kind of object,
provided there's a Translator for it) and also apply validations
automatically.
Actually, the way the Tapestry form fields components are written is
avoiding code, not creating extra code. Again, your perception here is the
opposite. And, in more than 6 years in this mailing list, you're the first
one to say that. :P
--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org