Results 1 to 8 of 8

Thread: view problems in a jsp page

  1. #1
    Join Date
    Oct 2004
    Posts
    10

    Default 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. #2
    Join Date
    Aug 2004
    Location
    Toronto
    Posts
    8

    Default

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

    jc

  3. #3
    Join Date
    Oct 2004
    Posts
    10

    Default

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


    perhaps i should rename the methods?

  4. #4
    Join Date
    Oct 2004
    Posts
    10

    Default

    thanks a lot ...... it was realy a stupid question

  5. #5
    Join Date
    Aug 2004
    Location
    Carlisle, UK
    Posts
    184

    Default

    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.
    Chris Harris
    Carlisle, UK

  6. #6
    Join Date
    Aug 2004
    Location
    Carlisle, UK
    Posts
    184

    Default

    Sorry, my last post was redundant - wasn't looking carefully enough at the author of the previous post!
    Chris Harris
    Carlisle, UK

  7. #7
    Join Date
    Mar 2005
    Location
    Champaign, IL
    Posts
    10

    Default

    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.

  8. #8
    Join Date
    Mar 2005
    Location
    Champaign, IL
    Posts
    10

    Default

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

Similar Threads

  1. Pageable data list with Hibernate
    By robmorgan in forum Data
    Replies: 23
    Last Post: Jul 24th, 2006, 06:12 PM
  2. Replies: 9
    Last Post: Nov 1st, 2005, 10:36 PM
  3. Problems moving Validation from View to external jsp
    By sforsyth in forum Spring-Modules
    Replies: 1
    Last Post: Oct 14th, 2005, 12:06 PM
  4. Replies: 0
    Last Post: Jun 10th, 2005, 08:22 AM
  5. Content Provider vs View Model
    By Martin Kersten in forum Swing
    Replies: 21
    Last Post: Mar 10th, 2005, 02:25 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •