-
1. Re: Form value submitted to server but not processed
jpviragine.jpviragine.gmail.com Apr 25, 2008 12:00 PM (in response to trumml)Martin,
When inputText id1 is marked as disabled, the JSF don’t update the value for simpleBean.value1
Note that this is desired behavior, JSF assume that the value never change once this is disabled.
To reach what you want, I suggest something like this:
<h:form id="form"> Value1:<h:inputText id="it1" value="#{simpleBean.value1}" disabled="#{simpleBean.disabled}" /><br /> Value2:<h:inputText id="it2" value="#{simpleBean.value2}" disabled="false" /><br /> <a4j:commandLink action=#{some action method in simpleBean to change the value of disabled attribute} reRender="it1" immediate="true">enable control</ a4j:commandLink> <h:commandButton value="submit" /> </h:form>
Note the use of ajax to notify JSF about the changes.
-
2. Re: Form value submitted to server but not processed
danielc.roth Apr 25, 2008 12:12 PM (in response to trumml)I agree it seems a bit weird...
You could solve it with something like this
<h:form> <h:inputText value="#{bean.str1}" /> <h:panelGroup id="a4j"> <h:inputText value="#{bean.str2}" disabled="#{bean.disabled}" /> </h:panelGroup> <a:commandLink value="Enable" action="#{bean.enable}" reRender="a4j" /> </h:form>
where enable() just sets disabled to false.
-
3. Re: Form value submitted to server but not processed
trumml Apr 25, 2008 1:03 PM (in response to trumml)Well, I was aware of the solution using ajax to re render the control but i had hoped there would be a solution to my problem without a round trip.
But the fact that this is desired JSF behaviour already showed me that I have to do implement some kind of workaround (e.g. use readonly in combination with setting the background of the input text control so that it looks like beeing disabled).
-
4. Re: Form value submitted to server but not processed
jpviragine.jpviragine.gmail.com Apr 25, 2008 1:16 PM (in response to trumml)Martin,
The readonly has the same effect as disabled.
JSF is “smart” to avoid that disabled/readonly field get “hacked”.
I think that there is no way to do what you wont without a round trip.
You can “mimic” desired behavior using some javascripts but be aware that is not safe (user can transform disabled/readonly fields in enabled/write fields and the sever will accept this values)