Announcement Announcement Module
Collapse
No announcement yet.
${status.value} not getting resolved Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • ${status.value} not getting resolved

    This is probably a VERY obvious issue but I cannot see what I am doing wrong. It is probably fairly common too, when you don't have everything setup correctly. I there a general place I should look when this happens.

    I am trying to get a AbstractWizardFormController implemenatation to work that is explained in a book that I am reading "Expert Spring MVC and Web Flows".

    I setup all the controller config stuf in the constructor (I have also tried setting it up in the myapp-servlet.xml file with the same results).

    Code:
    public CreateAccountWizardController() 
        {
        	logger.info("initialize controller...");
            setCommandName("createAccount");
            setCommandClass(CreateAccount.class);
            setValidator(new CreateAccountValidator());
            setPages(new String[]{"usernameAndEmail", "billingAddress"});
            logger.info("initialize controller done");
        }
    The following is a snippet from my jsp.
    Code:
    <spring:nestedPath path="createAccount">
    
    		<form action="" method="post">
    			<div>
    			<input type="hidden" name="_page0" value="true" />
    			<input type="hidden" name="_target1" value="true" />
    			</div>
    			<table>
    				<spring:nestedPath path="account">
    					<tag:formField name="Username" path="username" />
    					<tag:formField name="Password" path="password" type="password" />
    				</spring:nestedPath>
    				<tag:formField name="Confirm Password" path="confirmPassword" type="password" />
    				<spring:nestedPath path="account">
    					<tag:formField name="Email" path="email" />
    				</spring:nestedPath>
    				<tr>
    				  <td />
    				  <td><input type="submit" value="Go to Step 2" /></td>
    				</tr>
    			</table>
    		</form>
    	</spring:nestedPath>
    Also the tag formField is as follows:
    Code:
    <%@ tag body-content="scriptless" %>
    <%@ attribute name="name" required="true" %>
    <%@ attribute name="path" required="true" %>
    <%@ attribute name="type" required="false" %>
    <%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    
    <c:if test="${empty type}">
    <c:set var="type" value="text" scope="page" />
    </c:if>
    
    <spring:bind path="${path}">
    <tr>
      <td><label for="${status.expression}"
      <c:if test="${status.error}">class="error"</c:if>>${name}:</label></td>
      <td>
          <input type="${type}" id="${status.expression}" name="${status.expression}"
            value="${status.value}" />
      </td>
    </tr>
    </spring:bind>

    You probably don't need all this information, and will simply say something to the effect of: "oh, you just need to make sure such-in-such is in your such-in-such" By I am new and having trouble figuring this out. ANY help will be greatly appreciatted.

    Thanks in advance,
    Tad

  • #2
    More information

    Here's a screent show of what I am seeing in the browser:



    It is finding the binding tags because heres what the source looks like:
    Code:
    <body>
    
    	<h1>Create an Account</h1>
    
    
    		<form action="" method="post">
    			<div>
    			<input type="hidden" name="_page0" value="true" />
    			<input type="hidden" name="_target1" value="true" />
    			</div>
    		
    			<table>
    
    <tr>
      <td><label for="${status.expression}"
      >${name}:</label></td>
      <td>
          <input type="${type}" id="${status.expression}" name="${status.expression}"
            value="${status.value}" />
      </td>
    </tr>
    <tr>
      <td><label for="${status.expression}"
      >${name}:</label></td>
      <td>
          <input type="${type}" id="${status.expression}" name="${status.expression}"
            value="${status.value}" />
      </td>
    </tr>
    <tr>
      <td><label for="${status.expression}"
      >${name}:</label></td>
      <td>
          <input type="${type}" id="${status.expression}" name="${status.expression}"
            value="${status.value}" />
      </td>
    </tr>
    <tr>
      <td><label for="${status.expression}"
      >${name}:</label></td>
      <td>
          <input type="${type}" id="${status.expression}" name="${status.expression}"
            value="${status.value}" />
      </td>
    </tr>
    
    				
    				
    				<tr>
    				  <td />
    				  <td><input type="submit" value="Go to Step 2" /></td>
    				</tr>
    			
    			</table>
    		</form>
    	
    
    </body>
    Last edited by testing123; Apr 23rd, 2007, 04:03 PM.

    Comment


    • #3
      There's obviously something wrong with JSP config. It is not related to Spring.
      Check your web.xml to make sure it uses Servlet 2.4 namespace.

      Comment


      • #4
        It may be an issue with my jsp but I don't think it is the web.x

        I have a couple of sample controllers working correctly in the same app and I do not have this issue. The are more basic but the ${status.value} fields are resolved correctly in those jsps. This is the one jsp I have been having trouble with. Thanks for the reponse. Any ideas on what else could be wrong with my jsp setup? Do you need more information? If so what do you need?

        Comment


        • #5
          So far I only see that any of your EL expressions are ignored by servlet container.
          What container are you using? Could you post the heading of your web.xml file?
          Do you have any jsp-config declarations inside?

          Comment


          • #6
            More information

            I am using Tomcat 5.5 java 5.

            Here is my simplified springapp-servlet.xml

            Code:
            <?xml version="1.0" encoding="UTF-8"?>
            <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
            <!--  - Application context definition for "springapp" DispatcherServlet.  -->
            <beans>    
                <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
                    <property name="basename"><value>messages</value></property>
                </bean>
            	<bean id="createAccount" class="com.xactsites.xtol.web.CreateAccountWizardController" />
            	<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">        
            		<property name="mappings">            
            			<props>                
            				<prop key="/wizard.htm">createAccount</prop>      
            			</props>        
            		</property>    
            	</bean>
            	<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
                    <property name="viewClass"><value>org.springframework.web.servlet.view.JstlView</value></property>
                    <property name="prefix"><value>/WEB-INF/jsp/</value></property>
                    <property name="suffix"><value>.jsp</value></property>
                </bean>	
            </beans>
            Here is my web.xml
            Code:
            <?xml version="1.0" encoding="UTF-8"?>
            <!DOCTYPE web-app PUBLIC '-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN' 'http://java.sun.com/dtd/web-app_2_3.dtd'>
            
            <web-app>
            	<servlet>
                	<servlet-name>springapp</servlet-name>
                	<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
                	<load-on-startup>1</load-on-startup>
              	</servlet>
            
              	<servlet-mapping>
                	<servlet-name>springapp</servlet-name>
                	<url-pattern>*.htm</url-pattern>
              	</servlet-mapping>
            
              	<welcome-file-list>
                	<welcome-file>
                  		index.jsp
                	</welcome-file>
              	</welcome-file-list>
              	
              	<taglib>
            	    <taglib-uri>/spring</taglib-uri>
            	    <taglib-location>/WEB-INF/spring.tld</taglib-location>
            	</taglib>
              	
            </web-app>
            as seen no jsp-config declarations.

            Thanks again for helping with this! Again, the weird thing is that I have gotten a simpleformcontroller working fine and the status.* stuff resolves. Its only this one that I am having trouble with.

            Comment


            • #7
              I think you may try this one:
              Code:
              <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
                  version="2.4">
              Tomcat seems to be very sensible to namespace definition.

              Comment


              • #8
                No luck

                I added the stuff to my web.xml but still the same results. Like I said before I have other sample apps working so I don't think its the web.xml. It is probably a configuration issue with something process specific (i.e. something is wrong with my declarations in my springapp-servlet.xml or maybe in my controller constructors). But I can't see anything there either so your guess is as good as mine. I really appreciatte your help. Any other ideas?

                Comment


                • #9
                  So, did you dropped DOCTYPE?
                  And recompiled your JSP page?
                  And what is the header of JSP pages which work for you? (ie <%@page directive).

                  Comment


                  • #10
                    Originally posted by nekoval View Post
                    So, did you dropped DOCTYPE?
                    And recompiled your JSP page?
                    And what is the header of JSP pages which work for you? (ie <%@page directive).
                    1. It works for the page without the doctype. I have tried mixing and matching to try and get the wizard form to work but as discussed...no luck.

                    2. Yes I recompiled my jsp.

                    3. The page that works...
                    <%@ page session="false"%>
                    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
                    <%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
                    <%@ taglib prefix="spring" uri="/spring" %>

                    The page that doesnt...
                    <?xml version="1.0" encoding="ISO-8859-1" ?>
                    <%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>
                    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

                    <%@ taglib tagdir="/WEB-INF/tags" prefix="tag" %>
                    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

                    Sorry I am so ignorant about spring mvc, I think I have been staring at this to long and so I can't see what should be fairly easy to fix. Thanks again for all your help.

                    Comment


                    • #11
                      >1. It works for the page without the doctype. I have tried mixing and matching to try and get the wizard form to work but as discussed...no luck.

                      I mean DOCTYPE in your web.xml. Anyway, do you know what the bug is and why I'm asking to do that changes in web.xml?

                      Comment


                      • #12
                        Originally posted by nekoval View Post
                        >1. It works for the page without the doctype. I have tried mixing and matching to try and get the wizard form to work but as discussed...no luck.

                        I mean DOCTYPE in your web.xml. Anyway, do you know what the bug is and why I'm asking to do that changes in web.xml?
                        No I don't know what the bug it. Here is what my web.xml looks like:

                        Code:
                        <?xml version="1.0" encoding="UTF-8"?>
                        <!DOCTYPE web-app PUBLIC '-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN' 'http://java.sun.com/dtd/web-app_2_3.dtd'>
                        
                        <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
                            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                            xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
                            version="2.4">
                        	<servlet>
                            	<servlet-name>springapp</servlet-name>
                            	<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
                            	<load-on-startup>1</load-on-startup>
                          	</servlet>
                        
                          	<servlet-mapping>
                            	<servlet-name>springapp</servlet-name>
                            	<url-pattern>*.htm</url-pattern>
                          	</servlet-mapping>
                        
                          	<welcome-file-list>
                            	<welcome-file>
                              		index.jsp
                            	</welcome-file>
                          	</welcome-file-list>
                          	
                          	<taglib>
                        	    <taglib-uri>/spring</taglib-uri>
                        	    <taglib-location>/WEB-INF/spring.tld</taglib-location>
                        	</taglib>
                          	
                        </web-app>

                        Comment


                        • #13
                          You have to drop DOCTYPE because it refers to Servlet 2.3.
                          If that won't work, try inserting the following into web.xml:

                          Code:
                          <jsp-config>
                          <jsp-property-group>
                          <url-pattern>*.jsp</url-pattern>
                          <scripting-invalid>false</scripting-invalid>
                          <el-ignored>false</el-ignored>
                          </jsp-property-group>
                          </jsp-config>

                          Comment


                          • #14
                            If at first you don't succeed....

                            I finally just started over and got it working by creating my own sample app instead of trying to use the one from the book I am reading and wouldn't you know it, I got it up and working. Thanks for trying to help me solve this issue. I still have now clue why this was happening.

                            Comment

                            Working...
                            X