• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem while developing my spring application... (urgent!)

 
anand tiwari
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am facing a very strange issue while developing my spring application,

I am posting the code snippets from my application for better understanding of the problem. Following are the relevant files which are in use:
(servlet)-action.xml
controller.java which extends simpleformcontroller
*.jsp

Here is the code in the servlet-action.xml:

<bean id="gameValidator" class="com.lbadmin.validator.ManageGameValidator"></bean>
<bean id="manageGameController" class="com.lbadmin.web.ManageGameController">
<property name="failedView"><value>fail</value></property>
<property name="commandClass"><value>com.lbadmin.model.Game</value></property>
<property name="commandName"><value>gamemanage</value></property>
<property name="gameservice"><ref bean="gameService"/></property>
<property name="validator"><ref bean="gameValidator"/></property>
</bean>


(Here the thing to notice is that i have not included the formview property as i am using customized form view)

The code in the controller looks like this:

protected BindException bindObject(HttpServletRequest request,
Object command, Validator validator) throws Exception {
ServletRequestDataBinder binder = createBinder(request, command);
binder.bind(request);
BindException errors = new BindException(command,
getCommandName());
System.out.println("commandname=" + getCommandName());
if (validator.supports(command.getClass())) {
ValidationUtils.invokeValidator(validator, command, errors);
}
return errors;
}


protected ModelAndView showForm(HttpServletRequest request, HttpServletResponse response, BindException errors) throws Exception {
// TODO Auto-generated method stub
Map model = new HashMap();
if (request.getSession().getAttribute("userName") != null) {
String operation = RequestUtils.getStringParameter(request,
"operation", "");
if (operation.equals("showgames")) {
handleShowGames(model);
} else if (operation.equals("addgame")) {

return handleAddGame(request, response, model, errors);

} else if (operation.equals("editgame")) {
handleEditGame(request, response, model);
} else if (operation.equals("deletegame")) {
handleDeleteGame(request, response, model);
}
}

return new ModelAndView(getViewName(), "model",model);
}


protected ModelAndView onSubmit(HttpServletRequest request,
HttpServletResponse response, Object obj, BindException errors)
throws Exception {

Map model = new HashMap();
if (request.getSession().getAttribute("userName") != null) {
String operation = RequestUtils.getStringParameter(request,
"operation", "");
if (operation.equals("submitGameDetails")) {

handleSaveGame(response, model, obj);

}
}
return new ModelAndView(getViewName(), "model", model);
}


As you can see in the above code we are using the bindobject() and the show form() methods.


Now the code in the jsp will look like this:

<tr>
<td width="173">
<b class="UserName">Top Scores To Show</b></td>
<td width="296" align="left">

<spring:bind path="gamemanage.topscore">
<input name="topscore" type="text" class="smallTextBox" size="30" maxlength="3" width="50"
value="<c ut value="${status.value}"/>"/>
<c:if test="${status.error}">
<span id="<c ut value="${status.expression}"/>Error" class="error">
<c ut value="${status.errorMessage}"/>
</span>
</c:if>
</spring:bind>

</td>
</tr>

Here topscore is the property i am trying to bind and validate...


however when the above application is run i am getting the following exception:

javax.servlet.ServletException: Neither Errors instance nor plain target object for bean name 'gamemanage' available as request attribute
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:848)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781)
org.apache.jsp.WEB_002dINF.jsp.login_jsp._jspService(org.apache.jsp.WEB_002dINF.jsp.login_jsp:137)

I think i am missing somthing here?? can someone please help.... i am really stuck up....
thanks in advance
 
Herman Schelti
Ranch Hand
Posts: 387
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

Map model = new HashMap();
...
return new ModelAndView(getViewName(), "model", model);

Do you put anything in your map or is it still empty when you get to the jsp?

Herman
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic