Re: img vs. html:img onclick result

2004-11-10 Thread Ben Anderson
Lori,
notice I took this to the struts list.  The struts tags don't support
runtime expressions.  There is a subset of struts tags that supports
EL (expression language).  You might try the following approach:

c_rt:set var=pathParam value=%= pathParm %/
html-el:img ... onclick=${pathParam}/

However, it'd be even better if you didn't need the first line.  There
are times when scriplet expressions must be used (static variables),
but you should try to avoid them when you can.

-Ben

On Wed, 10 Nov 2004 11:10:48 -0800, Cook, Lori A [EMAIL PROTECTED] wrote:
 I am experiencing difficulty using tag libraries and the passing through
 of scripting variables in attributes. Specifically I'm trying to add an
 onclick value to an html:img tag but this is generic for any tag in
 the Struts libraries where the user can supply a value to an attribute.
 
 When the following markup is used in a jsp:
 img src=minor.gif alt= onclick=confirmAction(%= pathParam
 %); /
 img src=minor.gif alt= onclick=%= \confirmAction( +
 pathParam + );\ % /
 The resulting HTML is:
 img src=minor.gif alt= onclick=confirmAction(Foo); /
 img src=minor.gif alt= onclick=confirmAction(Foo); /
 
 As you can see either one of the jsp versions 'work' to create a good
 onclick method.
 
 But when the code is changed to use the html:img tag it doesn't work.
 That is with the following jsp markup:
 html:img src=normal.gif alt= onclick=confirmAction(%=
 pathParam %); /
 html:img src=normal.gif alt= onclick=%= \confirmAction( +
 pathParam + );\ % /
 The resulting HTML is:
 img src=normal.gif alt= onclick=confirmAction(%= pathParam
 %);
 html:img src=normal.gif alt= onclick=confirmAction(Foo); /
 
 While the first instance of html:img gets changed into the img
 markup the scripting variable pathParam does not get resolved. In the
 second case the scripting variable gets resolved but the html:img does
 not get changed into its appropriate img.
 
 Why? And how do you get the correct behavior?
 
 Any help is greatly appreciated.
 Lori Cook
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Validation and data display

2004-10-28 Thread Ben Anderson
You can turn off declaritve validation.  Then put the validation in your
Action.execute and do whatever you want:
ActionMessages am = form.validate( mapping, request );
if( am.size() != 0 ){

-Ben

Quoting Tate Austin [EMAIL PROTECTED]:

 I have a page in which I would like to display a list of information before
 validation goes off and verifies the form contents, other wise the list will
 never get populated and the page looks awkward.  So is there a way to dictate
 that a validation is triggered only at the time the form is declared on the
 page?




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



[OT] Re: Request parameters not making it to Actions?

2004-10-22 Thread Ben Anderson
Possibly many of you already have your own approaches for seeing
what's actually transmitted over the wire, but if you don't - check
out the LiveHTTPHeaders extension to Firefox - I love it!

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



validateTwoFields

2004-10-06 Thread Ben Anderson
Hi all,
I'm trying to use this custom validate method.  I got the instructions from Matt
Raible's site (thanks Matt ;-)):
http://www.raibledesigns.com/page/rd/20030226

I remember this used to work, but now it's not.  I'm using Struts 1.2.4 and
commons-validator 1.1.3.  I've been playing with it a little and found that the
problem is that the incoming errors parameter is null.  I know something
concerning ActionErrors has gone into place with the recent struts releases
(i.e. don't use ActionErrors, I think?)  Anyways, I'd like to write a few
other custom validation methods, which is really why I'm planning on using
Struts for my current project.  Has anyone figured out this problem or know of
any other documentation.

  public static boolean validateTwoFields(Object bean, ValidatorAction va,
Field field, ActionErrors errors,
HttpServletRequest request) {
String value =
ValidatorUtils.getValueAsString(bean, field.getProperty());
String sProperty2 = field.getVarValue(secondProperty);
String value2 = ValidatorUtils.getValueAsString(bean, sProperty2);

LOG.debug(errors: +errors);  // this is null

if (!GenericValidator.isBlankOrNull(value)) {
try {
if (!value.equals(value2)) {
errors.add(field.getKey(),
   Resources.getActionError(request, va, field));

return false;
}
} catch (Exception e) {
errors.add(field.getKey(),
   Resources.getActionError(request, va, field));

return false;
}
}

Thanks,
Ben

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]