On Tuesday, July 1, 2003, at 04:52 PM, Jason Carreira wrote:
Well, I'm glad to hear it.... But now you're making me work... See
below...

You seemed far too relaxed at TSS... time to make you sweat! :)


   - How do I get to my application context attributes?  I
set some in
an initialization servlet from its init-param's.

Check out ServletActionContext.getServletContext(). This should let you do what you want to do (at the expense of not being able to use your Action outside a Servlet container, but you're used to Struts, so we forgive you :-))

Actually I'd want something more elegant, like something like this:


public void setAppConfig(AppConfig config) { ... }

Where an AppConfig object is in application scope. Can this be done with components.xml like the session stuff is done? If so, then I'm all set. Otherwise it seems to be trivial to add an interceptor to do this.

Where in the code (yeah, I'm learning it fast, but pointers always help) is the components.xml and session scope dealt with?

   - I plan on refactoring my infamous <custom:label> taglib
in Struts
to the comparable piece in WW2.  Can someone point me in the right
direction to grab the validation metadata so I can tell if a field is
required or not, as well as getting at the errors from the validation
so I can turn the label red?   Or is there already infrastructure in
place to make this unneeded or easier?

It's very easy to check for errors. If your Action implements
ValidationAware (or extends ActionSupport or BaseActionSupport) then
this is built in, as errors will be added to your action and you can use
hasErrors(), hasActionErrors(), hasFieldErrors(), getActionErrors(), and
getFieldErrors() depending on what you need.

Cool... I discovered ActionSupport after I sent my original mail and got it working with doExecute.


For the validation metadata.... You can use
ActionValidatorManager.getValidators(ActionInvocation invocation) to get
them... You can get the ActionInvocation from the ActionContext.
Unfortunately, this will return you a list of validators. You can check
if they're FieldValidators and get the field name to compare... I
realize this is not ideal for what I think you're trying to do. I'm open
to changing / adding to make this easier, if you've got some ideas.

I'll give it a whirl. Looks like it'll be easy enough to find out if a field is required or not.


The other challenge that you might face is if you want these tags to
work when the page is rendered without coming through an Action...

I never do that kind of thing anyway. All JSP's are under WEB-INF and proxied by an action in Struts, and I'd keep that same concept for WW2.


You'll probably also want to know not the validators on THIS alias, but
the alias you're going to send the request TO. Yeah. Challenges. :-)

Ok, so this is how you turn off validation when coming into a page, but turn it on when coming out?


Great work, everyone!  WW2 passed the 15-minute rule of being able to
pull it down and immediately be effective with it.  There is still a
way to go for me to fully implement all the pieces our
current app can
do (the main additional piece has to do with custom resource
handling,
not from a properties file but a DB instead).

This sounds cool... We could make resource loading pluggable, like we have for configuration, so message bundles can be pulled from other sources than just properties files.

Definitely resource loading should be pluggable. Having resources statically in a WAR always seemed odd to me with Struts. I don't know how good the Commons Resource code is (yes, I recognize the questionable quality of Jakarta stuff too guys, and take what is good and bitch about what is bad!) but if its a decent enough abstraction, then lets use it. If it sucks, then not. Thoughts on this?


We're just glad to have you... Next we'll convert Matt Raible, then
we'll teach Craig McClanahan the error of his ways... LOL

Matt we can convert, no problem!


Craig... no way. He created the abomination known as DynaActionForms, lest you forget! :)

Erik



-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100006ave/direct;at.asp_061203_01/01
_______________________________________________
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork

Reply via email to