This discussion is archived
11 Replies Latest reply: Jul 31, 2007 6:02 AM by 807605 RSS

Any Idea on the Solutions for this JSF Hibernate Problem

807605 Newbie
Currently Being Moderated
I try to pupolate a list showReports.
I try to compute the difference of 2 dates in unit hours..

The compilation throws error after this code...

temp = oocDataDet.getDetailId().getTimestamp();
log.debug("temp = "+ temp);


Here are the succeeding code:
showReports.add(oocDataDet);
=========================================================

27-07-2007 10:07:19 CST,ERROR,Application,org.apache.catalina.core.ApplicationDispatcher,,,"Servlet.service() for servlet jsp threw exception"
javax.faces.el.EvaluationException: Cannot get value for expression '#{ReportsBean.showReports}'
     at org.apache.myfaces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:397)
     at javax.faces.component.UIData.getValue(UIData.java:779)
     at javax.faces.component.UIData.createDataModel(UIData.java:545)
     at javax.faces.component.UIData.getDataModel(UIData.java:534)
     at javax.faces.component.UIData.getRowCount(UIData.java:103)
     at org.apache.myfaces.renderkit.html.HtmlTableRendererBase.encodeInnerHtml(HtmlTableRendererBase.java:124)
     at org.apache.myfaces.renderkit.html.HtmlTableRendererBase.encodeChildren(HtmlTableRendererBase.java:94)
     at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:319)
     at org.apache.myfaces.renderkit.RendererUtils.renderChild(RendererUtils.java:444)
  • 1. Re: Any Idea on the Solutions for this JSF Hibernate Problem
    800351 Newbie
    Currently Being Moderated
    Your ReportsBean class has bugs for property access or your faces-config.xml is not properly written for manageg-bean configuration.
  • 2. Re: Any Idea on the Solutions for this JSF Hibernate Problem
    807605 Newbie
    Currently Being Moderated
    Hi,

    Tnx hiwa...just the problem in ReportsBean. I just take away some unnecessary
    try-catch and found out it worked...

    My next problem is that : I can't displayed the queried value in the jsp. I tried to make this value a field of the object ReportsBean so I can call it up in the jsp page. Here's the jsp code:
    ----------------------------------------------------------------------------
    <h:outputText value="OCAP Spec Number:" />
                                  <h:outputText id="ocapSpecNumber" value="#{ReportsBean.ocapSpecNumber}" />     
    -----------------------------------------------------------------------------

    In the debugger, the queried value is displayed but got problem
    when it's access as a field of the ReportsBean.

    If you have alternative way of accessing a queried value from database
    without using the <h:dataTable> please tell me so since It's just a single
    value I NEED TO SHOW..

    Thanks in advance...
    -Lanz
  • 3. Re: Any Idea on the Solutions for this JSF Hibernate Problem
    800351 Newbie
    Currently Being Moderated
    Your ReportsBean class and/or faces-config.xml is not properly written for bean property access. It's just that.
  • 4. Re: Any Idea on the Solutions for this JSF Hibernate Problem
    807605 Newbie
    Currently Being Moderated
    Thanks hiwa...
    It seems that the jsp is accessing the value of the OcapSpecNumber prior to the retrieval of value from the database that's why it's null...any suggestion?
  • 5. Re: Any Idea on the Solutions for this JSF Hibernate Problem
    800351 Newbie
    Currently Being Moderated
    Thanks hiwa...
    It seems that the jsp is accessing the value of the
    OcapSpecNumber prior to the retrieval of value from
    the database that's why it's null...any suggestion?
    It is the issue of how the ReportsBean bean is written. It is not the accessor, the jsp, issue. You should rewrite the getOcapSpecNumber() method for it to return a correct value everytime it is called.
  • 6. Re: Any Idea on the Solutions for this JSF Hibernate Problem
    807605 Newbie
    Currently Being Moderated
    To all (including hiwa),

    I tried different ways like this code but still can't display the OcapSpecNumber in the jsp. Here is the code:
    ----------------------------------------------------------------------------------------
    tempOcapSpecNum = oocDataDet.getOocDataId().getOcapFormId().getOcapSpecNumber();

    setOcapSpecNumber(tempOcapSpecNum);
    ----------------------------------------------------------------------------------------

    then it getter,

    public String getOcapSpecNumber() {

    log.debug("ocapSpecNumber = "+ this.ocapSpecNumber);
    return this.ocapSpecNumber;
    }

    ----------------------------------------------------------------------------------------

    Still I can't display the retrieved value....

    Thanks in advance...
  • 7. Re: Any Idea on the Solutions for this JSF Hibernate Problem
    800351 Newbie
    Currently Being Moderated
    Provided faces-config.xml is properly written for the mangaged bean, the method should be:
    public String getOcapSpecNumber() {
      if (ocapSpecNumber == null){
        ocapSpecNumber = surefireWayToGenerateOcapSpecNumber();
      }
      reurn ocapSpecNumber;
    }
  • 8. Re: Any Idea on the Solutions for this JSF Hibernate Problem
    807605 Newbie
    Currently Being Moderated
    To all,

    Thanks for that hiwa. Almost the same as that... I invoke the fetching of data
    at submit function...and found it's working...

    Next problem of mine is i can't trigger the function transferToCSVFile in ViewSearchedDataBean...when I click the button in viewSearchedData.jsp...
    I place some log.debug but can't be seen in the console.

    The function transferToCSVFile writes the searched data in a csv file(comma delimited file).

    Here's the jsp code:
    ---------------------------------------------------------------------------------------------------
              <h:panelGrid width="100%" styleClass="columncenter">
                        <h:commandButton action="#{ViewSearchedDataBean.transferToCSVFile}"
                                       value="Transfer to CSV File"/>          
                   </h:panelGrid>
    ---------------------------------------------------------------------------------------------------


    Thanks again...
    -lanz
  • 9. Re: Any Idea on the Solutions for this JSF Hibernate Problem
    807605 Newbie
    Currently Being Moderated
    Hi all,
    Since I can't access the transferToCSVFile function in the SearchBean, I decided to create ViewSearchedDataBean for ViewSearchedData.jsp.

    Anyone who knows how to create save as dialog box in JSF?

    Thanks,
    Lanz
  • 10. Re: Any Idea on the Solutions for this JSF Hibernate Problem
    800351 Newbie
    Currently Being Moderated
    Hi all,
    Since I can't access the transferToCSVFile
    function in the SearchBean, I decided to create
    ViewSearchedDataBean for ViewSearchedData.jsp.

    Anyone who knows how to create save as dialog box in
    JSF?

    Thanks,
    Lanz
    Don't do that. You should write proper navigation rule in your faces-config.xml.

    -----------------------------
    #{ViewSearchedDataBean.transferToCSVFile}
    What was the error message or exception?
    Do you use a class name, not a bean object name????
  • 11. Re: Any Idea on the Solutions for this JSF Hibernate Problem
    807605 Newbie
    Currently Being Moderated
    Hiwa,

    This worked already after I already after I experimentally added something...

    <h:panelGrid width="100%" styleClass="columncenter">
    <h:commandButton action="#{ViewSearchedDataBean.transferToCSVFile}"
    value="Transfer to CSV File"/>
    </h:panelGrid>
    ----------------------------------------------------------------------
    I experimentally add this part given I also have transferToCSVFile in SearchBean:

    <h:commandButton action="#{SearchBean.transferToCSVFile}"
    value="Transfer to CSV File SearchBean"/>


    ------------------------------------------------------------------------
    Both are working....I am still to find out if the program will work if I eliminate the unnecessary second Transfer to CSV File SearchBean...

    Now, please help me to create a save as dialog box in JSF..I'm
    really having a hard time....

    Thanks,
    Lanz