It's really hard to determine a 100% accurate answer to this question.
There isn't really enough context.  However, I will say a couple of things.

1.  There is a BindingAndValidation LifecyclePhase where all binding
occurs.  Depending on how your Contact property is being used, refer to
Jeppe's response.

2.  You don't have to worry about it if you go the following route.  Instead
of keeping a separate contactId property, just use the Contact contactId
(assuming its called that).

<s:hidden name="contact.contactId" />

And then just have your getters and setters for Contact.

3.  I generally try not to put any business logic in my getters.  I either
do that in the resolution or in a method marked with @After or @Before.  So
for your situation I would do this:

@After(stages = {LifecycleStage.bindingAndValidation})
public void populateContact() {
    if (contact.contactId != null ) {
        contactDao.read(contact.getContactId());
    }
}

You can further improve that by specificying specific events you want this
to trigger on if need be like so:

@After(on = {"save", "list"}stages = {LifecycleStage.bindingAndValidation})
public void populateContact() {
    if (contact.contactId != null ) {
        contactDao.read(contact.getContactId());
    }
}

where "save" and "list" are event methods in your action bean.

Gregg
On Sat, Aug 30, 2008 at 3:34 AM, Jeppe Cramon <[EMAIL PROTECTED]> wrote:

>  From memory, I believe that Stripes binds in order of parameter name
> length. Shortest first.
>
> /Jeppe
> On 30/08/2008, at 07.06, sboulay wrote:
>
> >
> > What is the binding order when a form is submitted? I came across an
> > example
> > in the Stripes book (which is a very nice read) that had a form with a
> > hidden field that contained the object that was being edited. When
> > the form
> > is submitted for update the action bean form checks to see if the id
> > is
> > null, if it's not it reads it from the database and uses that model
> > object
> > to back the form.
> >
> > ActionBean
> > ---------------------------------
> >
> > private Integer contactId;
> > public Integer getContactId() {
> >       return contactId;
> > }
> > public void setContactId(Integer id) {
> >       contactId = id;
> > }
> >
> > public Contact getContact() {
> >       if (contactId != null) {
> >               return contactDao.read(contactId);
> >       }
> >       return contact;
> > }
> >
> > Is there any guarantee that the hidden form value (contactId) would
> > be set
> > on the ActionBean before getContact is called? Is it the form order
> > that
> > determines this? I have no idea.
> >
> > Thanks
> > -Serge-
> > --
> > View this message in context:
> http://www.nabble.com/Stripes-book-example-question-tp19213699p19213699.html
> > Sent from the stripes-users mailing list archive at Nabble.com.
> >
> >
> > -------------------------------------------------------------------------
> > This SF.Net email is sponsored by the Moblin Your Move Developer's
> > challenge
> > Build the coolest Linux based applications with Moblin SDK & win
> > great prizes
> > Grand prize is a trip for two to an Open Source event anywhere in
> > the world
> > http://moblin-contest.org/redirect.php?banner_id=100&url=/
> > _______________________________________________
> > Stripes-users mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/stripes-users
>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Stripes-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/stripes-users
>
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to