This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Other Application Frameworks and the fly likes Problem while developing my spring application... (urgent!) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Problem while developing my spring application... (urgent!)" Watch "Problem while developing my spring application... (urgent!)" New topic
Author

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

anand tiwari
Greenhorn

Joined: Jun 22, 2007
Posts: 22
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

Joined: Jul 17, 2006
Posts: 387
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem while developing my spring application... (urgent!)
 
Similar Threads
java. lang. IllegalStateException: Neither Binding Result nor plain target object
using SimpleFormController
Neither BindingResult nor plain target object for bean name 'user' available as request attribute
Spring form input binding problem
Spring MVC question