You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Peter Verhoye <pe...@synergetic-solutions.be> on 2004/01/14 23:47:52 UTC

Autofill form page

Hi all,

I'm just starting with struts and stumbled upon a problem.

I have a page called page1. This page shows a list of records in a table
(the list is stored as a collection received from the Action).
Now, per record in the table, there is a link on which you can click and
should display then a new page were you have the details of that record.
Now, I can show a blank new form page but the problem is I want to show the
form with the data from the record already filled in (so checkboxes checked,
combo-boxes selected on the correct entry etc...)

Can someone point me in the correct direction? I have been unable to find a
good solutions for this.

Thank you very much for the help!!

BB
Peter


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: Autofill form page

Posted by Matthias Wessendorf <ma...@matthias-wessendorf.de>.
hi peter
on our "show details action"

store the object in the request
and forward to "details-form"
and then do

<html:text property="beanProperty" name="nameOfObjectInRequest"/>
....

greetings


-----Original Message-----
From: Peter Verhoye [mailto:peter.verhoye@synergetic-solutions.be] 
Sent: Wednesday, January 14, 2004 11:48 PM
To: struts-user@jakarta.apache.org
Subject: Autofill form page


Hi all,

I'm just starting with struts and stumbled upon a problem.

I have a page called page1. This page shows a list of records in a table
(the list is stored as a collection received from the Action). Now, per
record in the table, there is a link on which you can click and should
display then a new page were you have the details of that record. Now, I
can show a blank new form page but the problem is I want to show the
form with the data from the record already filled in (so checkboxes
checked, combo-boxes selected on the correct entry etc...)

Can someone point me in the correct direction? I have been unable to
find a good solutions for this.

Thank you very much for the help!!

BB
Peter


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Autofill form page

Posted by Hubert Rabago <ja...@yahoo.com>.
You can also check out examples on using ActionForm objects.  That is what
they're for.  

--- Peter Verhoye <pe...@synergetic-solutions.be> wrote:
> Hi all,
> 
> I'm just starting with struts and stumbled upon a problem.
> 
> I have a page called page1. This page shows a list of records in a table
> (the list is stored as a collection received from the Action).
> Now, per record in the table, there is a link on which you can click and
> should display then a new page were you have the details of that record.
> Now, I can show a blank new form page but the problem is I want to show the
> form with the data from the record already filled in (so checkboxes checked,
> combo-boxes selected on the correct entry etc...)
> 
> Can someone point me in the correct direction? I have been unable to find a
> good solutions for this.
> 
> Thank you very much for the help!!
> 
> BB
> Peter
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: Autofill form page

Posted by Matthias Wessendorf <ma...@matthias-wessendorf.de>.
hi...

perhaps you need a link like this:
to "get" the desired "record":


<struts-html:link action="showDetailsForMyRecordAction"
paramId="recordId" paramName="currentInIterate"
paramProperty="propertyOfBeanPerhapsId">details</html:link>


(you are using the logic:iterate ?)
regards,






-----Original Message-----
From: Peter Verhoye [mailto:peter.verhoye@synergetic-solutions.be] 
Sent: Wednesday, January 14, 2004 11:48 PM
To: struts-user@jakarta.apache.org
Subject: Autofill form page


Hi all,

I'm just starting with struts and stumbled upon a problem.

I have a page called page1. This page shows a list of records in a table
(the list is stored as a collection received from the Action). Now, per
record in the table, there is a link on which you can click and should
display then a new page were you have the details of that record. Now, I
can show a blank new form page but the problem is I want to show the
form with the data from the record already filled in (so checkboxes
checked, combo-boxes selected on the correct entry etc...)

Can someone point me in the correct direction? I have been unable to
find a good solutions for this.

Thank you very much for the help!!

BB
Peter


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: Autofill form page

Posted by Richard Hightower <rh...@arc-mind.com>.
To populate an ActionForm with a domain object so that it can be displayed
on an input JSP with html:form, you first have to create an action that is
called before the form:

        <action path="/readUser"
                type="rickhightower.ReadUserAction"
                name="UserForm" scope="request" validate="false">
            <forward name="success" path="/userForm.jsp"/>
        </action>

Notice that we mapped in the form that the userForm will display, also
notice that validation is off. This form will be created and passed to the
execute method of ReadUserAction before the userForm.jsp service method is
called. This gives the code an opportunity to populate the form and put it
into scope so that the userForm.jsp's html:form tag can display it.
Here is an example of the ReadUserAction's execute method:

    public ActionForward execute(
        ActionMapping mapping,
        ActionForm form,
        HttpServletRequest request,
        HttpServletResponse response)
                               throws Exception {

            //Get the user id of
        String id = request.getParameter("id");

            //Obtain the default DAOFactory
        DAOFactory factory = DAOFactory.getDefaultfactory();

            //Obtain the DAO for users
        UserDAO userDAO = factory.getUserDAO();

            //Retrieve the user from the database
        UserDTO user = userDAO.getUser(id);

            //Cast the form to a UserForm
        UserForm userForm = (UserForm)form;

            //Copy over the properties from the DTO to the form.
        BeanUtils.copyProperties(userForm,user);

      }
...


Notice that the action does not create a new UserForm. It did not need to
because the action mapping caused a form to be created. The code looks up
the user based on an ID that was passed as a request parameter. Then it uses
BeanUtils.copyProperties (org.apache.commons.beanutils.BeanUtils) to copy
the domain objects properties to the userForm. The userForm properties
should all be of type String (Strings are best for validation). The domain
objects properties can be any primitive type or wrapper objects (BeanUtils
will perform the type conversion automatically).



Rick Hightower
Developer

Struts/J2EE training -- http://www.arc-mind.com/strutsCourse.htm
Struts/J2EE consulting --
http://www.arc-mind.com/consulting.htm#StrutsMentoring


-----Original Message-----
From: Peter Verhoye [mailto:peter.verhoye@synergetic-solutions.be]
Sent: Wednesday, January 14, 2004 3:48 PM
To: struts-user@jakarta.apache.org
Subject: Autofill form page


Hi all,

I'm just starting with struts and stumbled upon a problem.

I have a page called page1. This page shows a list of records in a table
(the list is stored as a collection received from the Action).
Now, per record in the table, there is a link on which you can click and
should display then a new page were you have the details of that record.
Now, I can show a blank new form page but the problem is I want to show the
form with the data from the record already filled in (so checkboxes checked,
combo-boxes selected on the correct entry etc...)

Can someone point me in the correct direction? I have been unable to find a
good solutions for this.

Thank you very much for the help!!

BB
Peter


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org