Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Apr 18th, 2012  |  syntax: None  |  size: 1.31 KB  |  views: 1,607  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. JSF (and PrimeFaces) How to pass parameter to a method in ManagedBean
  2. <h:outputText value="First name:"/>
  3. <p:inplace id="firstname" editor="true">
  4.      <p:ajax event="save" onsuccess="#{employeeController.saveName()}"/>
  5.      <p:inputText id="firstName" value="#{emp.firstName}"  
  6.                   required="true" label="text"
  7.                   valueChangeListener="#{employeeController.firstNameChanged}">
  8.      <p:ajax event="valueChange" listener="#{employeeController.onValueChangedStart}"/>
  9.      </p:inputText>
  10. </p:inplace>
  11.        
  12. FacesContext context = FacesContext.getCurrentInstance();
  13. Employee employee = context.getApplication().evaluateExpressionGet(context, "#{emp}", Employee.class);
  14. Long id = employee.getId();
  15. // ...
  16.        
  17. Employee employee = model.getRowData();
  18. Long id = employee.getId();
  19. // ...
  20.        
  21. public void onValueChanged(AjaxBehaviorEvent event)
  22. {
  23.     Employee employee = (Employee)((UIOutput)event.getSource()).getValue();
  24.     //...
  25. }
  26.  
  27. <h:selectOneMenu required="true"
  28.     value="#{empl}" converter="#{bean.employeeConverter}">
  29.     <f:selectItems value="#{bean.employees}" var="varEmployee"
  30.         itemLabel="#{varEmployee}" itemValue="#{varEmployee}"/>
  31.     <p:ajax event="change" listener="#{bean.onValueChanged}"/>
  32. </h:selectOneMenu>
  33.        
  34. <p:ajax event="save" onsuccess="#{employeeController.saveName(emp.id)}"/>
clone this paste RAW Paste Data