0
votes

I want my managed bean to be cleared after a successful action. I use PrimeFaces5.0 for web page. Here is a block. I used partialSubmit and process to submit only one part of the form.

<p:panel id="panel1">
  ...
    <p:commandButton id="saveButton" value="Save"
        action="#{myBean.save}" 
        update="msg" partialSubmit="true" process="panel1" />
</p:panel>

I used @viewScoped for managed bean and my save method is

public String save() {
    //do some save stuff
    try{
        myEjb.save();
        return "";
    } catch (EJBException ejbe) {
        mesajYazKaydetmeHatali(ejbe);
        ejbe.printStackTrace();
    }
    return null;
 }

Although I return "" after a successful save, I think PF does not refresh the page. How can I achieve this.

Thanks

2
Thanks it worked for me. - hasan
i'm glad. i'll write it as a separate answer. - tt_emrah

2 Answers

0
votes

I dont know did i undestand clearly your quesiton, i think that you want to refresh page after saving a new record. You can use request context

With spesifying your tag id you can update needed thing, if you want to refresh your panel you can use the code below.

context = RequestContext.getCurrentInstance();
context.update("YOURFORMID:panel1");
0
votes

instead of returning an empty string, you can redirect the user to the same page in case of successful save:

FacesContext.getCurrentInstance().getExternalContext().redirect(redirectionPath‌​);