You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Karim Saloojee <ka...@hotpop.com> on 2002/07/02 20:04:22 UTC

How to pre-populate forms without being able to get direct access to their names or scope. Am I missing something?

Hi

I am having a bit of a problem understanding how exactly to pre-populate a
form bean. It seems there is no way to get the name of the formbean of my
next JSP or the session it is likely to be in.

I know that I could do it like this:
    TestActionForm tf = new TestActionForm();
    tf.setEmployeeNo("55525");
    tf.setName("compaq");
    request.setAttribute("testactionform", tf);

This would prepopulate my next JSP with no problems. However any changes to
bean names/scope in my struts-config.xml would require a change in my
classes where the above code would be.

This feels a bit strange, am I doing something wrong or not following the
best practice?

TIA,
Karim



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: How to pre-populate forms without being able to get direct access to their names or scope. Am I missing something? (Alex)

Posted by Karim Saloojee <ka...@hotpop.com>.
Thanks Alex

However how would I go about populating the form in this scenario.
I have:
A Log on jsp, form and action
A display user details jsp, form, action

In the log on action, after validating the user,  I want to populate the
display user details form with the users details from the db.

Currently I do this in the following way, I instantiate the display user
details form in the log on action, set the required fields and put the form
into the request.

However I hardcode the scope and the name of the form in my code based on
the values in my struts-config.xml.

Is this the correct way to go about doing things.

Thanks in advance,
Karim



----- Original Message -----
From: "Alex Paransky" <ap...@standardset.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Wednesday, July 03, 2002 6:06 AM
Subject: RE: How to pre-populate forms without being able to get direct
access to their names or scope. Am I missing something?


> Well, if you configure your action with a proper form, the form would
> already be passed to you in your action method.  Simply cast ActionForm to
> the TestActionForm, and populate it as you did.  You don't have to set it
> into the request since that's done for you automatically.
>
> Good Luck.
>
> -AP_
> http://www.myprofiles.com/member/profile/apara_personal
>
> -----Original Message-----
> From: Karim Saloojee [mailto:karims@hotpop.com]
> Sent: Tuesday, July 02, 2002 11:04 AM
> To: struts-user@jakarta.apache.org
> Subject: How to pre-populate forms without being able to get direct
> access to their names or scope. Am I missing something?
>
>
> Hi
>
> I am having a bit of a problem understanding how exactly to pre-populate a
> form bean. It seems there is no way to get the name of the formbean of my
> next JSP or the session it is likely to be in.
>
> I know that I could do it like this:
>     TestActionForm tf = new TestActionForm();
>     tf.setEmployeeNo("55525");
>     tf.setName("compaq");
>     request.setAttribute("testactionform", tf);
>
> This would prepopulate my next JSP with no problems. However any changes
to
> bean names/scope in my struts-config.xml would require a change in my
> classes where the above code would be.
>
> This feels a bit strange, am I doing something wrong or not following the
> best practice?
>
> TIA,
> Karim
>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: How to pre-populate forms without being able to get direct access to their names or scope. Am I missing something?

Posted by Alex Paransky <ap...@standardset.com>.
Well, if you configure your action with a proper form, the form would
already be passed to you in your action method.  Simply cast ActionForm to
the TestActionForm, and populate it as you did.  You don't have to set it
into the request since that's done for you automatically.

Good Luck.

-AP_
http://www.myprofiles.com/member/profile/apara_personal

-----Original Message-----
From: Karim Saloojee [mailto:karims@hotpop.com]
Sent: Tuesday, July 02, 2002 11:04 AM
To: struts-user@jakarta.apache.org
Subject: How to pre-populate forms without being able to get direct
access to their names or scope. Am I missing something?


Hi

I am having a bit of a problem understanding how exactly to pre-populate a
form bean. It seems there is no way to get the name of the formbean of my
next JSP or the session it is likely to be in.

I know that I could do it like this:
    TestActionForm tf = new TestActionForm();
    tf.setEmployeeNo("55525");
    tf.setName("compaq");
    request.setAttribute("testactionform", tf);

This would prepopulate my next JSP with no problems. However any changes to
bean names/scope in my struts-config.xml would require a change in my
classes where the above code would be.

This feels a bit strange, am I doing something wrong or not following the
best practice?

TIA,
Karim



--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>