How to Update a page in Spring mvc - spring

Can someone please point me to the right direction, it is a very simple spring form that I'm trying to edit. I have tried various examples from net but can not get it working.
<form:form id="myForm" modelAttribute="contacts" method="Post" action="contacts.html" commandName="contacts">
<label>First Name<span class="small">Edit your first name</span></label>
<form:input path="firstName" /><br>
<form:errors path="firstName" cssClass="error" /><br>
<label>Last Name<span class="small">Edit your last name</span></label>
<form:input path="lastName" /><br>
<form:errors path="lastName" cssClass="error" /><br>
<button type="submit">Amend</button>
</form:form>
protected static final String EDIT_VIEW_KEY = "editForm";
#Autowired
private ContactsService conService;
#RequestMapping(value="/edit/{id}", method = RequestMethod.GET)
public String showEditForm(#PathVariable("id") Integer id,
#ModelAttribute("contacts") Contacts contacts,Model model){
model.addAttribute("contacts", conService.listContactsById(id));
return EDIT_VIEW_KEY;
}
and the error I'm getting is this;
org.springframework.beans.NotReadablePropertyException: Invalid property 'firstName' of bean class [java.util.ArrayList]: Bean property 'firstName' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:729)
org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:721)
org.springframework.web.servlet.support.BindStatus.<init>(BindStatus.java:147)
org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getBindStatus(AbstractDataBoundFormElementTag.java:178)
org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getPropertyPath(AbstractDataBoundFormElementTag.java:198)
org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getName(AbstractDataBoundFormElementTag.java:164)
org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.autogenerateId(AbstractDataBoundFormElementTag.java:151)
org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.resolveId(AbstractDataBoundFormElementTag.java:142)
org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.writeDefaultAttributes(AbstractDataBoundFormElementTag.java:126)
org.springframework.web.servlet.tags.form.AbstractHtmlElementTag.writeDefaultAttributes(AbstractHtmlElementTag.java:421)
org.springframework.web.servlet.tags.form.InputTag.writeTagContent(InputTag.java:142)
org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(AbstractFormTag.java:102)
org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:79)
org.apache.jsp.WEB_002dINF.views.editForm_jsp._jspx_meth_form_005finput_005f0(editForm_jsp.java:214)
org.apache.jsp.WEB_002dINF.views.editForm_jsp._jspx_meth_c_005fforEach_005f0(editForm_jsp.java:173)
org.apache.jsp.WEB_002dINF.views.editForm_jsp._jspx_meth_form_005fform_005f0(editForm_jsp.java:128)
org.apache.jsp.WEB_002dINF.views.editForm_jsp._jspService(editForm_jsp.java:85)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:954)
org.apache.jasper.runtime.PageContextImpl.doInclude(PageContextImpl.java:684)
org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:678)
org.apache.tiles.jsp.context.JspTilesRequestContext.include(JspTilesRequestContext.java:103)
org.apache.tiles.jsp.context.JspTilesRequestContext.dispatch(JspTilesRequestContext.java:96)
org.apache.tiles.renderer.impl.TemplateAttributeRenderer.write(TemplateAttributeRenderer.java:44)
org.apache.tiles.renderer.impl.AbstractBaseAttributeRenderer.render(AbstractBaseAttributeRenderer.java:106)
org.apache.tiles.renderer.impl.ChainedDelegateAttributeRenderer.write(ChainedDelegateAttributeRenderer.java:76)
org.apache.tiles.renderer.impl.AbstractBaseAttributeRenderer.render(AbstractBaseAttributeRenderer.java:106)
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:670)
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:336)
org.apache.tiles.template.InsertAttributeModel.renderAttribute(InsertAttributeModel.java:210)
org.apache.tiles.template.InsertAttributeModel.end(InsertAttributeModel.java:126)
org.apache.tiles.jsp.taglib.InsertAttributeTag.doTag(InsertAttributeTag.java:311)
org.apache.jsp.WEB_002dINF.jsp.layout_jsp._jspx_meth_tiles_005finsertAttribute_005f3(layout_jsp.java:180)
org.apache.jsp.WEB_002dINF.jsp.layout_jsp._jspService(layout_jsp.java:98)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.tiles.servlet.context.ServletTilesRequestContext.forward(ServletTilesRequestContext.java:241)
org.apache.tiles.servlet.context.ServletTilesRequestContext.dispatch(ServletTilesRequestContext.java:222)
org.apache.tiles.renderer.impl.TemplateAttributeRenderer.write(TemplateAttributeRenderer.java:44)
org.apache.tiles.renderer.impl.AbstractBaseAttributeRenderer.render(AbstractBaseAttributeRenderer.java:106)
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:670)
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:690)
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:644)
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:627)
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:321)
org.springframework.web.servlet.view.tiles2.TilesView.renderMergedOutputModel(TilesView.java:124)
org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:262)
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1157)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:927)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:827)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
Many thanks

