Craig, All,

I would like to discuss the issue I have entered in Bugzilla (issue #30511) with title “Struts-faces form input with rendered attribute set” that you put invalid a while ago.

I am first going to rewrite the issue and I will try to explain where I do not find things logical.

First of all, I use the struts-faces library, so I have Struts forms and JSF pages (I also use tiles).

So I have 1 Struts forms, called serverForm with 2 attributes:
   <form-bean      name="serverForm"
                   type="org.apache.struts.validator.DynaValidatorForm" >
     <form-property name="dns"          type="java.lang.String" />
     <form-property name="mtc"          type="java.lang.String" />
   </form-bean>

I also have 2 actions: one called before displaying the JSF page, and another one called at submission time.
These 2 actions are associated with the same form serverForm marked as request scope for both.
The first action populates the form attributes so as to prefill the inputs, it also sets the mtc attribute to ‘edit’.
The second action is used to save the data into an XML data file.


The JSF page looks like this:
<s:form action="/saveServer" onsubmit="return validateServerForm(this);">
<h:inputHidden id="mtc" value="#{serverForm.mtc}" />
...
<h:inputText id="dns" value="#{serverForm.dns}" rendered="#{serverForm.mtc == 'edit'}"/>
...
</s:form>


At rendering time the page is correctly displayed and the dns input displays if mtc is equals to ‘edit’, if the dns field has a value its value displays in the field.

Then if I submit the form, in my Struts action class, I can get the mtc value using:

DynaValidatorForm serverForm = (DynaValidatorForm) form ;
String mtc = (String)serverForm.get( "mtc" ) ;

The mtc attribute is equals to ‘edit’.

But when I try to do:

String dns = (String)serverForm.get( "dns" ) ;

I cannot obtain the dns value that was submitted even if mtc is equals to ‘edit’.

To sum up the value of the attribute serverForm.mtc is available at rendering time and at submitting time but seems not present while evaluating the rendered JSF attribute during the form submit phase.

Then if I put the scope of both actions used as Session scope, it works correctly, I can get the dns submitted value.

Without knowing in details the way a request is handled behind the scene especially between JSF and Struts, I think there is something wrong here but I am not 100% sure. In fact I am pretty sure that I should not be obliged to set these actions in session scope.

If you need more information, please let me know.

Thanks a lot for your help

Xavier

_________________________________________________________________
MSN Messenger : discutez en direct avec vos amis ! http://www.msn.fr/msger/default.asp



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



Reply via email to