Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Tomcat - JSP/Servlet container
Struts - A MVC web framework
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
JSP - A mailing list about Java Server Pages specification and reference
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Oracle Connection Pooling in 3 2 2
Servlet : Session invalidate
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Tomcat and webapplication specific java library path
Running a Simple JMS Example
Mapping in workers2 properties
org apache jasper JasperException
Cannot find message resources under key org apache struts action
   MESSAGE
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
url string for connecting jboss to oracle
Value attribute of <html:checkbox
javax servlet ServletException: BeanUtils populate
HTTP Status 404 The requested resource is not available
5 0 18: Windows XP Pro vs Windows 2000
 
Struts validation (still) (again!) (ARRGH!)

Struts validation (still) (again!) (ARRGH!)

2007-01-05       - By Peter L. Berghold

 Back
Reply:     1     2     3  

-- --BEGIN PGP SIGNED MESSAGE-- --
Hash: SHA1

OK,

I've been hacking around some more on this validation stuff and while
some of the suggestions I've been given have been a HUGE help I'm still
stuck.

Re-distilling the problem a bit I think I may have stumbled on something
but I'm not quite sure what to make of it.

Here are the ApplicationResources I have defined:

# Resources for parameter 'org.bcdc.struts.ApplicationResources'
# Project P/www.bayshoredogclub.org

label.from_rq=Your Email address
label.subject_rq=Subject
label.body_rq=A body of message text

Fairly simple... or so I'd think...

Here is where the resource file is referenced in the struts-config.xml
file.

<message-resources parameter="org.bcdc.struts.ApplicationResources" />

so far so good, I look in the WEB-INF/classes/... tree and find the file
where I think it should belong under
org/bcdc/struts/ApplicationResources.properties

Awwright. Now I look at my .jsp form and here it is in its entirety.

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8 (See http://UTF-8.ora-code.com)"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>





<html:form action="/actions/public/system/sendEmail" method="POST"
onsubmit="return validateSendEmailForm(this);">
<html:javascript formName="sendEmailForm"/>
  <p>
    Use this form to send an email. All fields are considered mandatory.
    Email addresses will be checked for validity.
  </p>
  <p>
    Please be sure to include your real name in the body of the message to
    avoid confusion on the part of the email recipient
  </p>
  <p style="border: 1px; color: red; ">
    <html:errors />

  </p>
  <hr>
  <table width="100%">
    <tr height="30">
      <td width="30%" align="right">
        From:
        <br>
        (Your email address)
      </td>
      <td>
        <html:text property="from_rq" size="40" maxlength="80" />
        <br>
        <html:errors property="label.from_rq" />
      </td>
    </tr>
    <tr height="30">
      <td width="30%" align="right">
        Subject:
      </td>
      <td>
        <html:text property="subject_rq" size="40" maxlength="72" />
        <br>
        <html:errors property="subject_rq" />
      </td>
    </tr>
    <tr>
      <td width="30%" align="right">
        Message body:
      </td>
      <td>
        <html:textarea property="body_rq" rows="10" cols="40" />
        <br>
        <html:errors property="body_rq" />
      </td>
    </tr>
    <tr>
      <td colspan="2">
        <table width="100%">
          <tr>
            <td width="33%">
           
              <html:cancel value="abort" property="action_rq" />
            </td>
            <td width="34%">
              &nbsp;
            </td>
            <td>
              <html:submit value="Send" property="action_rq"></html:submit>
            </td>
          </tr>
        </table>
      </td>
    </tr>
  </table>

</html:form>

Here's the input form being described in struts-config.xml

<form-bean name="sendEmailForm"
      type="org.bcdc.struts.form.SendEmailForm" />
and the associated action
<action
     attribute="sendEmailForm"
     input=".public.email.send"
     name="sendEmailForm"
     path="/actions/public/system/sendEmail"
     scope="request"
     validate="yes"
     type="org.bcdc.struts.action.SendEmailAction">
     <forward name="class_detail" path="/actions/public/class/detail.do" />
     <forward name="failure" path="/actions/public/sendEmail.do" />
   </action>

Here is the validation formset entry for this form:

<form name="sendEmailForm">
    <field property="from_rq" depends="required,email">
      <arg0 key="label.from_rq"/>
    </field>
    <field property="subject_rq" depends="required">
      <arg0 key="label.subject_rq"/>
     
    </field>
    <field property="body_rq" depends="required">
      <arg0 key="label.body_rq"/>
    </field>
 </form>


Now... in the end I don't want to use Javascript for my validation, I'd
like to be able to do all this server side.  However I used the
JavaScript stuff just to figure out what is going on.

When the form is submitted completely blank (which should generate an
error.. and it does) I get a popup with NOTHING IN IT but an yellow
exclamation mark.

The conclusion I'm drawing is that the validation framework is for some
unknown reason not finding the resource file.  Was there something the
the validation.xml file that was supposed to point to this file or
should it have picked it up on its own?

Someone suggested I use a set of tags to try in invoke the message
"manually" but that crashed the app so I'm guessing I'm on the right
track...


- --
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Peter L. Berghold                                     Peter@(protected)
"Those who fail to learn from history are condemned to repeat it."
AIM: redcowdawg        Yahoo IM: blue_cowdawg              ICQ: 11455958
-- --BEGIN PGP SIGNATURE-- --
Version: GnuPG v1.2.6 (GNU/Linux)
Comment: Using GnuPG with Red Hat - http://enigmail.mozdev.org

iD8DBQFFnt9wUM9/01RIhaARAifqAKCItwt9x6dhOoouKl1DJg/LQkmrKACgyS8l
wQ2HZGnpgzlGXqTSwOHycWk=
=dICY
-- --END PGP SIGNATURE-- --


-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.