Spring Roo 1.3.2 を使用して既存の DB を指すようにリバース エンジニアリングした、動作中の CRUD アプリケーションがあります。
また、ドメイン クラスにいくつかのファインダー メソッドを追加し、それに応じて自動生成されたコントローラーを変更することもできました。ただし、UI を変更して field:input 要素を表示して検索することはできません。
list.jspx
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<div xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:form="urn:jsptagdir:/WEB-INF/tags/form"
xmlns:page="urn:jsptagdir:/WEB-INF/tags/form"
xmlns:field="urn:jsptagdir:/WEB-INF/tags/form/fields"
xmlns:table="urn:jsptagdir:/WEB-INF/tags/form/fields"
version="2.0">
<jsp:directive.page contentType="text/html;charset=UTF-8"/>
<jsp:output omit-xml-declaration="yes"/>
<!-- ADDED THIS FOR INTEGRATING WITH FINDER -->
<form:find finderName="findDimDataCentersByDataCenterDescriptionLike" id="ff_com_ebayenterprise_publicapi_events_domain_DimDataCenter" path="/dimdatacenters/find" z="">
<field:input field="dataCenterDescription" id="c_com_ebayenterprise_publicapi_events_domain_DimDataCenter_dataCenterDescription" required="true" z="3TpKuzI7g7HD3fPDUeHe2L1Vfp8="/>
</form:find>
<!-- ADDED ABOVE BLOCK FOR INTEGRATING WITH FINDER -->
<page:list id="pl_com_ebayenterprise_publicapi_events_domain_DimDataCenter" items="${dimdatacenters}" z="MktsGGofWG5TPMqQURfs27lkSUY=">
<table:table data="${dimdatacenters}" id="l_com_ebayenterprise_publicapi_events_domain_DimDataCenter" path="/dimdatacenters" typeIdFieldName="dataCenterName" z="fknzYfQDGmVcfHQFqvNWldG6TMQ=">
<table:column id="c_com_ebayenterprise_publicapi_events_domain_DimDataCenter_dataCenterDescription" property="dataCenterDescription" z="v1HGoxfLod4aDKgr9CDZmBG3T1s="/>
<table:column calendar="true" dateTimePattern="${dimDataCenter_createtimestamp_date_format}" id="c_com_ebayenterprise_publicapi_events_domain_DimDataCenter_createTimestamp" property="createTimestamp" z="H8e9z7SBQDscPrc7GmSsgl8MT+U="/>
<table:column calendar="true" dateTimePattern="${dimDataCenter_updatetimestamp_date_format}" id="c_com_ebayenterprise_publicapi_events_domain_DimDataCenter_updateTimestamp" property="updateTimestamp" z="DzEUyaLfFw9EYNCZ5fs7IS23FSg="/>
</table:table>
</page:list>
</div>
DimDataCenterController.java
@RequestMapping("/dimdatacenters")
@Controller
@RooWebScaffold(path = "dimdatacenters", formBackingObject = DimDataCenter.class)
public class DimDataCenterController {
@RequestMapping(value = "/find", produces = "text/html")
public String find(
@RequestParam(value = "find", required = true) String finder,
@RequestParam(value = "filter", required = true) String filter,
Model uiModel) {
if ("findDimDataCentersByDataCenterDescriptionLike".equals(finder)) {
uiModel.addAttribute("dimdatacenters", DimDataCenter.findDimDataCentersByDataCenterDescriptionLike(filter).getResultList());
uiModel.addAttribute("filter", filter);
return "dimdatacenters/list";
} else {
return "redirect:/dimdatacenters";
}
}
.......
}
DimDataCenter.java
@Table(schema = "PUBAPI_EVNTPRVSN_SVC", name = "DIM_DATA_CENTER")
@Entity
@Configurable
@RooJavaBean
@RooDbManaged(automaticallyDelete = true)
@RooToString(excludeFields = { "brokerConnections" })
@RooJpaActiveRecord(versionField = "", table = "DIM_DATA_CENTER", schema = "PUBAPI_EVNTPRVSN_SVC", finders = { "findDimDataCentersByDataCenterDescriptionLike" })
public class DimDataCenter {
public static TypedQuery<DimDataCenter> findDimDataCentersByDataCenterDescriptionLike(String dataCenterDescription) {
if (dataCenterDescription == null || dataCenterDescription.length() == 0) throw new IllegalArgumentException("The dataCenterDescription argument is required");
dataCenterDescription = dataCenterDescription.replace('*', '%');
if (dataCenterDescription.charAt(0) != '%') {
dataCenterDescription = "%" + dataCenterDescription;
}
if (dataCenterDescription.charAt(dataCenterDescription.length() - 1) != '%') {
dataCenterDescription = dataCenterDescription + "%";
}
EntityManager em = DimDataCenter.entityManager();
TypedQuery<DimDataCenter> q = em.createQuery("SELECT o FROM DimDataCenter AS o WHERE LOWER(o.dataCenterDescription) LIKE LOWER(:dataCenterDescription)", DimDataCenter.class);
q.setParameter("dataCenterDescription", dataCenterDescription);
return q;
}
......
}
ページ読み込み中の例外
29-Sep-2017 15:29:21.385 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 15709 ms
2017-09-29 15:29:44,223 [http-nio-8080-exec-7] ERROR org.springframework.web.servlet.tags.form.InputTag - Neither BindingResult nor plain target object for bean name 'command' available as request attribute
java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'command' available as request attribute
at org.springframework.web.servlet.support.BindStatus.<init>(BindStatus.java:144)
at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getBindStatus(AbstractDataBoundFormElementTag.java:179)
at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getPropertyPath(AbstractDataBoundFormElementTag.java:199)
at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getName(AbstractDataBoundFormElementTag.java:165)
at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.writeDefaultAttributes(AbstractDataBoundFormElementTag.java:128)
at org.springframework.web.servlet.tags.form.AbstractHtmlElementTag.writeDefaultAttributes(AbstractHtmlElementTag.java:421)
at org.springframework.web.servlet.tags.form.InputTag.writeTagContent(InputTag.java:142)
at org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(AbstractFormTag.java:103)
at org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:80)
at org.apache.jsp.tag.web.form.fields.input_tagx._jspx_meth_form_005finput_005f0(input_tagx.java:1335)
at org.apache.jsp.tag.web.form.fields.input_tagx._jspx_meth_c_005fotherwise_005f3(input_tagx.java:1303)
at org.apache.jsp.tag.web.form.fields.input_tagx._jspx_meth_c_005fchoose_005f3(input_tagx.java:1219)
at org.apache.jsp.tag.web.form.fields.input_tagx.doTag(input_tagx.java:431)
at org.apache.jsp.WEB_002dINF.views.dimdatacenters.list_jspx._jspx_meth_field_005finput_005f0(list_jspx.java:191)
at org.apache.jsp.WEB_002dINF.views.dimdatacenters.list_jspx.access$0(list_jspx.java:174)
at org.apache.jsp.WEB_002dINF.views.dimdatacenters.list_jspx$Helper.invoke0(list_jspx.java:323)
at org.apache.jsp.WEB_002dINF.views.dimdatacenters.list_jspx$Helper.invoke(list_jspx.java:359)
at org.apache.jsp.tag.web.form.find_tagx._jspx_meth_form_005fform_005f0(find_tagx.java:550)
at org.apache.jsp.tag.web.form.find_tagx.access$1(find_tagx.java:528)
at org.apache.jsp.tag.web.form.find_tagx$Helper.invoke0(find_tagx.java:625)
at org.apache.jsp.tag.web.form.find_tagx$Helper.invoke(find_tagx.java:643)
at org.apache.jsp.tag.web.util.panel_tagx._jspx_meth_c_005fif_005f0(panel_tagx.java:230)
at org.apache.jsp.tag.web.util.panel_tagx.doTag(panel_tagx.java:176)
at org.apache.jsp.tag.web.form.find_tagx._jspx_meth_util_005fpanel_005f0(find_tagx.java:495)
at org.apache.jsp.tag.web.form.find_tagx._jspx_meth_c_005fif_005f0(find_tagx.java:270)
at org.apache.jsp.tag.web.form.find_tagx.doTag(find_tagx.java:236)
at org.apache.jsp.WEB_002dINF.views.dimdatacenters.list_jspx._jspx_meth_form_005ffind_005f0(list_jspx.java:169)
at org.apache.jsp.WEB_002dINF.views.dimdatacenters.list_jspx._jspService(list_jspx.java:128)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:720)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:584)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:523)
at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:934)
at org.apache.jasper.runtime.PageContextImpl.doInclude(PageContextImpl.java:679)
at org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:673)
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.layouts.default_jspx._jspx_meth_tiles_005finsertAttribute_005f2(default_jspx.java:294)
at org.apache.jsp.WEB_002dINF.layouts.default_jspx._jspService(default_jspx.java:150)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:720)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:466)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:391)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:318)
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:264)
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1208)
at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:992)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:939)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:953)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:844)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:829)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:154)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:199)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:110)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:50)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:343)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:180)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:217)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:673)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)