This hopefully is a trivial question but it is driving me crazy (more
so).

 I have a trivial form setup for Home.  Below is my Home.java

-----------------
import org.apache.tapestry.html.BasePage;
import org.apache.tapestry.IRequestCycle;
import org.apache.tapestry.event.PageBeginRenderListener;
import org.apache.tapestry.event.PageEvent;
import org.apache.tapestry.annotations.InjectPage;
import org.apache.tapestry.IPage;
import org.apache.tapestry.form.StringPropertySelectionModel;

public abstract class Home extends BasePage implements
PageBeginRenderListener
{
        public abstract Person getPerson();
        
        public abstract void setPerson(Person person);
        
        public abstract StringPropertySelectionModel getGenders();
        public abstract void setGenders(StringPropertySelectionModel
model);

    public void pageBeginRender(PageEvent event)
    {
         if (! event.getRequestCycle().isRewinding()) 
         {
                setPerson(new Person());                
         } 
         
         StringPropertySelectionModel genders = new
StringPropertySelectionModel(new String[] {"M", "F"});
                
             setGenders(genders);


    }

    @InjectPage("Results")
    public abstract Results getResults();  
    
    public IPage doSubmit(IRequestCycle cycle)
    {
        Results results = getResults();
        
        results.setPerson(getPerson());

        return results;
    }   
}

-------------------------------

 The problem is that I am doing some validation.  The form is updating
the person's firstname, lastname, etc via a person POJO bean. I am using
beginPageRender to init the person object (new Person()).  Okay, no
problems.  And if I submit the form completely filled out, all works as
expected.

 However, since I am using the required validator, let's say I fill out
the person's first name but not their last name.  The page goes back to
Home and does "red" that those fields that are in error in the form. So
yay for that!  But it then resets all the form values (doesn't remember
them). So all my form fields (even the red ones) are all blank again
(like the user began the form all over again).

 I read (searched the tapestry-user archives) that some recommended in
beginPageRender to add the check to see if the page is being rewinded
(in this case, for an error).  However, when I do that after I submit
the page and validation errors send it back to home, I get a null
exception on the property (like person == null).  The code above is what
gives me the null property error when I submit on a validation error.
What happened to the person object?  Shouldn't a rewind still be part of
the pagecycle and thus still remember the submitted (al-be-it)
incomplete values for the form? Help!

 Thanks in advance for any assistance on this. Tapestry does things so
well and since it has such an easy way to do validation, I have to think
it has an easy way to remember values in an incomplete form. Gotta be
something stupid I am doing I say  :)

- Damian
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to