Results 1 to 10 of 14

Thread: ${status.value} not getting resolved

Hybrid View

  1. #1
    Join Date
    Apr 2007
    Posts
    276

    Default ${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. #2
    Join Date
    Apr 2007
    Posts
    276

    Default More information

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


    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>
    Attached Images Attached Images
    Last edited by testing123; Apr 23rd, 2007 at 03:03 PM.

  3. #3
    Join Date
    Feb 2007
    Location
    Moscow, Russia
    Posts
    56

    Default

    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.

  4. #4
    Join Date
    Apr 2007
    Posts
    276

    Default 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?

  5. #5
    Join Date
    Feb 2007
    Location
    Moscow, Russia
    Posts
    56

    Default

    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?

  6. #6
    Join Date
    Apr 2007
    Posts
    276

    Default 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.

  7. #7
    Join Date
    Feb 2007
    Location
    Moscow, Russia
    Posts
    56

    Default

    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.

Posting Permissions

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