StrutsMailReader

HomePage | RecentChanges | Preferences

Trouble with Validation in StrutsMailReader

20050914 built locally and deployed

INFO: Deploying web application archive struts-mailreader.war
Sep 14, 2005 3:33:34 PM org.apache.struts.action.ActionServlet initChain
INFO: Loading chain catalog from jar:file:/C:/java/jakarta-tomcat-5.5.9/work/Cat
alina/localhost/struts-mailreader/WEB-INF/lib/struts-core-1.3.0-dev.jar!/org/apa
che/struts/chain/chain-config.xml
Sep 14, 2005 3:33:35 PM org.apache.struts.apps.mailreader.plugin.MemoryDatabaseP
lugIn init
INFO: Initializing memory database plug in from '/WEB-INF/database.xml'
Sep 14, 2005 3:33:35 PM org.apache.struts.validator.ValidatorPlugIn initResource
s
INFO: Loading validation rules file from '/WEB-INF/validator-rules.xml'
Sep 14, 2005 3:33:35 PM org.apache.struts.validator.ValidatorPlugIn initResource
s
INFO: Loading validation rules file from '/WEB-INF/validation.xml'
Sep 14, 2005 3:33:35 PM org.apache.struts.action.ActionServlet init
SEVERE: Unable to initialize Struts ActionServlet due to an unexpected exception
 or error thrown, so marking the servlet as unavailable.  Most likely, this is d
ue to an incorrect or missing library dependency.
java.lang.NoSuchMethodError: org.apache.commons.validator.ValidatorResources.<in
it>([Ljava/lang/String;)V
        at org.apache.struts.validator.ValidatorPlugIn.initResources(ValidatorPl
ugIn.java:237)
        at org.apache.struts.validator.ValidatorPlugIn.init(ValidatorPlugIn.java
:163)
        at org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServle
t.java:914)
        at org.apache.struts.action.ActionServlet.init(ActionServlet.java:343)
        at javax.servlet.GenericServlet.init(GenericServlet.java:211)
        at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.
java:1091)
        at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:92
5)
        at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContex
t.java:3857)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4
118)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
.java:759)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:73
9)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)

        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:788)

        at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:677
)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:473
)
        at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1165)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java
:293)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl
eSupport.java:119)
        at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBas
e.java:1304)
        at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.p
rocessChildren(ContainerBase.java:1568)
        at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.p
rocessChildren(ContainerBase.java:1577)
        at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.r
un(ContainerBase.java:1557)
        at java.lang.Thread.run(Thread.java:566)

Adding the DisplayTag taglib to the Struts MailReader example webapp


Changed Registration.jsp:
<%@ taglib uri="http://displaytag.sf.net" prefix="display" %>

<display:table name="sessionScope.user.subscriptions" pagesize="10">
	<display:column property="host" title="Host Name" />
	<display:column property="username" title="User Name" />
	<display:column property="type" title="Server<br/>Type"/>
	<display:column property="autoConnect" title="Auto" />
    <display:column title="Action">
       <html:link action="/EditSubscription?action=Delete" paramId="username"
          paramName="RegistrationForm" paramProperty="username">
          <bean:message key="registration.deleteSubscription"/>
       </html:link>
    </display:column>
</display:table>

The Edit and Delete links originally used this:

      <app:linkSubscription page="/EditSubscription.do?action=Delete">
        <bean:message key="registration.deleteSubscription"/>
      </app:linkSubscription>
which expects to be nested in a <logic:iterate> tag. At this point we have the 'action' and 'username' but we're missing the 'host' attribute for the links.

The links are supposed to look like this:

   <a href="/struts-mailreader/EditSubscription.do?action=Delete&username=user&host=mail.yahoo.com">
      Delete
   </a>

But instead we only have this:

   <a href="/struts-mailreader/EditSubscription.do?action=Delete&username=user">Delete</a>


Time to switch to JSTL and the EL version of DisplayTag, then...

and switched to the EL tld plus JSTL Core tags:

  <%@ taglib uri="http://displaytag.sf.net/el"        prefix="display" %>
  <%@ taglib uri="http://java.sun.com/jstl/core"      prefix="c" %>


<!-- With JSTL for the URLs -->
<display:table name="sessionScope.user.subscriptions" pagesize="10" uid="sub">
	<display:column property="host" title="Host Name" />
	<display:column property="username" title="User Name" />
	<display:column property="type" title="Server<br/>Type"/>
	<display:column property="autoConnect" title="Auto" />
    <display:column title="Action">
       <c:url value="/EditSubscription.do" var="deleteURL">
         <c:param name="action" value="Delete"/>
         <c:param name="username" value="${sub.username}"/>
         <c:param name="host" value="${sub.host}"/>
       </c:url>
       <a href="<c:out value='${deleteURL}'/>">
          <bean:message key="registration.deleteSubscription"/>
       </a>
       <c:url value="/EditSubscription.do" var="editURL">
         <c:param name="action" value="Edit"/>
         <c:param name="username" value="${sub.username}"/>
         <c:param name="host" value="${sub.host}"/>
       </c:url>
       <a href="<c:out value='${editURL}'/>">
          <bean:message key="registration.editSubscription"/>
       </a>
       </display:column>
</display:table>

Questions

  1. Can the column title come from ApplicationResources.properties ?

Problems

  1. If the contents of a paged table include a form, how do we make the 'next' and 'prior' links submit that form?
  2. If that form contains checkboxes, how do we 'reset' only the checkboxes that would have been on that page?


Paging

Added several more lines to $TOMCAT_HOME/webapps/struts-mailreader/WEB-INF/database.xml and changed the 'size' of the table to 5 so we'll get some pages. First page displayed fine, but clicking a different page number resulted in:

     An unexpected error has occured
     No bean found under attribute key RegistrationForm

Need to set the requestURI attribute of the table tag to EditRegistration?.do so the display taglib can figure out the right link.

<display:table name="sessionScope.user.subscriptions" pagesize="5" 
               requestURI="EditRegistration.do" uid="sub">
	<display:column property="host" title="Host Name" />
	<display:column property="username" title="User Name" />
	<display:column property="type" title="Server<br/>Type"/>
	<display:column property="autoConnect" title="Auto" />
    <display:column title="Action">
       <c:url value="/EditSubscription.do" var="deleteURL">
         <c:param name="action" value="Delete"/>
         <c:param name="username" value="${sub.username}"/>
         <c:param name="host" value="${sub.host}"/>
       </c:url>
       <a href="<c:out value='${deleteURL}'/>">
          <bean:message key="registration.deleteSubscription"/>
       </a>
       <c:url value="/EditSubscription.do" var="editURL">
         <c:param name="action" value="Edit"/>
         <c:param name="username" value="${sub.username}"/>
         <c:param name="host" value="${sub.host}"/>
       </c:url>
       <a href="<c:out value='${editURL}'/>">
          <bean:message key="registration.editSubscription"/>
       </a>
       </display:column>
     </display:table>


Making it submit a form on next/prior or clicking a page number


HomePage | RecentChanges | Preferences
This page is read-only | View other revisions
Last edited September 14, 2005 3:36 pm by WendySmoak (diff)
Search: