On Thu, 06 Nov 2014 09:03:38 -0200, Ivano Luberti <lube...@archicoop.it> wrote:

Thanks Thiago, you answer quickly as usually and always providing the
fishing rod not the fish :-)

:)

Yes I saw that page, of course but to me, for a newbie it lacks
indications on how to get together the select model with the bean model.

Actually, you don't associate a SelectModel with BeanModel. You do this in your edition block. There, you'll have a Select component. Pass it the SelectModel you want.

In real world scenarios populating a drop down list from an enum is far
more rare than populating from a Map or a List dynamically generated
from a data source (DB or web service as in my case).
So for a newbie to have a BeanEditForm ready to use with this respect
could be quite important. BeanEditForm in fact is documented in the
Getting Started guide since is correctly deemed as a Basic funcionality.

Tapestry can figure out the SelectModel for an enum by itself, but, in other cases, it doesn't what data it should provide. You are the one who does. That's why this isn't built-in in BeanEditor (which is used by BeanEditForm). That's why you need to provide your own edition block: so you tell Tapestry how to edit the field, including any data needed for that. Again, Tapestry is magic, but not psychic.

Another thing is not mentioned in the BeanEditForm guide is the coercion
of Map to SelectModel: I guess  this means that if my data provider give
me Maps I can override the property editor and I'm done.

This should be in Select's documentation, not BeanEditForm's, because BeanEditForm doesn't have any notion of SelectModel. As we say here in Brazil, one thing is one thing, another thing is another thing. :)

One more observation on the guide:  BeanModelSource.create is deprecated
:-) : the guide is outdated.

Just this part is outdated. Good catch.

However even turning to BeanModelSource.createEditModel doesn't work for
me because my bean to be created needs the IP address of the client.  I
will give a try later when I will implement other forms...

What does one thing (BeanModelSource) have with the other (instatiating the bean)? Use onPrepare() to set up the object you need to be edited so BeanEditForm/BeanEditor doesn't need to instatiate your object. This method will be called *before* BeanEditForm/BeanEditor does anything.

public void onPrepare() {
        yourEditedObject = ...;
        // do whatever you need
}

I fear I will have to use a "normal" Form component.

No, you don't. You said you're a newbie. You just need to learn a bit more. ;)

--
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

Reply via email to