struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter L. Berghold" <Pe...@berghold.net>
Subject Struts validation (still) (again!) (ARRGH!)
Date Fri, 05 Jan 2007 23:29:53 GMT
-----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"%>
<%@ 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@Berghold.Net
"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-----


Mime
View raw message