title: PrimeFaces commandButton is not working
body: <p>I know this is a very common issue which happens for a variety of reasons, but although I have searched about it a lot, I didn't manage to find a solution for my case.  </p>
  
  <p>My <a href="http://www.primefaces.org/" rel="nofollow">primefaces</a> commandButton is inside an h:form and is declared as follows:  </p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;p:commandButton action="#{userGroupBean.createOrUpdateItemAction}"
                   value="#{userGroupBean.actionCreateOrUpdateLabel}" 
                   icon="iconDisk"
                   update="@form"
                   oncomplete="window.scrollTo(0,0);" /&gt;
  </code></pre>
  
  <p>My UserGroupBean is ViewScoped.  </p>
  
  <p>This button when clicked is supposed to create a userGroup and show a "Successful creation" message. Instead of doing this it just shows "Please wait" loader for a second and then does nothing. There are no errors in the log and through remote debugging I confirmed that it doesn't enter the action method.  </p>
  
  <p>The weird thing is that when I run the same code in a local Tomcat installation it runs successfully. Also, on the remote server this application is deployed, this used to work just fine. All happened suddenly, and I have a lot of commandButtons like this one, across my application which still work great. Something seems to go wrong just with this particular page .  </p>
  
  <p>I use PrimeFaces 3.1 version, I dont know what other information is usefull to provide.<br>
  Any help/ideas is/are appreciated.   </p>
  
  <p>EDIT<br>
  This is userGroup.xhtml (the page whose buttons do not work) code:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;ui:composition 
  xmlns="http://www.w3.org/1999/xhtml"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:p="http://primefaces.org/ui"
  xmlns:c="http://java.sun.com/jsp/jstl/core"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:fn="http://java.sun.com/jsp/jstl/functions"
  xmlns:comps="http://java.sun.com/jsf/composite/components"
  template="/WEB-INF/templates/userGroup/edit.xhtml"&gt;
  
  &lt;f:metadata&gt;
      &lt;f:event type="preRenderView" listener="#{userGroupBean.initUserGroupUsersList}" /&gt;
  &lt;/f:metadata&gt;
  
  &lt;ui:define name="title"&gt;
      User Group
  &lt;/ui:define&gt;
  
  &lt;ui:define name="centerUnit"&gt;
      &lt;h:form&gt;
          &lt;h:panelGrid columns="3" styleClass="ui-messages-info ui-corner-all" rendered="#{not empty flash.messages_info}"&gt;
              &lt;span class="ui-message-info-icon"&gt;&lt;/span&gt;
              #{flash.messages_info}
          &lt;/h:panelGrid&gt;
  
          &lt;p:messages showDetail="true" globalOnly="true" /&gt;
  
          &lt;p:panel header="Settings"&gt;
              &lt;h:panelGrid columns="3" cellpadding="5"&gt;
                  &lt;h:outputLabel for="title" value="User Group Title:" /&gt;
                  &lt;p:inputText id="title" value="#{userGroupBean.userGroup.title}" /&gt;
                  &lt;p:message for="title" /&gt;
              &lt;/h:panelGrid&gt;
          &lt;/p:panel&gt;
  
          &lt;p:panel header="Members"&gt;
  
              &lt;p:pickList value="#{userGroupBean.usersGroupUsersList}" var="user"
                  iconOnly="true"
                  converter="userConverter"
                  itemLabel="#{user.username}" itemValue="#{user}"&gt;
                  &lt;f:facet name="sourceCaption"&gt;Available&lt;/f:facet&gt;
                  &lt;f:facet name="targetCaption"&gt;Participating&lt;/f:facet&gt;
                  &lt;p:column style="width:25%"&gt;  
                      &lt;p:graphicImage value="#{facesContext.externalContext.request.contextPath}/../file?thumbnail=&amp;amp;downloadPath=#{user.contactDetails.picture.downloadPath}" width="40" height="40" /&gt;  
                  &lt;/p:column&gt;
                  &lt;p:column style="width:25%"&gt;
                      &lt;h:outputText value="#{user.username}" /&gt;
                  &lt;/p:column&gt; 
                  &lt;p:column style="width: 50%"&gt;
                      &lt;h:outputText value="#{user.contactDetails.lastName} #{user.contactDetails.firstName}"/&gt;
                  &lt;/p:column&gt;
              &lt;/p:pickList&gt;
  
          &lt;/p:panel&gt;
  
          &lt;p:commandButton 
              action="#{userGroupBean.createOrUpdateItemAction}"
              value="#{userGroupBean.actionCreateOrUpdateLabel}"
              icon="iconDisk"
              update="@form"
              oncomplete="window.scrollTo(0,0);" /&gt;
  
          &lt;p:separator /&gt;
  
          &lt;p:outputPanel style="text-align:right" layout="block" rendered="#{!userGroupBean.userGroup.isNew() and userGroupBean.hasUserModifyUserGroupAuthority()}"&gt;
              &lt;h:panelGroup&gt;
                  &lt;p:commandButton value="Delete" title="Do you want to delete this user group?"
                      action="#{userGroupBean.deleteItemAction}" 
                      update="@form"
                      icon="iconDelete" /&gt;
  
                  &lt;p:commandButton value="Leave user group" title="I want to leave this user group"
                      action="#{userGroupBean.userInSessionLeavesUserGroupAction}"
                      update="@form" 
                      icon="iconUserGo"/&gt;
              &lt;/h:panelGroup&gt;
          &lt;/p:outputPanel&gt;
  
      &lt;/h:form&gt;
  
  
  &lt;/ui:define&gt;
  </code></pre>
  
  <p></p>
  
  <p>The UserGroupBean.java: </p>
  
  <pre class="lang-java prettyprint-override"><code>@Controller("userGroupBean")
  @Scope(value = "view")
  public class UserGroupBean extends GenericBean&lt;UserGroup&gt; {
  
  private static final long serialVersionUID = 1L;
  final Log logger = LogFactory.getLog(getClass());
  
  @Autowired
  private SessionServiceImpl sessionService;
  @Autowired
  protected UserGroupService userGroupService;
  @Autowired
  protected UserService userService;
  
  @Override
  public String getPageCreateOrUpdate() { return "userGroup.xhtml"; }
  @Override
  public String getPageList() {   return "../../my/userGroups.xhtml"; }
  
  /** Wrapper method which calls getItem() */
  public UserGroup getUserGroup() { return getItem(); }
  /** Wrapper method which calls setItem() */
  public void setUserGroup(UserGroup UserGroup) { setItem(UserGroup); }
  
  
  protected UserGroup findItemById(Integer userGroupId) {
      return userGroupService.findUserGroupById(userGroupId);
  }
  
  
  
  @Override
  protected void resolveCreateRequest(HttpServletRequest req) {
      logger.debug("UserGroupBean::resolveCreateRequest()");
      setItem( userGroupService.initializeUserGroup("") );
  }
  
  @Override
  protected String createItem() {
      try {
          if(!isValidUsersSelection(new ArrayList&lt;User&gt;(usersGroupUsersList.getTarget()))) 
              return null;
  
          List&lt;Integer&gt; userIds = new ArrayList&lt;Integer&gt;();
          for(User user: usersGroupUsersList.getTarget())
              userIds.add(user.getId());
          userGroupService.saveUserGroup(getUserGroup(), userIds);
  
          helperFacesContext.addInfoMessageToFlash("User Group successfully created.");
          return getPageCreateOrUpdate()+"?action=update&amp;id="+getItem().getId()+"&amp;faces-redirect=true";
      }
      catch (Exception e) {
           JsfUtils.error("There was an error", e.getMessage());
           return null;
      } 
  }
   .....
  }
  </code></pre>
  
  <p>And finally the UservConverter.java</p>
  
  <pre class="lang-java prettyprint-override"><code>@FacesConverter(value = "userConverter")
  public class UserConverter extends GenericConverter {
  
  final Log logger = LogFactory.getLog(getClass());
  
  private UserDAO getUserDAO(FacesContext facesContext) {
      // @Autowired gives null
      return (UserDAO) FacesContextUtils.getWebApplicationContext(facesContext).getBean("userDAO");
  }
  
  /**
   * converts the String representation of the key back to the Object
   */
  @Override
  public Object getAsObject(FacesContext context, UIComponent component,
          String value) throws ConverterException {
      logger.info("UserConverter::getAsObject("+value+")");
      Integer userId = Integer.valueOf(value);
      try {
          return getUserDAO(context).findById(userId);
      } catch(Exception e) {
          throw new ConverterException(handleException(context,e.getMessage()));
      }
  }   
  </code></pre>
  
  <p>NEW CLUE: When I restart the server and only after that, when I access this page and manage to create a user group before userGroup.xhtml is fully loaded, the user group is created just fine. If I restart the server and wait till the page is loaded and then create a user group again nothing happens. This problem will drive me crazy at the end.</p>