You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Brian Ferris <bd...@cs.washington.edu> on 2008/07/25 18:27:57 UTC
Struts Taglib + JSP: Best Practices For Complex HTML Attribute Construction
I'm not sure what that Struts Taglib "way" to do the following task
would look like:
I've got a bean on the ValueStack with a "boolean isActive()" getter.
When active, I'd like to construct html like:
<div class="baseStyle active"><!-- complex html in here --></div>
And when in-active, I'd like to construct:
<div class="baseStyle"><!-- complex html in here --></div>
The only real difference is the class attribute, which always has a
"baseStyle" class, but should also have an "active" class when the
bean is active.
Using struts taglibs inside a JSP, what's the easiest way to make that
construction? I have some ideas... but they all seem kind of akward.
Thanks,
Brian
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
AW: Re: Implementing ParameterAware but still getting Unexpected Exception caught setting 'name' on 'class....
Posted by Jan Froehlich <Ja...@infomotion.de>.
Hi Laurie,
sorry if I expressed not totally clear what I mean - have still some problems with my english! ;)
> What do you mean that the parameters passed to the action 'change every
> now and then'? At random?!? If you just mean that there are a variable
> number of them, no problem; that's what List- and array-backed
> properties are for.
I have some report objects that have different prompts, with those prompts I build a input form and pass them to my ParameterAware action. The parameter names, and also the parameter count changes from report to report.
> Not sure I understand what you want. Do you just want to suppress the
> exception report in the logs, or does the exception represent an actual
> problem you need to fix? If the latter, you'll need to provide more details.
I guess you can call it "suppress". Its more a cosmetic fix, but I try to understand more of s2 and how to avoid things like that.
I have no functional problems with the exception - everything else works like expected!
So thanks for your answer, it just would be fine to get rid of it, its not a show stopper, if it can be called like that! ;)
Regards
Jan Froehlich
-----Ursprüngliche Nachricht-----
Von: news [mailto:news@ger.gmane.org] Im Auftrag von Laurie Harper
Gesendet: Mittwoch, 30. Juli 2008 07:34
An: user@struts.apache.org
Betreff: Re: Implementing ParameterAware but still getting Unexpected Exception caught setting 'name' on 'class....
Jan Froehlich wrote:
> Hi there...
>
> I have a page with a dynamic number of input fields that is submited to
> an action that implements ParameterAware.
> Cause the names of the parameters passed to that action change every now
> and then I can't write getters and setters for them.
> Thats what I thought ParameterAware is made for.
ParameterAware is just a low-level mechanism for getting access to the
raw request parameters. If you want to apply conversion or validation to
your request data, or have it injected into your actions or model
objects, it's probably not what you need.
What do you mean that the parameters passed to the action 'change every
now and then'? At random?!? If you just mean that there are a variable
number of them, no problem; that's what List- and array-backed
properties are for.
> But even then I get those "Unexpected Exception caught setting.....".
>
> Is there a way to tell s2 that it should stop doing it?
>
> Well, ok - not the most clever question, but I just want to get rid of
> those Exceptions!
Not sure I understand what you want. Do you just want to suppress the
exception report in the logs, or does the exception represent an actual
problem you need to fix? If the latter, you'll need to provide more details.
L.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Implementing ParameterAware but still getting Unexpected Exception
caught setting 'name' on 'class....
Posted by Laurie Harper <la...@holoweb.net>.
Jan Froehlich wrote:
> Hi there...
>
> I have a page with a dynamic number of input fields that is submited to
> an action that implements ParameterAware.
> Cause the names of the parameters passed to that action change every now
> and then I can't write getters and setters for them.
> Thats what I thought ParameterAware is made for.
ParameterAware is just a low-level mechanism for getting access to the
raw request parameters. If you want to apply conversion or validation to
your request data, or have it injected into your actions or model
objects, it's probably not what you need.
What do you mean that the parameters passed to the action 'change every
now and then'? At random?!? If you just mean that there are a variable
number of them, no problem; that's what List- and array-backed
properties are for.
> But even then I get those "Unexpected Exception caught setting.....".
>
> Is there a way to tell s2 that it should stop doing it?
>
> Well, ok - not the most clever question, but I just want to get rid of
> those Exceptions!
Not sure I understand what you want. Do you just want to suppress the
exception report in the logs, or does the exception represent an actual
problem you need to fix? If the latter, you'll need to provide more details.
L.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Implementing ParameterAware but still getting Unexpected Exception caught setting 'name' on 'class....
Posted by Jan Froehlich <Ja...@infomotion.de>.
Hi there...
I have a page with a dynamic number of input fields that is submited to
an action that implements ParameterAware.
Cause the names of the parameters passed to that action change every now
and then I can't write getters and setters for them.
Thats what I thought ParameterAware is made for.
But even then I get those "Unexpected Exception caught setting.....".
Is there a way to tell s2 that it should stop doing it?
Well, ok - not the most clever question, but I just want to get rid of
those Exceptions!
Thanks in advance & a nice weekend!
Regards
Jan Froehlich
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Struts Taglib + JSP: Best Practices For Complex HTML Attribute
Construction
Posted by Laurie Harper <la...@holoweb.net>.
Brian Ferris wrote:
> I'm not sure what that Struts Taglib "way" to do the following task
> would look like:
>
> I've got a bean on the ValueStack with a "boolean isActive()" getter.
> When active, I'd like to construct html like:
>
> <div class="baseStyle active"><!-- complex html in here --></div>
>
> And when in-active, I'd like to construct:
>
> <div class="baseStyle"><!-- complex html in here --></div>
>
> The only real difference is the class attribute, which always has a
> "baseStyle" class, but should also have an "active" class when the bean
> is active.
>
> Using struts taglibs inside a JSP, what's the easiest way to make that
> construction? I have some ideas... but they all seem kind of akward.
The easiest way is using JSTL instead:
<div class="baseStyle${active ? 'active' : ''}">...
You can do the equivalent using struts tags + OGNL, which would look
something like
<div class="baseStyle<s:property value="#{...}"/>">...
It's more cumbersome, and you'd have to work out from the OGNL docs
exactly what you need to substitute for #{...} [does OGNL support the
ternary operator?].
However, it may be better to introduce semantic markers for
active/inactive and use something like
<div class="${activeStyle}"...
L.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org