5 Replies Latest reply: Dec 19, 2007 1:37 PM by 807601 RSS

    Value pass problem from JSF page to SessionBean

    807601
      Hi,
      I use NetBean IDE-Visual Web Application to create this java application.
      Basically, there is a list of links, which should link to a page with different content, depend on which link ID is passed over. However, the link ID is passed correctly only at the first time. And it never get changed again until the project redeployed?!

      Here is the code for the link event handler, which passes link ID to the SessionBean:
      public String hyperlink1_action() {
      Object clickedLink = hyperlink1.getText();
      try{
      getSessionBean1().getEd_activityRowSet().setObject(1,clickedLink);
      }catch(Exception e){
      error("what is wrong?");
      }
      return "page2";
      }

      Here is the SessionBean code,which receives the link ID:
      private void _init() throws Exception {
      ...
      ed_activityRowSet.setCommand
      ("SELECT EDAS2.ED_ACTIVITY.ACT_UID, \n EDAS2.ED_ACTIVITY.MLOC_UID = ? ");
      ...
      }

      Please help! Thanks in advance.
        • 1. Re: Value pass problem from JSF page to SessionBean
          807601
          Leewu wrote:
          Hi,
          I use NetBean IDE-Visual Web Application to create this java application.
          Doesn't really matter.
          Basically, there is a list of links, which should link to a page with different content, depend on which link ID is passed over. However, the link ID is passed correctly only at the first time. And it never get changed again until the project redeployed?!

          Here is the code for the link event handler, which passes link ID to the SessionBean:
          You need to use the code button when you post code so we can read it, like this:
                     
          public String hyperlink1_action() { 
              Object clickedLink = hyperlink1.getText(); 
              try{ 
                  getSessionBean1().getEd_activityRowSet().setObject(1,clickedLink);           
              } catch(Exception e){ 
                  error("what is wrong?"); 
              } 
              return "page2"; 
          }
          What is this: getEd_activityRowSet()
          Did you come up with that?!
          Here is the SessionBean code,which receives the link ID:
          private void _init() throws Exception {
          ...
          ed_activityRowSet.setCommand
          ("SELECT EDAS2.ED_ACTIVITY.ACT_UID, \n EDAS2.ED_ACTIVITY.MLOC_UID = ? ");
          ...
          }

          Please help! Thanks in advance.
          You haven't posted enough info for anyone to figure out your problem.
          • 2. Re: Value pass problem from JSF page to SessionBean
            807601
            code tags not working today? interesting (doesn't surprise me)
            • 3. Re: Value pass problem from JSF page to SessionBean
              807601
              Ok, here is SessionBean1.java code:
              import com.sun.rave.web.ui.appbase.AbstractSessionBean;
              import com.sun.sql.rowset.CachedRowSetXImpl;
              import javax.faces.FacesException;
              
              public class SessionBean1 extends AbstractSessionBean {
                     private int __placeholder;
                  
                     private void _init() throws Exception {
                      ed_monitoring_locationRowSet.setDataSourceName("java:comp/env/jdbc/dataSource_1193342265548");
                      ed_monitoring_locationRowSet.setCommand("SELECT * FROM EDAS2.ED_MONITORING_LOCATION");
                      ed_monitoring_locationRowSet.setTableName("ED_MONITORING_LOCATION");
                      ed_activityRowSet.setDataSourceName("java:comp/env/jdbc/dataSource_1193342265548");
                      ed_activityRowSet.setCommand("SELECT ALL EDAS2.ED_ACTIVITY.ACT_UID, \n                    EDAS2.ED_ACTIVITY.ACMED_UID, \n                    EDAS2.ED_ACTIVITY.ACTYP_UID, \n                    EDAS2.ED_ACTIVITY.AMSUB_UID, \n                    EDAS2.ED_ACTIVITY.HCMTH_UID, \n                    EDAS2.ED_ACTIVITY.HRDAT_UID, \n                    EDAS2.ED_ACTIVITY.MLOC_UID, \n                    EDAS2.ED_ACTIVITY.MSUNT_UID_DEPTH_HEIGHT, \n                    EDAS2.ED_ACTIVITY.MSUNT_UID_DEPTH_HEIGHT_TOP, \n                    EDAS2.ED_ACTIVITY.MSUNT_UID_DEPTH_HEIGHT_BOTTOM, \n                    EDAS2.ED_ACTIVITY.ORG_UID, \n                    EDAS2.ED_ACTIVITY.RELDPTH_UID, \n                    EDAS2.ED_ACTIVITY.TMZONE_UID_START_TIME, \n                    EDAS2.ED_ACTIVITY.TMZONE_UID_END_TIME, \n                    EDAS2.ED_ACTIVITY.ACT_ID, \n                    EDAS2.ED_ACTIVITY.ACT_COMMENTS, \n                    EDAS2.ED_ACTIVITY.ACT_START_DATE, \n                    EDAS2.ED_ACTIVITY.ACT_START_TIME, \n                    EDAS2.ED_ACTIVITY.ACT_END_DATE, \n                    EDAS2.ED_ACTIVITY.ACT_END_TIME, \n                    EDAS2.ED_ACTIVITY.ACT_DEPTH_HEIGHT, \n                    EDAS2.ED_ACTIVITY.ACT_DEPTH_HEIGHT_TOP, \n                    EDAS2.ED_ACTIVITY.ACT_DEPTH_HEIGHT_BOTTOM, \n                    EDAS2.ED_ACTIVITY.ACT_DEPTH_ALTITUDE_REF_POINT, \n                    EDAS2.ED_ACTIVITY.ACT_LOC_LATITUDE, \n                    EDAS2.ED_ACTIVITY.ACT_LOC_LONGITUDE, \n                    EDAS2.ED_ACTIVITY.ACT_LOC_SOURCE_MAP_SCALE, \n                    EDAS2.ED_ACTIVITY.CONCOL_UID, \n                    EDAS2.ED_ACTIVITY.CONTYP_UID, \n                    EDAS2.ED_ACTIVITY.SCEQP_UID, \n                    EDAS2.ED_ACTIVITY.STANT_UID, \n                    EDAS2.ED_ACTIVITY.TAX_UID, \n                    EDAS2.ED_ACTIVITY.THPRSV_UID, \n                    EDAS2.ED_ACTIVITY.ACT_SAM_CHEMICAL_PRESERVATIVE, \n                    EDAS2.ED_ACTIVITY.ACT_SAM_COLLECT_METH_ID, \n                    EDAS2.ED_ACTIVITY.ACT_SAM_COLLECT_METH_CONTEXT, \n                    EDAS2.ED_ACTIVITY.ACT_SAM_COLLECT_METH_NAME, \n                    EDAS2.ED_ACTIVITY.ACT_SAM_COLLECT_METH_QUAL_TYPE, \n                    EDAS2.ED_ACTIVITY.ACT_SAM_COLLECT_METH_DESC, \n                    EDAS2.ED_ACTIVITY.ACT_SAM_COLLECT_EQUIP_COMMENTS, \n                    EDAS2.ED_ACTIVITY.ACT_SAM_PREP_METH_ID, \n                    EDAS2.ED_ACTIVITY.ACT_SAM_PREP_METH_CONTEXT, \n                    EDAS2.ED_ACTIVITY.ACT_SAM_PREP_METH_NAME, \n                    EDAS2.ED_ACTIVITY.ACT_SAM_PREP_METH_QUAL_TYPE, \n                    EDAS2.ED_ACTIVITY.ACT_SAM_PREP_METH_DESC, \n                    EDAS2.ED_ACTIVITY.ACT_SAM_TRANSPORT_STORAGE_DESC, \n                    EDAS2.ED_ACTIVITY.ACT_LAST_CHANGE_DATE, \n                    EDAS2.ED_ACTIVITY.REQUEST_UID \nFROM EDAS2.ED_ACTIVITY\nWHERE EDAS2.ED_ACTIVITY.MLOC_UID = ? ");
                      ed_activityRowSet.setTableName("ED_ACTIVITY");
                  }
              
                  private CachedRowSetXImpl ed_monitoring_locationRowSet = new CachedRowSetXImpl();
              
                  public CachedRowSetXImpl getEd_monitoring_locationRowSet() {
                      return ed_monitoring_locationRowSet;
                  }
              
                  public void setEd_monitoring_locationRowSet(CachedRowSetXImpl crsxi) {
                      this.ed_monitoring_locationRowSet = crsxi;
                  }
              
                  private CachedRowSetXImpl ed_activityRowSet = new CachedRowSetXImpl();
              
                  public CachedRowSetXImpl getEd_activityRowSet() {
                      return ed_activityRowSet;
                  }
              
                  public void setEd_activityRowSet(CachedRowSetXImpl crsxi) {
                      this.ed_activityRowSet = crsxi;
                  }
                 
                  
                     public SessionBean1() {
                  }
                  
                    public void init() {
                             super.init();
                              try {
                          _init();
                      } catch (Exception e) {
                          log("SessionBean1 Initialization Failure", e);
                          throw e instanceof FacesException ? (FacesException) e: new FacesException(e);
                      }
                      
                   
                  }
                  
                     public void passivate() {
                  }
                  
                     public void activate(){
                      
                  }
                  
                     public void destroy() {
                  }
              
                    protected ApplicationBean1 getApplicationBean1() {
                      return (ApplicationBean1)getBean("ApplicationBean1");
                  }
              }
              getSessionBean1().getEd_activityRowSet().setObject(1,clickedLink) is method call to set the '? value' in the sql statement (at very end) in _init() method.
              Some how, I think, _init() is only called once and will never be refreshed.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
              • 4. Re: Value pass problem from JSF page to SessionBean
                807601
                sorry, i was commenting on the method name
                those are scary method names
                you obviously used to code in C :)

                in Java we don't use underscores for field & method names
                so __placeholder would just be placeholder and setEd_activityRowSet() would be setEdActivityRowSet()

                nobody can stop you from doing it but it's just very ugly, blech!
                • 5. Re: Value pass problem from JSF page to SessionBean
                  807601
                  Sorry, Some are auto-generated code such as init; some are oracle table name like edmonitoring_location, etc...