1

JSF code:

<rich:popupPanel modal="true" id="editPanelUser">
  <h:form>
    <h:panelGrid columns="2">
      <h:outputLabel value="first name (*)" />
      <h:inputText value="#{usersBean.currentItem.firstName}" />
    </h:panelGrid>
    <h:panelGrid>
      <a4j:commandButton value="save"
        oncomplete="if(#{facesContext.maximumSeverity==null}) #{rich:component('editPanelUser')}.hide()"
        action="#{usersBean.runAction('saveUser')}"/>
    </h:panelGrid>
  </h:form>
</rich:popupPanel>

Backing bean code:

public void setRunAction(String action){
    if("saveUser".equals(action)){
        ...
    }
}

I put a breakpoint in the setRunAction method, but it never makes it here. Ideas?

What's weird is that the a4j:commandLink code that opens this popup works fine and calls the runAction method:

<h:form>
  <rich:dataTable value="#{usersBean.dataList}" var="singleUser"
    rowClasses="row1,row2" rowKeyVar="row" id="singleUserTable"
    ajaxKeys="#{usersBean.keys}">
    <rich:column>
      <a4j:commandLink id="editlink"
        oncomplete="#{rich:component('editPanelUser')}.show();return false;">
        <f:setPropertyActionListener value="editUser"
          target="#{usersBean.runAction}" />
      </a4j:commandLink>
    </rich:column>
  </rich:dataTable>
</h:form>
Nick Humphrey
  • 611
  • 6
  • 15
  • is there a – Daniel Mar 28 '12 at 12:15
  • just for checking , try to remove the oncomplete... also isn't should be eq null instead of your condition... also check firebug – Daniel Mar 28 '12 at 12:35
  • removed oncomplete, but still didn't reach the breakpoint in the method in the eclipse debugger. – Nick Humphrey Mar 28 '12 at 12:41
  • just noticed... change the name of your action method in your bean from setRunAction into runAction – Daniel Mar 28 '12 at 12:43
  • @Daniel, the naming should be correct because ctrl+space suggests "runAction" in the jsf page, plus the – Nick Humphrey Mar 28 '12 at 12:52
  • try renaming like i suggested with the original code... ignore the autocomplete... also , it works for you in the setPropertyActionListener cause it expects the set prefix cause its a set method... while in the action method a method should not be named with set prefix... try my previous comment suggestion and let me know... – Daniel Mar 28 '12 at 12:59
  • @Daniel, renaming didn't have any effect. – Nick Humphrey Mar 28 '12 at 13:06
  • ok, that's weird , public void runAction(String action){...} should have work for action="#{usersBean.runAction('saveUser')}" – Daniel Mar 28 '12 at 13:15
  • is there a webpage i can reference that documents passing parameters from actions in jsf? i can't find anything like that anywhere. – Nick Humphrey Mar 29 '12 at 06:46
  • take a look at this : http://stackoverflow.com/a/3909382/617373 and this http://stackoverflow.com/q/5970721/617373 and this http://www.mkyong.com/jsf2/jsf-2-link-commandlink-and-outputlink-example/ and this http://www.mkyong.com/jsf2/4-ways-to-pass-parameter-from-jsf-page-to-backing-bean/ – Daniel Mar 29 '12 at 07:20
  • also , if I already answer you again... try a this call your action method public void wow(String action) and refer to it like action="#{usersBean.wow('saveUser')}" ... it should work.... – Daniel Mar 29 '12 at 07:24

2 Answers2

0

Please try following XHTML code (also make sure that you do not have form inside another form element):

<rich:popupPanel modal="true" id="editPanelUser">
  <h:form id="myForm">
    <h:panelGrid columns="2">
      <h:outputLabel value="first name (*)" />
      <h:inputText value="#{usersBean.currentItem.firstName}" />
    </h:panelGrid>
    <h:panelGrid>
      <a4j:commandButton id="myBtn" value="save"
        oncomplete="if(#{facesContext.maximumSeverity==null}) #{rich:component('editPanelUser')}.hide()"
        actionListener="#{usersBean.runAction('saveUser')}"/>
    </h:panelGrid>
  </h:form>
</rich:popupPanel>

And method in Managed bean:

public void runAction(String action){
    if("saveUser".equals(action)){
        ...
    }
}
Mr.B
  • 91
  • 2
0

change your action attribute as below

action="#{usersBean.setRunAction('saveUser')}"

or change your method as

public void runAction(String action){}
prageeth
  • 7,159
  • 7
  • 44
  • 72