2 Replies Latest reply on May 30, 2012 5:01 AM by gauthier Peel

    s:viewAction not fired with JBoss 7.1.1 and and f:viewParam no longer set

    gauthier Peel Newbie

      I just don't understand why including Seam-faces 3.0.2 and its dependencies the   f:viewParam  is no longer set ?

       

      I directly type the GET url in the browser :

      http://localhost:8080/proto-pilot/pilot.faces?id=13

       

      the page is

       

       

       

       

      <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
       xmlns:s="http://jboss.org/seam/faces">
       
      <f:metadata>
       <f:event listener="#{pilotAction.prepare}" type="preRenderView" />
       <f:viewParam name="id" value="#{pilotAction.id}" />
       <s:viewAction action="#{pilotAction.prepareBis}" />
      </f:metadata>
      <h:head>
       <meta http-equiv="Cache-Control" content="no-store" />
       <meta http-equiv="Pragma" content="no-cache" />
       <meta http-equiv="Expires" content="0" />
       <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
       <title><ui:insert name="title">Default title</ui:insert></title>
      </h:head>
      <h:body>
       <h:messages globalOnly="false" />
       <h:form>
        <h:panelGrid columns="2">
         <h:outputLabel value="#{appMsg['pilot.firstname']}" />
         <h:inputText label="#{appMsg['pilot.firstname']}" value="#{pilotHolder.pilot.firstname}" />
         <h:outputLabel value="#{appMsg['pilot.lastname']}" />
         <h:inputText label="#{appMsg['pilot.lastname']}" value="#{pilotHolder.pilot.lastname}" />
         <h:outputLabel value="#{appMsg['pilot.age']}" />
         <h:inputText label="#{appMsg['pilot.age']}" value="#{pilotHolder.pilot.age}" required="true"
          validator="#{pilotAction.validateAge}" />
         <h:outputLabel value="#{appMsg['pilot.level']}" />
         <h:selectOneMenu value="#{pilotHolder.pilot.level}">
          <f:selectItem noSelectionOption="true" itemLabel="" />
          <f:selectItems value="#{levels.list}" var="w" itemValue="#{w}" itemLabel="#{w.name}" itemKey="#{w.id}" />
          <f:converter converterId="objectConverter" />
         </h:selectOneMenu>
         <h:outputLabel value="#{appMsg['pilot.team']}" />
         <h:selectOneMenu value="#{pilotHolder.pilot.team}">
          <f:selectItem noSelectionOption="true" itemLabel="" />
          <f:selectItems value="#{teams.list}" var="w" itemValue="#{w}" itemLabel="#{w.name}" itemKey="#{w.id}" />
          <f:converter converterId="objectConverter" />
         </h:selectOneMenu>
        </h:panelGrid>
        <h:commandButton action="#{pilotAction.doMerge}"
         value="#{pilotHolder.pilot.id ne null ? appMsg['pilot.update'] : appMsg['pilot.create']}" />
       </h:form>
      </h:body>
      </html>
      
      

       

      my java cdi bean :

       

      @javax.inject.Named
      @javax.enterprise.context.RequestScoped
      public class PilotAction implements Serializable {
       @Inject
       private PilotHolder pilotHolder;
       @EJB
       private PilotService pilotService;
       /**
        * set with the HttpParam
        * 
        * <pre>
        *  <f:viewParam name="id" value="#{pilotAction.id}" />
        * </pre>
        */
       private Long id;
       public void prepareBis() {
        System.out.println("hello");
       }
       /**
        * <pre>
        *   <f:metadata>
        *    <f:event listener="#{pilotAction.prepare}" type="preRenderView" />
        *    <f:viewParam name="id" value="#{pilotAction.id}" />
        *   </f:metadata>
        * </pre>
        */
       public void prepare() {
        FacesContext context = FacesContext.getCurrentInstance();
        HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();
        String method = request.getMethod();
        Object o = request.getParameter("id");
        System.out.println(o);
        if ("GET".equals(method)) {
         // this means first CALL to the page
         if (id != null) {
          // this means UPDATE
          Pilot pilot = pilotService.selectPilotById(id);
          // It would be nice to have OUTJECTION here.
          // forces Pilot object on Holder, when a new process (update) starts
          // the Holder play the role a data bag in session, it is very close to a
          // conversation
          // scope ...
          pilotHolder.setPilot(pilot);
         } else {
          // this means CREATE
          pilotHolder.setPilot(new Pilot());
         }
        }
       }
      
       public void setId(Long id) {
        this.id = id;
       }
       public Long getId() {
        return id;
       }
      

       

      With the debugger :

      the <f:event listener="#{pilotAction.prepare}" type="preRenderView" /> is called OK

      the setter on id   setId()  is never called :  <f:viewParam name="id" value="#{pilotAction.id}" />

      the action prepareBis() is never called :  <s:viewAction action="#{pilotAction.prepareBis}" />

      I checked on the HttpRequest instance, and yes the "id" http paramter is there with the right value => 13

       

      If I remove all the jars from seam and its dependency, the setter setId() is called again,

      any explaination ?