Form update/reset fail JSF2.0 PF 3.0.M3

UI Components for JSF
Post Reply
SamAntonis
Posts: 8
Joined: 08 Sep 2011, 16:37

27 Sep 2011, 12:36

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

ltune
Posts: 125
Joined: 20 Jul 2011, 20:25
Contact:

28 Sep 2011, 07:08

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 :twisted:

So, anyway, change please:

Code: Select all

public void clearForm() {
candidate = new CandidatesEntity();
}
to

Code: Select all

public String clearForm() {
candidate = new CandidatesEntity();
// now return null to prevent navigation
return null;
}
Stay tuned,

Adam
Busy applying primefaces patches to my local repo at /dev/null

Lyrionus
Posts: 60
Joined: 31 Aug 2011, 09:09

05 Oct 2011, 15:24

I figured it was:
#{userBean.clearForm()}

Because i thought primefaces would call the getters and setters then thinking it was a binding... but i don't really know cause i've used Spring webflow with jsf
JSF 2.0
Primefaces 3.2
Tomcat 7.0

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 29 guests