Results 1 to 2 of 2

Thread: Strange Error Text

  1. #1
    Join Date
    Jun 2005
    Posts
    2

    Default Strange Error Text

    My login screen shows Ê ÊÊ Ê Ê Ê Ê ÊÊ Ê characters where my errors should be. This happens on the GET request and on POST, so on first page load and on login failure. The message text is contained within properties files defined in the message source bean and I can pull the error messages from the file.

    Thanks for any help.

    My jsp code is below. The taglibs are imported correctly, because the i18n messages display and I verified the c:outs:
    Code:
    <html>
    	<body>	
    		<form method="POST" action="/login.do">
    			<table>
    				<spring&#58;bind path="command.*"> 
    			 * ** *<c&#58;forEach items="$&#123;status.errorMessages&#125;" var="errorMessage"> 
    			 		<tr><td>
    			 * ** ** *<c&#58;out value="$&#123;errorMessage&#125;"/>
    			 		</tr></td>
    			 * ** *</c&#58;forEach> 
     * *				</spring&#58;bind> 
    				<tr>
    					<td class="label">
    						<spring&#58;message code="username"/>
    					</td>
    					<td>
    						<spring&#58;bind path="command.username">
    							<input class="input" type="text" name="username"/>
    						</spring&#58;bind>
    					</td>
    				</tr>
    				<tr>
    					<td class="label">
    						<spring&#58;message code="password"/>
    					</td>
    					<td>
    						<spring&#58;bind path="command.password">
    							<input type="password" class="input" name="password"/>
    						</spring&#58;bind>
    					</td>
    					<td>
    						<input class="button" type="submit" value="<spring&#58;message code='login'/>"/>
    					</td>
    				<tr>
    			</table>
    		</form>
    	</body>
    </html>
    This is my login controller
    Code:
    protected Object formBackingObject&#40;HttpServletRequest request&#41; throws ServletException &#123; 
        		return new User&#40;&#41;;
        &#125; 
        
        protected ModelAndView onSubmit&#40;HttpServletRequest q_,  HttpServletResponse r_,  Object f_,  BindException e_&#41;&#123; 
            User _user = &#40;User&#41;f_;
            String message = getApplicationContext&#40;&#41;.getMessage&#40;"required.username", null, "My Default Message", q_.getLocale&#40;&#41;&#41;;
            boolean _validated = _userService.validateUser&#40;_user.getUsername&#40;&#41;, _user.getPassword&#40;&#41;&#41;;
            if &#40;_validated&#41;&#123;
            		return new ModelAndView&#40;getSuccessView&#40;&#41;,"user", _user&#41;;
            &#125;
            else&#123;
            		return new ModelAndView&#40;getFormView&#40;&#41;, e_.getModel&#40;&#41;&#41;;
            &#125;
            
        &#125;
    And the validator

    Code:
    public class LoginValidator implements Validator &#123;
    	
    	private Logger _logger = Logger.getLogger&#40;LoginValidator.class&#41;;
    
    	public boolean supports&#40;Class clazz_&#41; &#123;
    		return clazz_.equals&#40;User.class&#41;;
    	&#125;
    
    	public void validate&#40;Object obj_, Errors errors_&#41; &#123;
    		System.out.println&#40;"validating"&#41;;
    		User _user = &#40;User&#41; obj_;
    		ValidationUtils.rejectIfEmpty&#40;errors_, "username", "required.username", "Username is required"&#41;;
    	&#125;
    
    &#125;

  2. #2
    Join Date
    May 2005
    Location
    California, US
    Posts
    735

    Default

    I'm a newbie so I don't know if the way I'm doing it is any better but here's how I'm doing it. Here's the controller part from my -servlet.xml file:
    Code:
        <bean id="adminSignInCtlr" class="ctlr.AdminSignInCtlr">
            <property name="commandClass" value="view.AdminSignInFrmData" />
            <property name="validator" ref="adminSignInValidate" />
            <property name="formView" value="adminSignInView" />
            <property name="adminView" value="fdebugView" />
            <property name="waitlistView" value="waitlistView" />
            <property name="sessionForm" value="false" />
            <property name="bindOnNewForm" value="true" />
            <property name="facilityDao" ref="facilityDao" />
            <property name="wleDao" ref="wleDao" />
        </bean>
    For my controller the onSubmit is:
    Code:
        protected ModelAndView
        onSubmit&#40;Object cmd&#41; &#123;
            AdminSignInFrmData      sifd = &#40;AdminSignInFrmData&#41; cmd;
    
            String view = sifd.getView&#40;&#41;;
    
            Map<String,Object> model = new HashMap<String, Object>&#40;&#41;;
            model.put&#40;"sifd", sifd&#41;;
            model.put&#40;"platcnt", facilityDao.getPlatCount&#40;sifd.getFacility&#40;&#41;&#41;&#41;;
            model.put&#40;"wlePc", wleDao.getWaitlistEntries&#40;sifd.getFacility&#40;&#41;, "pc"&#41;&#41;;
            model.put&#40;"wleMac",wleDao.getWaitlistEntries&#40;sifd.getFacility&#40;&#41;,mac"&#41;&#41;;
    
            if &#40;view.equals&#40;"admin"&#41;&#41;
                return&#40;new ModelAndView&#40;adminView, "model", model&#41;&#41;;
    
            if &#40;view.equals&#40;"waitlist"&#41;&#41;
                return&#40;new ModelAndView&#40;waitlistView, "model", model&#41;&#41;;
    
            /* oops */
            return&#40;new ModelAndView&#40;&#40;String&#41; null, "model", model&#41;&#41;;
        &#125;
    And my validator is just like yours:
    Code:
        public void
        validate&#40;Object obj, Errors errs&#41; &#123;
            ValidationUtils.rejectIfEmpty&#40;errs,
                                    "facility",
                                    "err.facility",
                                    "Facility?"&#41;;
    
            ValidationUtils.rejectIfEmpty&#40;errs,
                                    "view",
                                    "err.view",
                                    "View?"&#41;;
    
            ValidationUtils.rejectIfEmptyOrWhitespace&#40;errs,
                                    "password",
                                    "err.password",
                                    "Password?"&#41;;
        &#125;
    I think that the main difference is that I'm setting the validator in the -servlet.xml file and not calling it directly the way you are and it's being called automatically for me.

Similar Threads

  1. really strange problem with session
    By a_wronski in forum Security
    Replies: 2
    Last Post: Jun 24th, 2005, 10:23 PM
  2. Strange setup bean behaviour with validation
    By Christian in forum Web Flow
    Replies: 4
    Last Post: Jun 20th, 2005, 05:27 PM
  3. Replies: 1
    Last Post: Apr 29th, 2005, 06:56 AM
  4. Replies: 3
    Last Post: Jan 31st, 2005, 08:52 AM
  5. Replies: 0
    Last Post: Jan 3rd, 2005, 03:31 AM

Posting Permissions

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