Wednesday 25 May 2011

PrimeFaces/wizard component: resets value

Problem description: assume my wizard has 2 tabs and tab 1 contains inputText (actualy my problem was with h:selectOneRadio). Then I press next, I go to next table, and submit my form (both tabs).

But my property that is bound on inputText is null!

Solution proposed:
Debugging through jsf stack I saw that after form submission the setter of out property is called with null argument. Why????

Two solutions - none is perfect
a) edit setter so that if its argument is null to return (this far worse solution)

b) add immediate="true" to commandButton - this skips validation and second call to setter of our property (but what if the form needs validation?)

What has worked for me:
a) add immediate="true" to commandButton
b) Because of immediate="true" setters are not invoked for the properties of the last tab and therefore they remain null. Solution: the last tab should be a confirmation tab where all the properties are shown (this way the last properties will be set on the second from the last tab).
c) edit all setters of enums properties so that they modify their property onloy if the new one is not null,

eg:

private FooType foo = null;
@Enumerated(EnumType.STRING)
public FooType getFoo() { return foo; }
public void setFoo(FooType foo) { if(foo!=null) this.foo = satisfiedByInfo; }



Has anybody solved this issue?
My current PrimeFaces version is 3 Milestone 1

References
http://primefaces.prime.com.tr/forum/viewtopic.php?f=3&t=5081

No comments:

Post a Comment