Re: Action Messages

2005-05-28 Thread Adam Hardy

Ray,
it's not clear what you are trying to do that is different from 
standard. Struts puts the ActionErrors in the request by default. The 
Messages too.


I used to know this inside out but it's been a year or so... but I think 
the key is like this:


request.getAttribute(org.apache.struts.Globals.MESSAGE_KEY);
request.getAttribute(org.apache.struts.Globals.ERROR_KEY);




On 27/05/05 19:46nbsp;Ray Madigan wrote:

I am looking for the ability to handle the ActionMessage in a different way
in my application.  In the validate method of the form I create a new
instance of ActionErrors and add ActionMessage instances to it.  In the
Action dispatch method I call validate and get a non empty ActionErrors
instance.  To figure how to make this work, I can get the iterator to the
keys and copy it to the request attribute like

Iterator iter = errors.properties ( );
request.setAttribute ( ERRORS, errors );

but I can't get the messages associated with the property to allow me to
manipulate my page.

What I would like is:

for ActionErrors to be a collection, the I could iterate on the errors and
get the key and the values.  I could iterate on the values, or reteive a
specific one.

I want the ability to inspect an error condition and if it exists or not and
generate jsp accordingly with an error message.

Does anyone know how to do this?

it would look like, but I dream too much

c:choose
c:when test='${ not empty ERROR.confirmMatch }'
c:forEach var='message' items='${ERROR.confirmMatch}'
trtdfmt:message key='${message}'//td/tr
!--  Generate specific code --
/c:forEach
/c:when
c:otherwise
!-- Generate specific code --
/c:otherwise
/c:choose





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



Re: Action Messages

2005-05-28 Thread Dakota Jack
Hi, Ray,

Why is what you are doing superior to the standard?  The standard is
something like the following and is very efficient, I think?


 table
  tr
td
  !--
  ERRORS
  --
  logic:messagesPresent
ul
  html:messages id='error'
li
bean:write name='error'/
/li
  /html:messages
/ul
  /logic:messagesPresent
  !--
  MESSAGES
  --
  logic:messagesPresent message='true'
ul
  html:messages id='message' message='true'
li
bean:write name='message'/
/li
  /html:messages
/ul
  /logic:messagesPresent
/td
  /tr
 /table

On 5/27/05, Ray Madigan [EMAIL PROTECTED] wrote:
 I am looking for the ability to handle the ActionMessage in a different way
 in my application.  In the validate method of the form I create a new
 instance of ActionErrors and add ActionMessage instances to it.  In the
 Action dispatch method I call validate and get a non empty ActionErrors
 instance.  To figure how to make this work, I can get the iterator to the
 keys and copy it to the request attribute like
 
 Iterator iter = errors.properties ( );
 request.setAttribute ( ERRORS, errors );
 
 but I can't get the messages associated with the property to allow me to
 manipulate my page.
 
 What I would like is:
 
 for ActionErrors to be a collection, the I could iterate on the errors and
 get the key and the values.  I could iterate on the values, or reteive a
 specific one.
 
 I want the ability to inspect an error condition and if it exists or not and
 generate jsp accordingly with an error message.
 
 Does anyone know how to do this?
 
 it would look like, but I dream too much
 
 c:choose
 c:when test='${ not empty ERROR.confirmMatch }'
 c:forEach var='message' items='${ERROR.confirmMatch}'
 trtdfmt:message key='${message}'//td/tr
 !--  Generate specific code --
 /c:forEach
 /c:when
 c:otherwise
 !-- Generate specific code --
 /c:otherwise
 /c:choose
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 


-- 
You can lead a horse to water but you cannot make it float on its back.
~Dakota Jack~

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



RE: Action messages.

2004-06-03 Thread Frank Zammetti
You can fake it and do this... have a hidden span in your page that, 
just before you submit your form, you display.  You will probably also want 
to wrap everything else in your page in a span and hide it at the same 
time.  I say this is faking it because the browser won't have any idea 
what's going on on the server, which might be OK.

If you want some sort of progress bar though, something that actually has 
knowledge of what's going on on the server, what you'll need to do is kick 
off a thread in your Action, and store some reference to it persistently 
(i.e., session or a database, etc.).  Then, you'll have to have a page on 
the browser with something like a meta-refresh that calls some special 
Action that can check the status of that thread, maybe get some sort of 
percent complete or something like that to display back to the browser.

Obviously, if faking it is good enough, as it usually is in these cases, 
that's by far the better choice.

