Values lost after validation error in JSF?

You indeed need to transfer the very same boolean properties to the next request. You can in theory use h:inputboolean1} for this, but unfortunately those will only be set during update model values phase, while you actually need it to be available during apply request values phase. Besides, they will also go lost when a validation error occurs.

You indeed need to transfer the very same boolean properties to the next request. You can in theory use for this, but unfortunately those will only be set during update model values phase, while you actually need it to be available during apply request values phase. Besides, they will also go lost when a validation error occurs.

There are three ways to fix this non-intuitive behaviour of h:inputdden (I've ever filed a bug against it at the Mojarra issue list, but they didn't seem to do anything with it). First is to use the binding on the h:inputdden instead: This however requires changes in the way you get/set the boolean values in the backing bean code. For example: private HtmlInputdden hidden1 = new HtmlInput // +getter +setter.

Public void setBoolean1(boolean boolean1) { hidden1. SetValue(boolean1); } public boolean getBoolean1() { return (Boolean) hidden1.getValue(); } Second is to use Tomahawk's t:saveState instead. The major advantage is that you don't need to change anything in the backing bean code.It will restore the value early before the apply request values phase.

You only need to add extra libraries if not done yet, but as Tomahawk provides much more advantages than only the t:saveState, such as the in basic JSF implementation missing components/features t:inputFileUpload, t:dataList, t:dataTable preserveDataModel="true", t:selectOneRadio layout="spread" and so on, it is worth the effort. The third way is to store them in a session scoped bean, but you actually don't want to do that for request scoped variables.It would only give "wtf? " experiences when the enduser has multiple tabs/windows open in the same session.

Edit: as per the comments, here's an SSCCE of the second way: JSF page: MyBean class: package mypackage; import javax.faces.component.html. HtmlInput public class MyBean { private HtmlInputdden hidden = new HtmlInput public void submit() { if (hidden.getValue() == null) { hidden. SetValue(true); // Set to true on 1st submit.

} else { hidden. SetValue(!((Boolean) hidden.getValue())); // Toggle true/false. } } public HtmlInputdden get } public void setdden(HtmlInputhidden = hidden; } } The relevant part of faces-config.

Xml: myBean mypackage. MyBean request Playground environment is JSF 1. 2_13 on Tomcat 6.0.20.

Great answer. (+1) BalusC, do you use RichFaces besides Tomahawk? Is it a good idead to use RichFaces?

– Arthur Ronald F D Garcia Dec 18 '09 at 3:44 thanks balusC for your precious time... I will try and let you know, but for the second option I am using RSA 7.5. X so if I use tomahawk then it will be only for t:savestate and more over that I don't think it will support also. I had tried earlier but no success. Thanks, – user234194 Dec 18 '09 at 4:28 "This however requires changes in the way you get/set the boolean values in the backing bean code.

" What do you mean by this, are'nt they normal getters and setters, if not could you explain more... please. Thanks. – user234194 Dec 18 '09 at 4:31 @Arthur: I don't use RichFaces.

But if you already use it, you can also use its a4j:keepAlive instead of t:saveState. @Topicstarter: you need to bind the whole component instead of its value.To set the value use UIInput#setValue() and to get it use UIInput#getValue(). – BalusC Dec 18 '09 at 11:19 On the Second page, I am using hidden field as: and the getters and setters are as: public UIInput getTestBoo() { return testBoo; } public void setTestBoo(UIInput testBoo) { this.

TestBoo = testBoo; } On the First I am setting the value as: UIInput test = new UIInput(); test. SetRendered(true); backBean. SetTestBoo(test); But I didn't get no success.

I don't no where I went wrong. – user234194 Dec 18 '09 at 21:50.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions