1 Reply Latest reply: Aug 25, 2012 10:50 PM by Amasoni RSS

    RE: Setter method not setting a value when passing parameter from JSF

    Amasoni
      I have a datatable with a commandlink which i want to pass an object to the bean. The action attribute
      on the commandlink direct to the same page ie. there's no navigation. As a result (i think/suspect),
      or for some other reason, the setter method in the bean isn't being implemented hence my object in the bean method (removeBOQ)
      is null. How can i sort this out plz. Below are extracts of my datatable and the setter and method in the bean.

      <h:commandLink value="Delete" actionListener="#{bOQMasterManager.removeBOQ}" action="boqmaster">

      <f:setPropertyActionListener target="#{bOQMasterManager.boqmasterPK}"
      value="#{boqs.boqmasterPK}" />
      </h:commandLink>

      public void setBoqmasterPK(BoqmasterPK boqmasterPK) {
      System.out.println("In the setter!!!");
      this.boqmasterPK = boqmasterPK;

      }

      public void removeBOQ(ActionEvent event) {
      try {
      System.out.println("In removeBOQ!!!");

      request.removeBoq(boqmasterPK);
      logger.info("Removed BOQ .");
      } catch (IllegalArgumentException e) {
      System.out.println("In the exception!!!"+e.getMessage());

      }
      }
        • 1. Re: RE: Setter method not setting a value when passing parameter from JSF
          Amasoni
          I sorted it out using <f:param> instead.

          <h:commandLink value="Delete" actionListener="#{bOQMasterManager.removeBOQ}" action="boqmaster">
          <f:param name="boqmasterPk" value="#{boqs.boqmasterPK}" id="boqmasterPK" />
          </h:commandLink>

          public void removeBOQ(ActionEvent event) {
          try {

          UIParameter param = (UIParameter) event.getComponent()
          .findComponent( "boqmasterPK");
          BoqmasterPK pk = (BoqmasterPK)param.getValue();

          request.removeBoq(pk);
          logger.info("Removed BOQ .");
          } catch (IllegalArgumentException e) {
          System.out.println("In the exception!!!"+e.getMessage());

          }
          }