[prev in list] [next in list] [prev in thread] [next in thread] 

List:       struts-user
Subject:    Re: Why does <html:text property="..."/> has no value?
From:       Laurie Harper <laurie () holoweb ! net>
Date:       2005-11-30 22:57:54
Message-ID: dmlapm$dgi$1 () sea ! gmane ! org
[Download RAW message or body]

Sebastian Stein wrote:
> Dave Newton <newton@pingsite.com> [051130 17:43]:
>>> If I write in my jsp page <bean:write name="sourceDate"/> the correct 
>>> string
>>> is shown in the HTML output. So I'm sure that the value for sourceDate is
>>> correctly handed over to the jsp page.
>>>
>>> Is there a way to easily fix this?
>> The property in an html:text tag is expecting a sourceDate property in 
>> whatever type of ActionForm you're using, not a scoped attribute.
> 
> So this means instead of:
> 
> request.setAttribute("sourceDate", srcDate);
> 
> I should use:
> 
> MyForm myForm = (MyForm) form; // ActionForm form in the constructor
> myForm.setSourceDate(srcDate);

Yes, exactly.

> But I guess that I have to tell the jsp page about the form in the
> struts-config.xml. At the moment the relevant parts in the struts-config
> look as follows:
> 
> 
> 		<form-bean name="docForm" type="org.contineo.forms.DocForm"/>
> ...
> 		<action path="/EditDoc"
> 		        type="org.contineo.actions.documan.document.EditDocAction">
> 			<forward name="editdoc"
> 			         path="/pages/editDoc.jsp"
> 			         redirect="false"/>
> ...
> 		<action input="/EditDoc.do"
> 		        name="docForm"
> 		        path="/ChangeDoc"
> 		        type="org.contineo.actions.documan.document.ChangeDocAction"
> 		        validate="false"/>
> 
> The second step already works, I can access the form content in
> ChangeDocAction.

Assuming editDoc.jsp contains an html:form tag which submits to 
/EditDoc, you don't need any additional configuration to use the form in 
editDoc.jsp. The html:form tag will automatically create a scripting 
variable 'docForm'.

However, to pre-populate the form bean in EditDocAction, you do need the 
extra configuration: you need to tell Struts to provide the form bean to 
the action. To do that, just add 'name="docForm"' in the /EditDoc 
mapping, just as you did for the /ChangeDoc mapping.

You can then use the code you wrote above to initialise the form.

L.


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

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic