0

i tried to show action result in panel with this :

<p:panel id="pnl" style="margin-bottom:10px;"> <p:commandButton id="addUser" value="Ajouter" action="#{userMB.addUser}" ajax="false" target=":pnl">

but i cant get result in same page, after click i've result in new page.

as you can see i used target for this, there is a way to do it ?

Thanks in advance

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Please check http://stackoverflow.com/questions/3909267/differences-between-action-and-actionlistener. Also, there is no target attribute available for p:commandButton. – rags May 24 '12 at 12:17
  • Note, fyi, since you appear to be new to StackOverflow: if you find an answer acceptable, you should click the check mark next to the answer. If you have any issues with an answer, please add a comment to it and work through it with the person providing the answer. – BestPractices May 25 '12 at 14:29

1 Answers1

1
  1. Change "target" to the word "update" and remove ajax="false"
  2. Ensure that your action method addUser either doesn't return anything (the method signature's return declaration is "void") or returns null
  3. You may need to make your backing bean view scoped (if you do change to ViewScoped, ensure that your backing bean is Serializable)
BestPractices
  • 12,738
  • 29
  • 96
  • 140
  • HI,Thank you for your interesting response, can i know what's the difference between RequestScoped and ViewScoped ? – user1414929 May 29 '12 at 10:09
  • RequestScoped has a lifetime as long as an HTTP Request, ViewScoped has a lifetime as long as you post back to the same page (e.g. your Action string is null or empty). In my experience, as you use more "ajaxified" components which submit partial page requests back to the backing bean and the response updates part of the current page, you may find your life made easier if your backing bean is ViewScoped. – BestPractices May 29 '12 at 10:59
  • Since you appear to be new to Stack Overflow, fyi, if this answer helped you and is the "Correct" answer for your question, please mark it with the green check beside the answer. – BestPractices May 29 '12 at 17:29