Frank
From: Marcelo Epstein [EMAIL PROTECTED]
Reply-To: Struts Users Mailing List [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Subject: Action messages.
Date: Thu, 3 Jun 2004 11:46:44 -0300
Hi,
I have a Action that takes 10s to execute. Is there any way to display
messages in the browser during execution?
Thx,
Marcelo
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
_
MSN 9 Dial-up Internet Access fights spam and pop-ups – now 3 months FREE! 
http://join.msn.click-url.com/go/onm00200361ave/direct/01/

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


Re: Action messages.

2004-06-03 Thread Marcelo Epstein
Thanks Frank,

Do you have any sample code of using SPAN ?
I think this is also good to avoid 2 submit´s click. Am I right?



- Original Message - 
From: Frank Zammetti [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, June 03, 2004 11:57 AM
Subject: RE: Action messages.


 You can fake it and do this... have a hidden span in your page that,
 just before you submit your form, you display.  You will probably also
want
 to wrap everything else in your page in a span and hide it at the same
 time.  I say this is faking it because the browser won't have any idea
 what's going on on the server, which might be OK.

 If you want some sort of progress bar though, something that actually has
 knowledge of what's going on on the server, what you'll need to do is kick
 off a thread in your Action, and store some reference to it persistently
 (i.e., session or a database, etc.).  Then, you'll have to have a page on
 the browser with something like a meta-refresh that calls some special
 Action that can check the status of that thread, maybe get some sort of
 percent complete or something like that to display back to the browser.

 Obviously, if faking it is good enough, as it usually is in these cases,
 that's by far the better choice.

 Frank

 From: Marcelo Epstein [EMAIL PROTECTED]
 Reply-To: Struts Users Mailing List [EMAIL PROTECTED]
 To: Struts Users Mailing List [EMAIL PROTECTED]
 Subject: Action messages.
 Date: Thu, 3 Jun 2004 11:46:44 -0300
 
 Hi,
 
 I have a Action that takes 10s to execute. Is there any way to display
 messages in the browser during execution?
 
 Thx,
 Marcelo
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 

 _
 MSN 9 Dial-up Internet Access fights spam and pop-ups - now 3 months FREE!
 http://join.msn.click-url.com/go/onm00200361ave/direct/01/


 -
 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: Action messages.

2004-06-03 Thread Frank Zammetti
I'm not sure what you mean by avoid 2 submit 's click.  If your referring 
to the pooling method requiring a submit after the initial one (potential 
any number of submits really), then yes, you would avoid that.

Here's an example off the top of my head (so the disclaimer is it might not 
be perfect!):

htmlheadtitle/title/headbody
span id=pleaseWait style=display:none;Please wait, doing server 
work.../span
span id=mainContent style=display:block;
form name=myForm method=post action=whatever.ext
Field A: input type=text name=fieldAbr
Field B: input type=text name=fieldBbr
input type=submit value=Call Server 
onClick=mainContent.style.display='none';pleaseWait.style.display='block';return 
false;
/form
/span
/body/html

Note the return faksel in the onClick of the submit button... I just did 
this so you'd see it work, without it the form submission proceeds and you 
won't see anything because you immediately get no return.  Or something like 
that anyway :)  The point is, remove that to try this for real against a 
real server.

I think that'll do it, let me know if you need any further help.
Frank
From: Marcelo Epstein [EMAIL PROTECTED]
Reply-To: Struts Users Mailing List [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Subject: Re: Action messages.
Date: Thu, 3 Jun 2004 13:55:11 -0300
Thanks Frank,
Do you have any sample code of using SPAN ?
I think this is also good to avoid 2 submit´s click. Am I right?

- Original Message -
From: Frank Zammetti [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, June 03, 2004 11:57 AM
Subject: RE: Action messages.
 You can fake it and do this... have a hidden span in your page that,
 just before you submit your form, you display.  You will probably also
want
 to wrap everything else in your page in a span and hide it at the same
 time.  I say this is faking it because the browser won't have any idea
 what's going on on the server, which might be OK.

 If you want some sort of progress bar though, something that actually 
has
 knowledge of what's going on on the server, what you'll need to do is 
kick
 off a thread in your Action, and store some reference to it persistently
 (i.e., session or a database, etc.).  Then, you'll have to have a page 
on
 the browser with something like a meta-refresh that calls some special
 Action that can check the status of that thread, maybe get some sort of
 percent complete or something like that to display back to the browser.

 Obviously, if faking it is good enough, as it usually is in these cases,
 that's by far the better choice.

 Frank

 From: Marcelo Epstein [EMAIL PROTECTED]
 Reply-To: Struts Users Mailing List [EMAIL PROTECTED]
 To: Struts Users Mailing List [EMAIL PROTECTED]
 Subject: Action messages.
 Date: Thu, 3 Jun 2004 11:46:44 -0300
 
 Hi,
 
 I have a Action that takes 10s to execute. Is there any way to display
 messages in the browser during execution?
 
 Thx,
 Marcelo
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 

 _
 MSN 9 Dial-up Internet Access fights spam and pop-ups - now 3 months 
FREE!
 http://join.msn.click-url.com/go/onm00200361ave/direct/01/


 -
 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]
_
Get fast, reliable Internet access with MSN 9 Dial-up – now 3 months FREE! 
http://join.msn.click-url.com/go/onm00200361ave/direct/01/

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