Errors / Messages

2003-09-15 Thread Edgar P Dollin
In validate, if you add an error to the message list, validator returns
without forwarding.  Has anyone done anything with an alternate message file
or prioritized messages, so you can add a message yet still forward.

Thanks in advance.

Edgar

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



Re: Errors / Messages

2003-09-15 Thread Max Cooper
Edgar,

What is your aim in doing this? If there is a validation error, the Struts
framework sends the user back to the input page to inform them of the
problem, and possibly allow them to fix it and resubmit. If the request
still gets passed to the action, the action will need to do conditional
processing based on the presence of errors, and then it is unclear how
control will pass back to Struts so that it can send the user back to the
input page to inform them of what went wrong.

I have sometimes thought about having the action produce a validation-style
error if something goes wrong in processing the request, after which it
could pass control back to the Struts framework to send the user back to the
input page. You can of course add another forward or something, but it
would be nice if you could just tell Struts more cleary that something went
wrong and that Struts should send the user back to the input form (as it
does with a validation error), but I am not sure if there is an elegant way
to do that. This is distinct from your proposed flow, but it seems the same
feature (tell Struts there was an error and user should be sent back to
input form) could support both of our scenarios.

What is the scenario you wish to support with the control flow that are
looking for?

-Max

- Original Message - 
From: Edgar P Dollin [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Sent: Monday, September 15, 2003 2:54 AM
Subject: Errors / Messages


 In validate, if you add an error to the message list, validator returns
 without forwarding.  Has anyone done anything with an alternate message
file
 or prioritized messages, so you can add a message yet still forward.

 Thanks in advance.

 Edgar

 -
 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: Errors / Messages

2003-09-15 Thread Edgar P Dollin
I would like the action to perform (not fail as validator specifies) but
give feedback to the user about the entered data.  For example in certain
fields you can use a table as a select but override the selection, and other
input would be added to the selection.  You would want to let the user know
that the information was added to the allowed list.

I am doing your other selection in the action class as well.

My intermeditate solution, is to extend the ActionForm and add an
informational message ActionMessages property and a special tag for
displaying any pending informational messages.

Edgar

 -Original Message-
 From: Max Cooper [mailto:[EMAIL PROTECTED] 
 Sent: Monday, September 15, 2003 5:38 AM
 To: Struts Users Mailing List
 Subject: Re: Errors / Messages
 
 
 Edgar,
 
 What is your aim in doing this? If there is a validation 
 error, the Struts framework sends the user back to the input 
 page to inform them of the problem, and possibly allow them 
 to fix it and resubmit. If the request still gets passed to 
 the action, the action will need to do conditional processing 
 based on the presence of errors, and then it is unclear how 
 control will pass back to Struts so that it can send the user 
 back to the input page to inform them of what went wrong.
 
 I have sometimes thought about having the action produce a 
 validation-style error if something goes wrong in processing 
 the request, after which it could pass control back to the 
 Struts framework to send the user back to the input page. You 
 can of course add another forward or something, but it 
 would be nice if you could just tell Struts more cleary that 
 something went wrong and that Struts should send the user 
 back to the input form (as it does with a validation error), 
 but I am not sure if there is an elegant way to do that. This 
 is distinct from your proposed flow, but it seems the same 
 feature (tell Struts there was an error and user should be 
 sent back to input form) could support both of our scenarios.
 
 What is the scenario you wish to support with the control 
 flow that are looking for?
 
 -Max
 
 - Original Message - 
 From: Edgar P Dollin [EMAIL PROTECTED]
 To: Struts Users Mailing List [EMAIL PROTECTED]
 Sent: Monday, September 15, 2003 2:54 AM
 Subject: Errors / Messages
 
 
  In validate, if you add an error to the message list, validator 
  returns without forwarding.  Has anyone done anything with an 
  alternate message
 file
  or prioritized messages, so you can add a message yet still forward.
 
  Thanks in advance.
 
  Edgar
 
  
 -
  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: Errors/Messages on Redirect

2003-04-04 Thread Cody Sherr
Brian,

I had the same problem. I did the following:

1) save the errors in the session instead of the request

2) wrote a method that takes the messages from the session, and puts it
into the request. I call that after my redirect is done.

