You could call an action before going to the form that takes the value from
the session and sets someForm.someProperty to that value and then forwards
to your jsp.  

-Rob

-----Original Message-----
From: Adam Bickford [mailto:[EMAIL PROTECTED] 
Sent: Thursday, January 29, 2004 9:55 AM
To: [EMAIL PROTECTED]
Subject: Struts text field 'value' attribute set from another ActionForm?

I have a web form such as:

<strutshtml:form action="/someAction" enctype="multipart/form-data">
    <strutshtml:text name="someForm" property="someProperty" size="10"
value="???"/>
</strutshtml:form>

How can I set a default value for the text field, where the value I want 
is in a different session scoped ActionForm than the one named in the 
<strutshtml:text> tag? The only way I've been able to do it is saving a 
value as a session attribute and retrieving it with a scriptlet, like this:

    <strutshtml:text name="someForm" property="someProperty" size="10" 
value="<%= (String)session.getAttribute("sessionAttributeValue") %>"/>

This approach works, but should I need to use a scriptlet and 
sessionAttributes to do this? I've heard that it's best to avoid putting 
scriptlet/java code in my jsp pages. What I'd like to do is reference 
the value in the existing session scoped ActionForm, such as:

    <strutshtml:text name="someForm" property="someProperty" size="10" 
value=otherSessionScopedForm.someProperty/>

Can something like this be done?



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


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

Reply via email to