2 Replies Latest reply on Dec 18, 2006 11:59 AM by Gavin King

    Seam/JSF thinks action method to be property...

    Markus Dahm Novice

      Hi,

      I've got a list of data which I want to be able to apply filters to. That is,
      I put a combobox on top with a submit button. This shall render the list
      using a new query:

      <?xml version="1.0" encoding="ISO-8859-1" ?>
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:c="http://java.sun.com/jstl/core"
       xmlns:s="http://jboss.com/products/seam/taglib" xmlns:t="http://myfaces.apache.org/tomahawk" lang="de" xml:lang="de">
      
       <head>
       <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
       <title>Abrechnung Integrierte Versorgung</title>
       <link href="ingver.css" rel="stylesheet" type="text/css"/>
       </head>
      
       <body>
       <ui:composition template="/includes/template.xhtml">
       <ui:param name="title" value="Liste aller Verträge"/>
       <ui:define name="logo">
       <ui:include src="/includes/header.xhtml"/>
       </ui:define>
       <ui:define name="links">
       <ui:include src="/includes/navigation.xhtml"/>
       </ui:define>
      
       <ui:define name="inhalt">
       <f:view>
       <h:form>
       <h:selectOneMenu value="#{listVertraege.vertragsFilter}" converter="#{vertragsFilterConverter}">
       <f:selectItems value="#{vertragsFilterConverter.vertragsFilter}"/>
       </h:selectOneMenu>
       <!--h:commandButton type="submit" action="#{listVertraege.filter}" value="Filtern"/-->
       <s:link value="Filtern" action="#{listVertraege.filter}" linkStyle="button"/>
       </h:form>
       </f:view>
       <f:view>
       <h:form>
       <h:outputText value="Keine Verträge vorhanden" rendered="#{vertraege.rowCount==0}"/>
       <h:dataTable var="v" value="#{vertraege}" rows="5" rendered="#{vertraege.rowCount>0}"
       id="vertraglist">
       <h:column>
       <f:facet name="header">
       <h:outputText value="Vertragskurzname"/>
       </f:facet>
       <s:link value="#{v.name}" action="#{listVertraege.select}"/>
       </h:column>
       <h:column>
       <f:facet name="header">
       <h:outputText value="Vertragsbeginn"/>
       </f:facet>
       <h:outputText value="#{v.vertragsBeginn}">
       <f:convertDateTime pattern="dd.MM.yyyy"/>
       </h:outputText>
       </h:column>
       <h:column>
       <f:facet name="header">
       <h:outputText value="Vertragsende"/>
       </f:facet>
       <h:outputText value="#{v.vertragsEnde}">
       <f:convertDateTime pattern="dd.MM.yyyy"/>
       </h:outputText>
       </h:column>
       <h:column>
       <s:link value="Editieren" action="#{listVertraege.edit}" linkStyle="button"/>
       </h:column>
       <h:column>
       <s:link value="Beenden" action="#{listVertraege.end}" linkStyle="button"
       onclick="javascript:return confirm('Wollen Sie diesen Vertrag wirklich beenden?');"/>
       </h:column>
       <!--h:column>
       <s:link value="Löschen" action="#{listVertraege.delete}" linkStyle="button"
       onclick="return confirm('Wollen Sie diesen Vertrag wirklich löschen?');"/>
       </h:column-->
       </h:dataTable>
      
       <t:dataScroller for="vertraglist" id="scroller" fastStep="3" pageIndexVar="indexVar"
       pageCountVar="countVar">
       <f:facet name="first"> Erster </f:facet>
       <f:facet name="previous">
       <
       </f:facet>
       <f:facet name="next">
       >
       </f:facet>
       <f:facet name="last"> Letzter </f:facet>
       <f:facet name="fastforward">
       >>
       </f:facet>
       <f:facet name="fastrewind">
       <<
       </f:facet>
       </t:dataScroller>
       <hr/>
      
       <h3>
       <h:outputText value="#{vertrag.name}"/></h3>
       <div>
       <h:outputText value="#{vertrag.beschreibung}"/>
       </div>
       <div><b>Vertragspartner:</b>
       <h:outputText value="#{vertrag.vertragspartner}"/>
       </div>
       <br></br>
       <div><b>Patienten:</b>
       <h:outputText value="#{vertrag.patienten}"/>
       </div>
       </h:form>
       </f:view>
       <ui:include src="/includes/footer.xhtml"/>
       </ui:define>
       </ui:composition>
       </body>
      </html>
      
      


      The interesting part is in the first <h:form>.
      The bean looks like this:

      @Stateful
      @Scope(ScopeType.SESSION)
      @Name("listVertraege")
      @Interceptors(SeamInterceptor.class)
      public class ListVertragActionBean implements ListVertragAction {
       private static final Category _logger = Logger.getInstance(ListVertragActionBean.class);
       private static final long serialVersionUID = 1L;
      
       @DataModel(value = "vertraege")
       private List<Vertrag> _vertraege;
      
       @Out(required = false, value = "vertrag")
       @DataModelSelection
       private Vertrag _vertrag;
      
       @SuppressWarnings("unused")
       @Out(value = "vertragReadOnly", required = false)
       private Boolean _vertragReadOnly;
      
       @PersistenceContext(type = EXTENDED)
       private EntityManager _em;
      
       private VertragsFilter _vertragsFilter = new VertragsFilter(VertragsFilter.ALLE);
      
       @SuppressWarnings("unchecked")
       @Factory("vertraege")
       public void findVertraege() {
      // TODO: Use chosen filter
       _vertraege = _em.createQuery("FROM Vertrag v ORDER BY v.vertragsBeginn").getResultList();
       }
      
       public String select() {
       return "selected";
       }
      
       public String delete() {
       _logger.debug("Löschen des Vertrags: " + _vertrag);
       _vertrag.removeAllVertragspartner();
       _vertrag.removeAllPatient();
       _vertraege.remove(_vertrag);entfernen
       _em.remove(_vertrag);
       _vertrag = null;
       return "deleted";
       }
      
       public String edit() {
      
       return rereadAndEdit(false);
       }
      
       public String end() {
      
       return rereadAndEdit(true);
       }
      
       private String rereadAndEdit(boolean readonly) {
       _vertragReadOnly = readonly;
       _em.refresh(_vertrag);
      
       return "editVertrag";
       }
      
       public VertragsFilter getVertragsFilter() {
       _logger.warn("getVertragsFilter: " + _vertragsFilter);
       return _vertragsFilter;
       }
      
       public void setVertragsFilter(VertragsFilter vertragsFilter) {
       _logger.warn("setVertragsFilter: " + vertragsFilter);
       _vertragsFilter = vertragsFilter;
       }
      
       public String filter() {
       _logger.warn("filter: " + _vertragsFilter);
       return "hallo";
       }
      
       @Remove
       @Destroy
       public void destroy() {
       _logger.debug("Bean wird entfernt: " + _vertrag);
       }
      }
      


      But this gives me the following exception:

      
      javax.el.PropertyNotFoundException: Bean: $Proxy609, property: filter
       at com.sun.facelets.el.LegacyELContext$LegacyELResolver.getValue(LegacyELContext.java:146)
       at com.sun.el.parser.AstValue.getValue(AstValue.java:117)
       at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:192)
       at com.sun.facelets.el.ELText$ELTextVariable.toString(ELText.java:174)
       at com.sun.facelets.el.ELText$ELTextComposite.toString(ELText.java:115)
       at com.sun.facelets.compiler.CommentInstruction.write(CommentInstruction.java:38)
       at com.sun.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:39)
       at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:232)
       at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:239)
       at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:239)
       at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:554)
       at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:384)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:138)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:144)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.seam.servlet.SeamRedirectFilter.doFilter(SeamRedirectFilter.java:30)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
       at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
       at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
       at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
       at java.lang.Thread.run(Thread.java:595)
      14:29:52,109 ERROR [[Faces Servlet]] Servlet.service() for servlet Faces Servlet threw exception
      javax.el.PropertyNotFoundException: Bean: $Proxy609, property: filter
       at com.sun.facelets.el.LegacyELContext$LegacyELResolver.getValue(LegacyELContext.java:146)
       at com.sun.el.parser.AstValue.getValue(AstValue.java:117)
       at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:192)
       at com.sun.facelets.el.ELText$ELTextVariable.toString(ELText.java:174)
       at com.sun.facelets.el.ELText$ELTextComposite.toString(ELText.java:115)
       at com.sun.facelets.compiler.CommentInstruction.write(CommentInstruction.java:38)
       at com.sun.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:39)
       at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:232)
       at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:239)
       at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:239)
       at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:554)
       at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:384)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:138)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:144)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.seam.servlet.SeamRedirectFilter.doFilter(SeamRedirectFilter.java:30)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
       at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
       at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
       at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
       at java.lang.Thread.run(Thread.java:595)
      



      Why does he possibly think the "filter" is property? I understand the he
      wants to call a method getFilter() and there is none. But why is that?
      I have seen similar code in the examples and it works.
      I tried to use just one form or commandButton, but that doesn't work either.


      Puzzled
      Markus