You're passing back a list to your form:
Invalid property 'firstName' of bean class [java.util.ArrayList]
Your form expects things like a firstName field.
In general, a list won't have a firstName field, although they might contain a collection of objects that have a firstName field. Did you mean to iterate over the list with a form per item?

you are using modelAttribute="contacts" in form and I think that contacts is ArrayList so it is not contains firstName, if your list have object of bean contains "firstName" you can use to iterate on it or use modelAttribute="contacts[${i}]" and set i using with the value you want.

Related

Getting this error while working on Spring MVC and Apache tiles

I am not sure where the error is.
message
Request processing failed; nested exception is org.apache.tiles.impl.CannotRenderException:
org.apache.tiles.util.TilesIOException:
JSPException including path '/WEB-INF/views/hotels/enterBookingInfo.jsp'.
description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.springframework.web.util.NestedServletException:
Request processing failed; nested exception is org.apache.tiles.impl.CannotRenderException:
org.apache.tiles.util.TilesIOException: JSPException including path '/WEB-INF/views/hotels/enterBookingInfo.jsp'.
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:656)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
root cause
org.apache.tiles.impl.CannotRenderException: org.apache.tiles.util.TilesIOException:
JSPException including path '/WEB-INF/views/hotels/enterBookingInfo.jsp'.
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:692)
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:644)
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:627)
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:321)
org.springframework.web.servlet.view.tiles2.TilesView.renderMergedOutputModel(TilesView.java:124)
org.springframework.js.ajax.tiles2.AjaxTilesView.renderMergedOutputModel(AjaxTilesView.java:131)
org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1047)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:817)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
tiles.xml defintion is as follows
<tiles-definitions>
<definition name="enterBookingInfo" extends="standardLayout">
<put-attribute name="body" value="/WEB-INF/views/hotels/enterBookingInfo.jsp"> </put-attribute>
</definition>
</tiles-definitions>
Tiles configuration extract
<beans:bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
<beans:property name="definitions">
<beans:value>
/WEB-INF/**/tiles.xml
</beans:value>
</beans:property>
</beans:bean>
I got this resolved by setting the commandName attribute of the form to the name of the modelAttribute object used in my controller.
I also had to modify the method syntax to have BindingResult parameter which had to follow the ModelAttribute object.
public String ultimateBooking(#RequestParam("hotelId") String hotelId,#ModelAttribute("booking") Booking bookingValidation,BindingResult result,ModelMap model)
No changes were made to tile.xml

get the MovieRecommendation throw exception

i use spring data neo4j to work,i have a repository to recommend movie,i think cypher have not problem,and i can get the recommendation,but i can not get the value of Movie.title and rating ,why it shows movie id not property to the recommendation.class,in my log and error info you can see,why ?
i have severl similar problems,it seems cant get the value in jsp?help me thank you very much .heart man
recommendation.class
package com.oberon.fm.domain;
import org.springframework.data.neo4j.annotation.QueryResult;
#QueryResult
public class MovieRecommendation {
Movie movie;
int rating;
the repository
#Query("match (user:User {login: {0}})-[r:RATED]->(movie)<-[r2:RATED]-(other)-[r3:RATED]->(otherMovie) "
+ " where r.stars >= 3 and r2.stars >= r.stars and r3.stars >= r.stars "
+ " with otherMovie, avg(r3.stars) as rating, count(*) as cnt"
+ " order by rating desc, cnt desc"
+ " return otherMovie limit 10")
List<MovieRecommendation> getRecommendations(String login);
my controller
#RequestMapping(value = "/user", method = RequestMethod.GET)
public String profile(Model model, HttpServletRequest request) {
// User user=populator.getUserFromSession();
HttpSession session = request.getSession(false);
User user = (User) session.getAttribute("user");
model.addAttribute("user", user);
if (user != null) {
List<MovieRecommendation> mr = movieRepository.getRecommendations(user.getLogin());
model.addAttribute("recommendations", mr);
}
return "user/index";
}
index.jsp
<%# taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%# taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%# page contentType="text/html;charset=UTF-8" language="java" %>
<%--#elvariable id="user" type="com.oberon.fm.domain.User"--%>
<%--#elvariable id="recommendations"type="java.util.List<com.oberon.fm.domain.MovieRecommendation>"--%>
<%--#elvariable id="recommendation"type="com.oberon.fm.domain.MovieRecommendation"--%>
<html>
<head>
<title>Profile</title>
<link rel="stylesheet" type="text/css" href="/Web/css/style.css"/>
</head>
<body>
<div class="span-third">
<h2>Your recommendations</h2>
</div>
<div class="span-third last">
<h2>${fn:length(recommendations)}</h2>
</div>
<ul class="rated-movies-list span-all last">
<c:choose>
<c:when test="${not empty recommendations}">
<c:forEach items="${recommendations}" var="recommendation">
<c:set var="movie" value="${recommendation.movie}"/>
<c:set var="stars" value="${recommendation.rating}"/>
<li>
<h4> <a href="<c:url value="/movies/${movie.id}" />"><c:out value="${movie.title}"/>
(${movie.year}) - "${movie.tagline}"</a>
<img class="rating" alt="${stars} stars" src="<c:url value="/images/rated_${stars}.png" />"/>
</h4>
</li>
</c:forEach>
</c:when>
<c:otherwise>
There are no recommendations for you, perhaps you have to add some friends?
</c:otherwise>
</c:choose>
</ul>
<div class="break"></div>
</div>
</div>
i can get the length of recommendation
log and error info
16:19:32.403 [http-nio-8080-exec-8] DEBUG o.s.w.b.a.s.HandlerMethodInvoker - Invoking request handler method: publicjava.lang.String com.oberon.fm.controller.UserController.profile(org.springframework.ui.Model, javax.servlet.http.HttpServletRequest)
16:19:32.403 [http-nio-8080-exec-8] DEBUG o.s.t.jta.JtaTransactionManager - Creating new transaction with name [null]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
16:19:32.404 [http-nio-8080-exec-8] DEBUG o.s.d.n.s.q.CypherQueryEngineImpl - Executing cypher query: match (user:User {login: {0}})-[r:RATED]->(movie)<-[r2:RATED]-(other)-[r3:RATED]->(otherMovie) where r.stars >= 3 and r2.stars >= r.stars and r3.stars >= r.stars with otherMovie, avg(r3.stars) as rating, count(*) as cnt order by rating desc, cnt desc return otherMovie limit 10 params {0=micha}
16:19:32.739 [http-nio-8080-exec-8] DEBUG o.s.t.jta.JtaTransactionManager - Initiating transaction commit
16:19:32.740 [http-nio-8080-exec-8] DEBUG c.o.fm.controller.UserController - ()()()()()()()()()()()[com.oberon.fm.domain.MovieRecommendation#bc5162, com.oberon.fm.domain.MovieRecommendation#1b8ceab]
16:19:32.740 [http-nio-8080-exec-8] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Invoking afterPropertiesSet() on bean with name 'user/index'
16:19:32.740 [http-nio-8080-exec-8] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'org.springframework.transaction.config.internalTransactionAdvisor'
16:19:32.740 [http-nio-8080-exec-8] DEBUG o.s.web.servlet.DispatcherServlet - Rendering view [org.springframework.web.servlet.view.JstlView: name 'user/index'; URL [/pages/user/index.jsp]] in DispatcherServlet with name 'context'
16:19:32.740 [http-nio-8080-exec-8] DEBUG o.s.web.servlet.view.JstlView - Added model object 'user' of type [com.oberon.fm.domain.User] to request in view with name 'user/index'
16:19:32.740 [http-nio-8080-exec-8] DEBUG o.s.web.servlet.view.JstlView - Added model object 'recommendations' of type [java.util.ArrayList] to request in view with name 'user/index'
16:19:32.740 [http-nio-8080-exec-8] DEBUG o.s.web.servlet.view.JstlView - Added model object 'org.springframework.validation.BindingResult.user' of type [org.springframework.validation.BeanPropertyBindingResult] to request in view with name 'user/index'
16:19:32.740 [http-nio-8080-exec-8] DEBUG o.s.web.servlet.view.JstlView - Forwarding to resource [/pages/user/index.jsp] in InternalResourceView 'user/index'
16:19:33.838 [http-nio-8080-exec-8] DEBUG o.s.web.servlet.DispatcherServlet - Error rendering view [org.springframework.web.servlet.view.JstlView: name 'user/index'; URL [/pages/user/index.jsp]] in DispatcherServlet with name 'context'
org.apache.jasper.JasperException: An exception occurred processing JSP page /pages/user/index.jsp at line 86
83: <c:choose>
84: <c:when test="${not empty recommendations}">
85: <c:forEach items="${recommendations}" var="recommendation">
86: <c:set var="movie" value="${recommendation.movie}"/>
87: <c:set var="stars" value="${recommendation.rating}"/>
88: <li>
89: <h4> <a href="<c:url value="/movies/${movie.id}" />"><c:out value="${movie.title}"/>:
at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568) ~[jasper.jar:8.0.15]
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:470) ~[jasper.jar:8.0.15]
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396) ~[jasper.jar:8.0.15]
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340) ~[jasper.jar:8.0.15]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:725) [servlet-api.jar:na]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291) [catalina.jar:8.0.15]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [catalina.jar:8.0.15]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) [tomcat-websocket.jar:8.0.15]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) [catalina.jar:8.0.15]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [catalina.jar:8.0.15]
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:721) ~[catalina.jar:8.0.15]
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:466) ~[catalina.jar:8.0.15]
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:391) ~[catalina.jar:8.0.15]
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:318) ~[catalina.jar:8.0.15]
at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:168) ~[spring-webmvc-4.1.5.RELEASE.jar:4.1.5.RELEASE]
at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303) ~[spring-webmvc-4.1.5.RELEASE.jar:4.1.5.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1228) [spring-webmvc-4.1.5.RELEASE.jar:4.1.5.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1011) [spring-webmvc-4.1.5.RELEASE.jar:4.1.5.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:955) [spring-webmvc-4.1.5.RELEASE.jar:4.1.5.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877) [spring-webmvc-4.1.5.RELEASE.jar:4.1.5.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966) [spring-webmvc-4.1.5.RELEASE.jar:4.1.5.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857) [spring-webmvc-4.1.5.RELEASE.jar:4.1.5.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:618) [servlet-api.jar:na]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842) [spring-webmvc-4.1.5.RELEASE.jar:4.1.5.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:725) [servlet-api.jar:na]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291) [catalina.jar:8.0.15]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [catalina.jar:8.0.15]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) [tomcat-websocket.jar:8.0.15]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) [catalina.jar:8.0.15]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [catalina.jar:8.0.15]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) [spring-web-4.1.5.RELEASE.jar:4.1.5.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.1.5.RELEASE.jar:4.1.5.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) [catalina.jar:8.0.15]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [catalina.jar:8.0.15]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219) [catalina.jar:8.0.15]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) [catalina.jar:8.0.15]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501) [catalina.jar:8.0.15]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142) [catalina.jar:8.0.15]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) [catalina.jar:8.0.15]
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610) [catalina.jar:8.0.15]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) [catalina.jar:8.0.15]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:537) [catalina.jar:8.0.15]
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1085) [tomcat-coyote.jar:8.0.15]
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:658) [tomcat-coyote.jar:8.0.15]
at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222) [tomcat-coyote.jar:8.0.15]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1556) [tomcat-coyote.jar:8.0.15]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1513) [tomcat-coyote.jar:8.0.15]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_05]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_05]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-util.jar:8.0.15]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_05]
Caused by: org.apache.jasper.el.JspPropertyNotFoundException: /pages/user/index.jsp(86,26) '${recommendation.movie}' Property 'movie' not found on type com.oberon.fm.domain.MovieRecommendation
at org.apache.jasper.el.JspValueExpression.getValue(JspValueExpression.java:120) ~[jasper.jar:8.0.15]
at org.apache.jsp.pages.user.index_jsp._jspx_meth_c_005fset_005f3(index_jsp.java:879) ~[na:na]
at org.apache.jsp.pages.user.index_jsp._jspx_meth_c_005fforEach_005f2(index_jsp.java:818) ~[na:na]
at org.apache.jsp.pages.user.index_jsp._jspx_meth_c_005fwhen_005f2(index_jsp.java:782) ~[na:na]
at org.apache.jsp.pages.user.index_jsp._jspx_meth_c_005fchoose_005f2(index_jsp.java:746) ~[na:na]
at org.apache.jsp.pages.user.index_jsp._jspService(index_jsp.java:171) ~[na:na]
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) ~[jasper.jar:8.0.15]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:725) [servlet-api.jar:na]
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432) ~[jasper.jar:8.0.15]
... 49 common frames omitted
You need to have getters for jsp el expressions, it won't recognize public properties.
Change your MovieRecommendation class (and possibly others) to something like this:
#QueryResult
public class MovieRecommendation {
Movie movie;
int rating;
Movie getMovie() { .... }
int getRating() {....}

Spring tiles jsp table records from other class

I try to configure spring with tiles and create a website - one to mane relation -> Klient - Pobyt and got a question regarding configuration.
I have got a class Klient and a class Pobyt, I also set up a view, but I am getting a null pointer exception when using = ${klient.idKlienta} in order to connect a klient to a list of pobyt`s.
I am getting a org.postgresql.util.PSQLException:- Error in postgresSQL syntax.
Using a concrete value in sql works fine.
Any idea what is wrong?
Could yoy help?
Here is the .jsp:
<%#page language="Java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%#taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%#taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%#taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>
<html >
<head>
<title>Insert title here</title>
</head>
<body>
<sql:setDataSource var="postgres" driver="org.postgresql.Driver"
url="jdbc:postgresql://localhost:5432/MAS_PRO" user="postgres"
password="qwe" scope="session" />
<sql:query dataSource="${postgres}" var="result">
SELECT * from Pobyt
where idklienta=${klient.idKlienta} // when entering an existing id fe. 1 it works fine
</sql:query>
<table border="1" width="100%">
<tr>
<th>Id Pobytu</th>
<th>Data od</th>
<th>do</th>
<th>Id klienta</th>
</tr>
<c:forEach var="row" items="${result.rows}">
<tr>
<td><c:out value="${row.idpobytu}"/></td>
<td><c:out value="${row.datazameldowania}"/></td>
<td><c:out value="${row.datawymeldowania}"/></td>
<td><c:out value="${row.idklienta}" /></td>
</tr>
</c:forEach>
</table>
</body>
</html>
PobytBean and KlientBean:
public class PobytBean {
private Integer idPobytu;
private Date dataZameldowania;
private Date dataWymeldowania;
private Integer idKlienta;
public class KlientBean {
private Integer idKlienta;
private String imie;
private String nazwisko;
private String nrTelefonu;
private String eMail;
Klient and Pobyt
#Entity
#Table(name = "Klient")
public class Klient implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
#Id
#GeneratedValue
#Column(name="idKlienta")
private Integer idKlienta;
#Column(name = "imie")
private String imie;
#Column(name = "nazwisko")
private String nazwisko;
#Column(name = "nrTelefonu")
private String nrTelefonu;
#Column(name = "eMail")
private String eMail;
#Entity
#Table(name = "Pobyt")
public class Pobyt implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
#Id
#GeneratedValue
#Column(name = "idPobytu")
private Integer idPobytu;
#Column(name = "dataZameldowania")
#Temporal(TemporalType.DATE)
private Date dataZameldowania;
#Column(name = "dataWymeldowania")
#Temporal(TemporalType.DATE)
private Date dataWymeldowania;
#ManyToOne
#JoinColumn(name="idKlienta", insertable=false, updatable=false)
public Klient klient;
private Integer idKlienta;
Here is the .jsp from where I try to get to the concrete list of pobyts
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%# taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Pobyty</title>
</head>
<body>
<h1>Lista klientow</h1>
<c:if test="${!empty klienci}">
<table align="left" border="1">
<tr>
<th>Klient id</th>
<th>Imie</th>
<th>Nazwisko</th>
<th>Nr Telefonu</th>
<th>e-Mail</th>
<th>Akcja</th>
</tr>
<c:forEach items="${klienci}" var="klient">
<tr>
<td><c:out value="${klient.idKlienta}" /></td>
<td><c:out value="${klient.imie}" /></td>
<td><c:out value="${klient.nazwisko}" /></td>
<td><c:out value="${klient.nrTelefonu}" /></td>
<td><c:out value="${klient.eMail}" /></td>
<td>Otwórz</td>
</tr>
</c:forEach>
</table>
</c:if>
</body>
</html>
Update:
SEVERE: Servlet.service() for servlet jsp threw exception
org.postgresql.util.PSQLException: org.postgresql.util.psqlexception error syntax error at end of input
(Position 44)
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2101)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1834)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:255)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:510)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:386)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:271)
at org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.doEndTag(QueryTagSupport.java:224)
at org.apache.jsp.WEB_002dINF.views.openKlient_jsp._jspx_meth_sql_005fquery_005f0(openKlient_jsp.java:202)
at org.apache.jsp.WEB_002dINF.views.openKlient_jsp._jspService(openKlient_jsp.java:91)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:605)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:544)
at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:954)
at org.apache.jasper.runtime.PageContextImpl.doInclude(PageContextImpl.java:684)
at org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:678)
at org.apache.tiles.jsp.context.JspTilesRequestContext.include(JspTilesRequestContext.java:103)
at org.apache.tiles.jsp.context.JspTilesRequestContext.dispatch(JspTilesRequestContext.java:96)
at org.apache.tiles.renderer.impl.TemplateAttributeRenderer.write(TemplateAttributeRenderer.java:44)
at org.apache.tiles.renderer.impl.AbstractBaseAttributeRenderer.render(AbstractBaseAttributeRenderer.java:106)
at org.apache.tiles.renderer.impl.ChainedDelegateAttributeRenderer.write(ChainedDelegateAttributeRenderer.java:76)
at org.apache.tiles.renderer.impl.AbstractBaseAttributeRenderer.render(AbstractBaseAttributeRenderer.java:106)
at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:670)
at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:336)
at org.apache.tiles.template.InsertAttributeModel.renderAttribute(InsertAttributeModel.java:210)
at org.apache.tiles.template.InsertAttributeModel.end(InsertAttributeModel.java:126)
at org.apache.tiles.jsp.taglib.InsertAttributeTag.doTag(InsertAttributeTag.java:311)
at org.apache.jsp.WEB_002dINF.views.mainTemplate_jsp._jspx_meth_tiles_005finsertAttribute_005f3(mainTemplate_jsp.java:180)
at org.apache.jsp.WEB_002dINF.views.mainTemplate_jsp._jspService(mainTemplate_jsp.java:94)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:487)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:412)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:339)
at org.apache.tiles.servlet.context.ServletTilesRequestContext.forward(ServletTilesRequestContext.java:241)
at org.apache.tiles.servlet.context.ServletTilesRequestContext.dispatch(ServletTilesRequestContext.java:222)
at org.apache.tiles.renderer.impl.TemplateAttributeRenderer.write(TemplateAttributeRenderer.java:44)
at org.apache.tiles.renderer.impl.AbstractBaseAttributeRenderer.render(AbstractBaseAttributeRenderer.java:106)
at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:670)
at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:690)
at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:644)
at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:627)
at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:321)
at org.springframework.web.servlet.view.tiles2.TilesView.renderMergedOutputModel(TilesView.java:124)
at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1060)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:798)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:647)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:552)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:947)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1009)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
And the "server is complaining" about:
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.apache.tiles.impl.CannotRenderException: ServletException including path '/WEB-INF/views/mainTemplate.jsp'.
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:659)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:552)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
root cause
org.apache.tiles.impl.CannotRenderException: ServletException including path '/WEB-INF/views/mainTemplate.jsp'.
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:692)
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:644)
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:627)
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:321)
org.springframework.web.servlet.view.tiles2.TilesView.renderMergedOutputModel(TilesView.java:124)
org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1060)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:798)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:647)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:552)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
I tried to search for logs and what I have found is:
Tomcat log:
0:0:0:0:0:0:0:1 - - [22/Feb/2014:18:34:40 +0100] "GET /MAS_Koncowy/welcome.html HTTP/1.1" 200 1786
0:0:0:0:0:0:0:1 - - [22/Feb/2014:18:34:43 +0100] "GET /MAS_Koncowy/klienci.html HTTP/1.1" 200 2441
0:0:0:0:0:0:0:1 - - [22/Feb/2014:18:34:44 +0100] "GET /MAS_Koncowy/openKlient.html?id=1 HTTP/1.1" 500 17745
In Pg_log I have found what I`ve already posted:
2014-02-22 18:43:36 CET error syntax error at end of input (Position 44)
2014-02-22 18:43:36 CET Query:
SELECT * from Pobyt
where idKlienta =
So the problem is the idKlienta is not passed to the query? How can I solve it?

i18n issue using servlet 3 and spring 3.2.3

Im working with spring 3.2.3, servlet 3 and maven 3.1, so i'm trying to use i18n, but for some dark reason i can't start my app saying:
javax.servlet.ServletException: javax.servlet.jsp.JspTagException: No message found under code 'login.button.signin' for locale 'pt_BR'.
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:912)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:841)
but my default lang is "EN" and i have both properties with this message.
Code:
WebConfig.java
#Configuration
#EnableWebMvc
#ComponentScan(basePackages = { "com.codesenior.oaon.controller" })
public class WebConfig extends WebMvcConfigurerAdapter {
#Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
}
#Override
public void addInterceptors(InterceptorRegistry registry) {
LocaleChangeInterceptor localeChangeInterceptor = new LocaleChangeInterceptor();
localeChangeInterceptor.setParamName("lang");
registry.addInterceptor(localeChangeInterceptor);
}
#Bean
public LocaleResolver localeResolver() {
CookieLocaleResolver cookieLocaleResolver = new CookieLocaleResolver();
cookieLocaleResolver.setDefaultLocale(StringUtils.parseLocaleString("en"));
return cookieLocaleResolver;
}
#Bean
public MessageSource messageSource() {
ReloadableResourceBundleMessageSource source = new ReloadableResourceBundleMessageSource();
source.setBasename("classpath:messages");
source.setDefaultEncoding("UTF-8");
return source;
}
#Bean
public InternalResourceViewResolver templateResolver() {
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
resolver.setPrefix("/WEB-INF/pages/");
resolver.setSuffix(".jsp");
resolver.setCache(false);
return resolver;
}
index.jsp
<body>
<div class="container">
<div class="content">
<div class="row">
<span style="float: right">
en
|
pt
</span>
<div class="login-form">
<h2>Login</h2>
<form action="/login">
<fieldset>
<div class="clearfix">
<input id="username" type="text" placeholder="Username">
</div>
<div class="clearfix">
<input id="password" type="password" placeholder="Password">
</div>
<button class="btn btn-primary" onclick="return signin();" value="<spring:message code="login.button.signin"/>" ></button>
</fieldset>
</form>
</div>
</div>
</div>
</div> <!-- /container -->
</body>
messages (current path:src/main/resources)
messages_en.properties
login.label.username=Username
login.label.password=Password
login.button.signin=Signin
messages_pt.properties
login.label.username=Usuário
login.label.password=Senha
login.button.signin=Entrar
Since my default lang is EN, i don't know why it are asking for PT, although even if i ignore this point, i have messages_pt.properties that contains the correct message.
Full stacktrace:
2014-01-14 15:30:49 ERROR MessageTag:83 - No message found under code 'login.button.signin' for locale 'pt_BR'.
javax.servlet.jsp.JspTagException: No message found under code 'login.button.signin' for locale 'pt_BR'.
at org.springframework.web.servlet.tags.MessageTag.doStartTagInternal(MessageTag.java:185)
at org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:80)
at org.apache.jsp.WEB_002dINF.pages.index_jsp._jspx_meth_spring_005fmessage_005f0(index_jsp.java:191)
at org.apache.jsp.WEB_002dINF.pages.index_jsp._jspService(index_jsp.java:155)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Jan 14, 2014 3:30:49 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [jsp] in context with path [/checkpointweb] threw exception [An exception occurred processing JSP page /WEB-INF/pages/index.jsp at line 86
83: <div class="clearfix">
84: <input id="password" type="password" placeholder="Password">
85: </div>
86: <button class="btn btn-primary" onclick="return signin();" value="<spring:message code="login.button.signin"/>" ></button>
87: </fieldset>
88: </form>
89: </div>
Stacktrace:] with root cause
javax.servlet.jsp.JspTagException: No message found under code 'login.button.signin' for locale 'pt_BR'.
at org.springframework.web.servlet.tags.MessageTag.doStartTagInternal(MessageTag.java:185)
at org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:80)
at org.apache.jsp.WEB_002dINF.pages.index_jsp._jspx_meth_spring_005fmessage_005f0(index_jsp.java:191)
at org.apache.jsp.WEB_002dINF.pages.index_jsp._jspService(index_jsp.java:155)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)

