Dear PrimeFace users ,
Somehow i can't get a form to reset , I do however bind the values of the inputs and clear them but they keep holding the values after the form is updated
my JSF code :
<h:panelGrid>
<h:form>
<p:inputText label="#{lbl.name}" value="#{userBean.candidate.firstname}" id="name"/>
//lots of other inputs , also bound to a specific value of candidate
<p:commandButton name="btnReset" value="#{lbl.reset}" action="#{userBean.clearForm}" update="@form"/>
</h:form>
</h:panelGrid>
my Bean code :
@ManagedBean(name = "userBean")
@SessionScoped
public class UserBean {
private CandidatesEntity candidate;
public void clearForm() {
candidate = new CandidatesEntity();
}
I left a part out to keep it readable but the candidate is a pojo entity which is linked to the bean
any comments that could help are welcome
thanks in advance
sam
Form update/reset fail JSF2.0 PF 3.0.M3
Hello Sam.
I see your error:
your commandbutton action must call a String method! (otherwise you woud use actionlistener="#{yourMethod}" process="@this" ).
In your code method clearForm() will never be called. BTW: Use Log4j to make sure in catalina.out (or some other specified log file) that methods get called - good for debugging
So, anyway, change please:
to
Stay tuned,
Adam
I see your error:
your commandbutton action must call a String method! (otherwise you woud use actionlistener="#{yourMethod}" process="@this" ).
In your code method clearForm() will never be called. BTW: Use Log4j to make sure in catalina.out (or some other specified log file) that methods get called - good for debugging
So, anyway, change please:
Code: Select all
public void clearForm() {
candidate = new CandidatesEntity();
}
Code: Select all
public String clearForm() {
candidate = new CandidatesEntity();
// now return null to prevent navigation
return null;
}
Adam
Busy applying primefaces patches to my local repo at /dev/null
-
- Information
-
Who is online
Users browsing this forum: No registered users and 29 guests