I thought about having the .jsp pull it out of the session and display
it, but I was concerned about that being fragile if the user's control
flow somehow didn't lead to the message display page. So instead, I do
it in my controller (we're using tiles, too, so I have more than 1
action being called for every page).

I'd be interested in hearing what approach you took to solving this
problem.

cheers,

--
Cody Sherr

Software Engineer
Covalent Technologies, Inc.


On Fri, 2003-03-28 at 10:47, Brian K Bonner wrote:
 Has anyone else run into this scenario before?  I've searched the archives 
 and couldn't find much on the topic of errors and redirect.
 
 During an action, I want may encounter an error condition and I want to 
 REDIRECT the user back to the page where they came from and pass along the 
 error.  I need to do a redirect to get the URL of the browser to reflect 
 the page where they came from (in case they bookmark the link).  If I 
 don't do a redirect then the page being displayed reflects the action they 
 were trying to perform and they are out of synch.
 
 The problem with this is that I can't pass the ActionErrors / 
 ActionMessages on the request as they are lost with the redirect.
 
 One option I've thought of is to put the data on the session and then 
 strip it off in the jsp--each request in a session would need to put data 
 in via a unique key that's not in the session (in the event of 
 simultaneous requests).
 
 -
 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]



Errors/Messages on Redirect

2003-03-28 Thread Brian K Bonner
Has anyone else run into this scenario before?  I've searched the archives 
and couldn't find much on the topic of errors and redirect.

During an action, I want may encounter an error condition and I want to 
REDIRECT the user back to the page where they came from and pass along the 
error.  I need to do a redirect to get the URL of the browser to reflect 
the page where they came from (in case they bookmark the link).  If I 
don't do a redirect then the page being displayed reflects the action they 
were trying to perform and they are out of synch.

The problem with this is that I can't pass the ActionErrors / 
ActionMessages on the request as they are lost with the redirect.

One option I've thought of is to put the data on the session and then 
strip it off in the jsp--each request in a session would need to put data 
in via a unique key that's not in the session (in the event of 
simultaneous requests).

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



NPE problem when using both errors/messages tag.

2003-02-05 Thread Richard Mixon

I'm getting an NPE in the generated JSP/Java whenever I try to display both
an errors and messages queue on a JSP page.

I image it is something pretty embarrasingly simple, but I've been after it
for over a day. Thanks in advance

Here's the NPE:

  java.lang.NullPointerException
at java.util.Hashtable.put(Hashtable.java:389)
at
org.apache.jasper.runtime.PageContextImpl.setAttribute(PageContextImpl.java:
229)
at
org.apache.struts.taglib.html.MessagesTag.doStartTag(MessagesTag.java:250)
at org.apache.jsp.ContactUs$jsp._jspService(ContactUs$jsp.java:873)
...

The generated JSP Java code fragment is:
   ...
   try {
 int _jspx_eval_html_messages_1 = _jspx_th_html_messages_1.doStartTag();
 if (_jspx_eval_html_messages_1 !=
javax.servlet.jsp.tagext.Tag.SKIP_BODY) {, like
   ...

Here are the tags in my page (its the second html:messages tage - where
this occurs
...
/html:form /td

logic:messagesPresent
  UL
html:messages id=error
  LIbean:write name=error//LI
/html:messages
  /UL
/logic:messagesPresent
logic:messagesPresent message=true
  UL
html:messages id=message message=true
  LIbean:write name=message//LI
/html:messages
  /UL
/logic:messagesPresent

My action does a save on both the ActionErrors and ActionMessages objects,
though only one should actually end up with a message in it.
   ...
 messages.add(
   ActionMessages.GLOBAL_MESSAGE,
   new ActionMessage(msg.email.sent));
 System.err.println(... Retrieved all fields from form);
   } catch (Exception e) {
 System.err.println(Error trying to send email);
 success = false;
 errors.add(
   ActionMessages.GLOBAL_MESSAGE,
 new ActionError(error.email.not.sent));
   throw e;
   } finally {
 System.err.println(... Finished one way or the other.);
 saveMessages(request,messages);
 saveErrors(request,errors);
   }
   ...

Thanks again for any ideas -

Richard Mixon
email: [EMAIL PROTECTED]



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