Announcement Announcement Module
Collapse
No announcement yet.
view problems in a jsp page Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • view problems in a jsp page

    i'm just thinking about how i must "bind" a model to a view.
    the model is like
    Code:
    public class Model implements Serializable{
    	private String modelId;
    	private String name;
    	private Sbml sbml;
    	private List listOfFunctionDefinition;
    	private List listOfUnitDefinition;
    	private List listOfCompartment;
    	private List listOfSpecies;
    	private List listOfParameter;
    	private List listOfRule;
    	private List listOfReaction;
    	private List listOfEvent;
    	private Long id;
    	private int metaId;
    	private String notes;
    	private String annotation;
    
    	public Model() {
    	}
    }
    and i give the model from an controller to the view. there i want to
    iterate threw the different listOfXXX to list the attributes. I tried this
    by
    Code:
           <table class="content" cellspacing="0" cellpadding="2" align="center">
    
              <tr width="100%"><th></th><th><b class="header1">Model</b></th><th></th><th></th><th></th><th></th><th></th><th></th></tr>
    
              <tr class="header2" align="center" width="100%">
              <td></td><td><b>Sbml</b></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
              <tr class="light" width="100%">
              <td></td><td><b>Level&#58;</b></td><td><c&#58;out value="$&#123;model.sbml.level&#125;"/></td><td><b>Version&#58;</b></td><td><c&#58;out value="$&#123;model.sbml.version&#125;"/></td><td></td><td></td><td></td></tr>
    
              <tr class="header2" align="center" width="100%">
              <td></td><td><b>Model</b></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
              <tr class="light" width="100%">
              <td></td><td><b>MetaId&#58;</b></td><td><c&#58;out value="$&#123;model.metaId&#125;"/></td><td><b>Annotation&#58;</b></td><td><c&#58;out value="$&#123;model.annotation&#125;"/></td><td><b>Notes&#58;</b></td><td><c&#58;out value="$&#123;model.notes&#125;"/></td><td></td></tr>
              <tr class="light" width="100%">
              <td></td><td><b>SId&#58;</b></td><td><c&#58;out value="$&#123;model.modelId&#125;"/></td><td><b>Name&#58;</b></td><td><c&#58;out value="$&#123;model.name&#125;"/></td><td><b></b></td><td></td><td></td></tr>
    
            <c&#58;if test="$&#123;model.listOfFunctionDefinition != null&#125;">
              <c&#58;forEach var="functionDefinition" items="$&#123;model.listOfFunctionDefinition&#125;">
                  <tr class="header2" align="center" width="100%">
                  <td></td><td><b>FunctionDefinition</b></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
                  <tr class="light" width="100%">
                  <td></td><td><b>MetaId&#58;</b></td><td></td><td><b>Annotation&#58;</b></td><td></td><td><b>Notes&#58;</b></td><td></td><td></td></tr>
              </c&#58;forEach>
            </c&#58;if>
    but i get errormessages like
    Code:
    2004-11-02 12&#58;06&#58;19,823 ERROR &#91;org.springframework.web.servlet.DispatcherServlet&#93; - Could not complete request 
    javax.servlet.ServletException&#58; javax.servlet.jsp.JspException&#58; An error occurred while evaluating custom action attribute "test" with value "$&#123;model.listOfFunctionDefinition != null&#125;"&#58; Unable to find a value for "listOfFunctionDefinition" in object of class "uk.ac.ebi.datamodel.Model" using operator "." &#40;null&#41;
    	at org.apache.jasper.runtime.PageContextImpl.doHandlePageException&#40;PageContextImpl.java&#58;825&#41;
    	at org.apache.jasper.runtime.PageContextImpl.handlePageException&#40;PageContextImpl.java&#58;758&#41;
    	at org.apache.jsp.WEB_002dINF.jsp.model_jsp._jspService&#40;model_jsp.java&#58;124&#41;
    	at org.apache.jasper.runtime.HttpJspBase.service&#40;HttpJspBase.java&#58;94&#41;
    can anybody help me with my problem? thanks for response

  • #2
    Perhaps a silly question, but do you have a method called 'getListOfFunctionDefinition' in your Model object?

    jc

    Comment


    • #3
      public List getFunctionDefinition() {
      return listOfFunctionDefinition;
      }
      public void setFunctionDefinition(List functiondefinition) {
      this.listOfFunctionDefinition = functiondefinition;
      }


      perhaps i should rename the methods?

      Comment


      • #4
        thanks a lot ...... it was realy a stupid question

        Comment


        • #5
          If your jsp is referencing
          ${model.listOfFunctionDefinition}
          and your Model class has
          public List getFunctionDefinition() {
          return listOfFunctionDefinition;
          }
          that won't work.

          As you suggest, you need to rename the methods.
          You either need a method getListOfFunctionDefinition()
          or you need to reference ${model.functionDefinition} in your jsp.

          Comment


          • #6
            Sorry, my last post was redundant - wasn't looking carefully enough at the author of the previous post!

            Comment


            • #7
              I'm getting a similar exception:

              Code:
              javax.servlet.jsp.JspException&#58; An error occurred while evaluating custom action attribute "value" with value "$&#123;model.UserProfile.AnnualSalary&#125;"&#58; Unable to find a value for "AnnualSalary" in object of class "com.profile.impl.UserProfile" using operator "." &#40;null&#41;
              Here is the code in the Controller that creates the model.

              Code:
              Map model = new HashMap&#40;&#41;;
              
              com.profile.IUserProfile UserProfile = facade.getUserProfile&#40;&#41;;
              model.put&#40;"UserProfile", UserProfile&#41;;
                      
              return new ModelAndView&#40;"GetUserProfile", "model", model&#41;;

              My class heirarchy is as follows:

              Code:
              &#40;interface&#41;              IProfile       <------------      Profile
                                          ^            &#40;implements&#41;         ^
                                          |                                 |
                               &#40;inherits&#41; |                                 |   &#40;inherits&#41;
                                          |                                 |
                                          |                                 |
              &#40;sub-interface&#41;       IUserProfile     <-------------    UserProfile
                                                      &#40;implements&#41;
              The getAnnualSalary() method is defined in the IProfile interface and implemented in the IUserProfile class.

              The odd part is that I had earlier created a jsp page that implemented this but I can't seem to get it to work this time.

              Comment


              • #8
                So apparently all the names of properties must begin with a lower case letter. If anyone else is having this problem, try that once.

                Comment

                Working...
                X