CommandButton don't work with Ajax and Param - JSF 2.0

I was trying to implement a command button with f:ajax and f:param in my project, but I'm not being successfull.
I have one Bean called "disciplinaMBean" that have a #SessionScoped. In the respective JSF (let's say, index.xhtml) I have one p:dataTable showing some disciplines (this is what "disciplina" means in English :P). When I click in one row, a modal is opened showing to user options to "edit" or "delete" discipline. The selected object is stored in "disciplinaSelecionada" by selection attribute of Primefaces dataTable. See by yourself:
The code of this modal is inside "edit.xhtml" file. See the code below:
<h:form>
<label for="nome">Nome:</label>
<h:inputText styleClass="form-control adicionar" id="nome"
value="#{disciplinaMBean.disciplinaSelecionada.nome}">
</h:inputText>
<h:commandButton id="excluir" styleClass="btn btn-md btn-danger pull-left" value="Excluir" >
<f:param name="idDisciplina" value="#{disciplinaSelecionada.id}" />
<f:ajax event="click" listener="#{disciplinaMBean.deletar}" />
</h:commandButton>
</h:form>
And the method "Deletar" (means delete) in disciplineMBean:
public void deletar(){
String param1 = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("idDisciplina");
System.out.println("Disciplina deletada: " + param1);
int idDisciplina = Integer.parseInt(param1);
controleDisciplina.remover(idDisciplina);
}
I know I called the method because the log of console, but I can't delete the discipline because I have one error (a empty string is stored in "idDisciplina" param).
Following is the error:
Disciplina deletada:
Nov 01, 2013 10:26:31 PM com.sun.faces.lifecycle.InvokeApplicationPhase execute
WARNING: /edit.xhtml #31,72 listener="#{disciplinaMBean.deletar}": java.lang.NumberFormatException: For input string: ""
javax.el.ELException: /edit.xhtml #31,72 listener="#{disciplinaMBean.deletar}": java.lang.NumberFormatException: For input string: ""
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:111)
at com.sun.faces.facelets.tag.jsf.core.AjaxBehaviorListenerImpl.processAjaxBehavior(AjaxHandler.java:447)
at javax.faces.event.AjaxBehaviorEvent.processListener(AjaxBehaviorEvent.java:113)
at javax.faces.component.behavior.BehaviorBase.broadcast(BehaviorBase.java:106)
at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:760)
at javax.faces.component.UICommand.broadcast(UICommand.java:300)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:791)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1256)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:724)
Caused by: java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:592)
at java.lang.Integer.parseInt(Integer.java:615)
at mbeans.DisciplinaMBean.deletar(DisciplinaMBean.java:143)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:491)
at org.apache.el.parser.AstValue.invoke(AstValue.java:262)
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
... 27 more
What can I do to solve this issue?
If you have EL 2.2, you can do it like this (assuming disciplinaSelecionada.id is an int)
<h:commandButton id="excluir" action="#{disciplinaMBean.deletar(disciplinaSelecionada.id)}" styleClass="btn btn-md btn-danger pull-left" value="Excluir" />
....
public void deletar(int idDisciplina)
{
System.out.println("Disciplina deletada: " + idDisciplina);
controleDisciplina.remover(idDisciplina);
}

Resources