Form Bean scope
I must be missing something here...I have a form bean and an action. When the action is invoked, the bean gets instantiated and I see it's validate method get called. So far, so good. When the action method ends and forwards to the actual JSP page that will display the form, the form bean gets re-instantiated, losing all the changes that I made to it in the action method. It seems like it should all be in the same request, since the action forward happens at the server side, not back at the browser. Any help will be greatly appreciated. Thanks, Bryan -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Accessing form bean from inside a custom tag, take 2
(I tried to post this to the list yesterday, but I don't think it made it - it is not in the list archive. Sorry if this shows up twice.) Is there any way to access the form bean from within the doStartTag/doAfterBody functions of a custom tag? Thanks, Bryan -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Accessing form bean from inside a custom tag, take 2
Christian - Those were the first two things I tried. In each case, I get a null returned from getAttribute. I even tried pageContext.findAttribute(beanName) and it also returned null. I am pretty sure I have things configured correctly: In struts-config.xml I define a form bean named fileXferBean. In the action mapping that will lead to the page with the custom tag, I specify fileXferBean for the name attribute. I see the bean get instantiated, but it is just not there when I try to get it from the doStartTag function (using ...getAttribute(fileXferBean)). I know I should be able to do this - what am I missing? Thanks again, Bryan -- Bryan Glennon (mailto:[EMAIL PROTECTED]) BPG Consulting, Inc. (http://www.bpgc.com) Tech Question? (mailto:[EMAIL PROTECTED]) -Original Message- From: Christian Bouessay [mailto:[EMAIL PROTECTED]] Sent: Monday, April 22, 2002 8:53 AM To: Struts Users Mailing List Subject: Re: Accessing form bean from inside a custom tag, take 2 Form-bean is stored in request/session. And in a custom tag, you can access the property pageContext. Why not using a code like : MyFormBean form = (MyFormBean)pageContext.getAttribute(myFormBeanName, PageContext.SESSION_SCOPE); or MyFormBean form = (MyFormBean)pageContext.getAttribute(myFormBeanName, PageContext.REQUEST_SCOPE); Don't know if it answer your question :-) -- C. Bouessay Bryan P. Glennon wrote: (I tried to post this to the list yesterday, but I don't think it made it - it is not in the list archive. Sorry if this shows up twice.) Is there any way to access the form bean from within the doStartTag/doAfterBody functions of a custom tag? Thanks, Bryan -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
JSP Include and tag lib declarations
I'm seeing some strange (or maybe intended) behavior with taglibs and included files. Here's what I do: %@ taglib prefix=bean uri=/WEB-INF/struts-bean.tld % %@ taglib prefix=html uri=/WEB-INF/struts-html.tld % Normal JSP/HTML stuff... html:form action=/action.do style=margin-botton:0m TABLE jsp:include page=/Common/foo1.jsp/ !-- Page specific rows go here -- /TABLE HR TABLE jsp:include page=/Common/foo2.jsp/ !-- More page specific rows here -- /TABLE /html:form More standard jsp/html (foo1 and foo2 just contain table rows but do use the struts bean tag.) The problem is with the two include files. In foo1 I can omit the %@ taglib lines and it works fine. If I omit them from foo2, its contents fail to display. Both foo1 and foo2 are well-formed, consisting only of matching TR/TR and TD/TD elements. Both use the struts bean tag. Any info is appreciated. Cheers, Bryan -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
struts-config and include
Is there a way to include another XML file within the struts-config file? I have tried using entity references but they always fail (null pointer exception when struts-config is being parsed.) The file is getting a big large and I want to split it into several smaller ones. Any ideas? Thanks, Bryan -- Bryan Glennon (mailto:[EMAIL PROTECTED]) BPG Consulting, Inc. (http://www.bpgc.com) Tech Question? (mailto:[EMAIL PROTECTED]) -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: struts-config and include
Steve - I tried that, having done it successfully in ant. I get the following exceptions, however, when I try it in structs-config: avax.servlet.ServletException: Parsing error processing resource path /WEB-INF/struts-config.xml at org.apache.struts.action.ActionServlet.initMapping(ActionServlet.java:13 36) at org.apache.struts.action.ActionServlet.init(ActionServlet.java:465) snip - Root Cause - java.lang.NullPointerException: at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1094) at org.xml.sax.helpers.XMLReaderAdapter.parse(XMLReaderAdapter.java:223) snip The XML is valid (according to Turbo XML): !DOCTYPE struts-config PUBLIC -//Apache Software Foundation//DTD Struts Configuration 1.0//EN http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd;[ !ENTITY incl1 SYSTEM incl1.xml ] Based on other threads I've seen here, I might be SOL. Any ideas? Thanks, Bryan -- Bryan Glennon (mailto:[EMAIL PROTECTED]) BPG Consulting, Inc. (http://www.bpgc.com) Tech Question? (mailto:[EMAIL PROTECTED]) -Original Message- From: Steve Wilkinson [mailto:[EMAIL PROTECTED]] Sent: Tuesday, March 19, 2002 6:25 PM To: Struts user Subject: Re: struts-config and include http://jakarta.apache.org/ant/ant_in_anger.html This tells you how to do an XML document include inside another XML document. I believe you could do this with the struts-config.xml? It under Tips and Tricks. Steve - Original Message - From: Bryan P. Glennon Sent: Tuesday, March 19, 2002 10:02 AM To: [EMAIL PROTECTED] Subject: struts-config and include Is there a way to include another XML file within the struts-config file? I have tried using entity references but they always fail (null pointer exception when struts-config is being parsed.) The file is getting a big large and I want to split it into several smaller ones. Any ideas? Thanks, Bryan -- Bryan Glennon (mailto:[EMAIL PROTECTED]) BPG Consulting, Inc. (http://www.bpgc.com) Tech Question? (mailto:[EMAIL PROTECTED]) -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Holding on to request data
Hi - I need to keep a request around during a page display. What I am doing goes like this: - User clicks on a button - Request gets passed to various struts Action classes where various things happen - Request then gets passed to a jsp page. This jsp page is a frameset containing two frames. The second frame needs to refresh itself (I do this with a meta tag). This is basically an action in progress stage, where a status message is displayed in the lower frame. Once the action is done, the message gets replaced with actual data, and the auto refreshes stop. Problem is, once control goes back to the browser to display the jsp, the request is lost. Unfortunately, it contains data that needs to be passed back for the refresh action. Right now I am pulling out the individual parameters and attributes and building the URL for the refresh with them. This is ugly, since every time info is added to the request, it has to be manually added to the refresh URL. Is there an easy way to have the jsp page just pass the original request on to the refresh URL? I don't want to put the request info in session scope, since it is not really session information. One limitation - I can't use JavaScript here. One of the project requirements is no client-side code. Thanks, Bryan -- Bryan Glennon (mailto:[EMAIL PROTECTED]) BPG Consulting, Inc. (http://www.bpgc.com) Tech Question? (mailto:[EMAIL PROTECTED]) -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Action mappings and request parameters
Hi - I can't seem to specify more that one request parameter in my action mapping entries in the struts-config.xml file. I want to do something like this: forward name=errNoCurrentObject path=/error.jsp?type=internalreason=errNoCurrentObject/ forward name=errNoCurrentServer path=/error.jsp?type=internalreason=errNoCurrentServer/ forward name=errNoSuchProcess path=/error.jsp?type=internalreason=errNoSuchProcess/ ... When my app loads, however, I get a load exception: org.xml.sax.SAXParseException: Next character must be ; terminating reference to entity reason. I have tried escaping the ampersand, but no joy there either. Is there a way to do this? Or a better approach? Thanks, Bryan -- Bryan Glennon (mailto:[EMAIL PROTECTED]) BPG Consulting, Inc. (http://www.bpgc.com) Tech Question? (mailto:[EMAIL PROTECTED]) -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Form bean and class instance question
I must be missing something... I have a class, Foo, whose data I want to display in a form. I have defined an action (NavigateAction) that is invoked when the user makes a selection which will move him/her to the page to disply Foo. This action locates the correct instance of Foo and puts it in a session attribute. I also have a form bean (FooBean) that is associated with the FooAction. This action populates FooBean from information in the Foo object. Right now, I have pretty much duplicated the public interface from Foo in FooBean. It seems like there must be a better way to do this. Anyone care to enlighten me? Thanks, Bryan -- Bryan Glennon (mailto:[EMAIL PROTECTED]) BPG Consulting, Inc. (http://www.bpgc.com) Tech Question? (mailto:[EMAIL PROTECTED]) -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
ActionError problem
Sorry to keep bugging this list, but you have all been so helpful... I am getting an HTTP error 500 (internal server error) sometime after the validate method in my form bean returns. I see all of my logging messages, and there is one entry in the errors list. I see no indication of problems in any of the tomcat or application logs. The validate method looks like this: public ActionErrors validate(ActionMapping mapping, javax.servlet.http.HttpServletRequest request) { cat.debug(Validate); ActionErrors errors = new ActionErrors(); cat.debug(errors created); Object o = request.getSession().getAttribute(currentObject); o = null; // Force error for testing... if(o == null) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(error.noCurrentObject)); } cat.debug(Returning error with + errors.size() + entries.); return errors; } Any ideas? Thanks, Bryan -- Bryan Glennon (mailto:[EMAIL PROTECTED]) BPG Consulting, Inc. (http://www.bpgc.com) Tech Question? (mailto:[EMAIL PROTECTED]) -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: ActionError problem
Alex- I do need to get the session object from the request, so that I can insure that an object has been set for the operation. It seems to make no difference if I use it or not - I tried just creating/populating the ActionErrors object and doing nothing else, and I got the same results... Thanks, Bryan -- Bryan Glennon (mailto:[EMAIL PROTECTED]) BPG Consulting, Inc. (http://www.bpgc.com) Tech Question? (mailto:[EMAIL PROTECTED]) -Original Message- From: Brown, Alex [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 29, 2002 6:13 PM To: 'Struts Users Mailing List' Subject: RE: ActionError problem Does this approach work for you? Make sure your messages are filled in (eng.admin.group.error.groupname.required) etc. You should have no need to play with Request, the GET/SET methods should be populated. -Alex public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); try { if (this.group_name == null) { errors.add(group_name, new ActionError(eng.admin.group.error.groupname.required)); } return errors; } catch (Exception e) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(eng.error.general,e.getMessage())); return errors; } } -Original Message- From: Bryan P. Glennon [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 29, 2002 7:09 PM To: [EMAIL PROTECTED] Subject: ActionError problem Sorry to keep bugging this list, but you have all been so helpful... I am getting an HTTP error 500 (internal server error) sometime after the validate method in my form bean returns. I see all of my logging messages, and there is one entry in the errors list. I see no indication of problems in any of the tomcat or application logs. The validate method looks like this: public ActionErrors validate(ActionMapping mapping, javax.servlet.http.HttpServletRequest request) { cat.debug(Validate); ActionErrors errors = new ActionErrors(); cat.debug(errors created); Object o = request.getSession().getAttribute(currentObject); o = null; // Force error for testing... if(o == null) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(error.noCurrentObject)); } cat.debug(Returning error with + errors.size() + entries.); return errors; } Any ideas? Thanks, Bryan -- Bryan Glennon (mailto:[EMAIL PROTECTED]) BPG Consulting, Inc. (http://www.bpgc.com) Tech Question? (mailto:[EMAIL PROTECTED]) -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
ActionForm and request parameters
Morning - Is there anyway to get access to the request parameters in an ActionForm bean? I need one of the parameters to do a lookup so that I can correctly populate the form. Thanks, Bryan -- Bryan Glennon (mailto:[EMAIL PROTECTED]) BPG Consulting, Inc. (http://www.bpgc.com) Tech Question? (mailto:[EMAIL PROTECTED]) -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: ActionForm and request parameters
But what about the initial display? In order to populate the fields so that the initial getXXX() calls will display the correct data, I need to use a request parameter as a lookup key. Thanks, Bryan -- Bryan Glennon (mailto:[EMAIL PROTECTED]) BPG Consulting, Inc. (http://www.bpgc.com) Tech Question? (mailto:[EMAIL PROTECTED]) -Original Message- From: Martin Farrell [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 24, 2002 11:39 AM To: 'Struts Users Mailing List' Subject: RE: ActionForm and request parameters Hi You can just use the get set methods within a form, and use the validate method to control what variables are filled in when. alternatively use the action.perform method to check what parameters should be collected when martin -Original Message- From: Bryan P. Glennon [mailto:[EMAIL PROTECTED]] Sent: 24 January 2002 17:41 To: [EMAIL PROTECTED] Subject: ActionForm and request parameters Morning - Is there anyway to get access to the request parameters in an ActionForm bean? I need one of the parameters to do a lookup so that I can correctly populate the form. Thanks, Bryan -- Bryan Glennon (mailto:[EMAIL PROTECTED]) BPG Consulting, Inc. (http://www.bpgc.com) Tech Question? (mailto:[EMAIL PROTECTED]) -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] ** For great Emap magazine subscription gift offers visit http://www.emapmagazines.co.uk ** The information in this email is intended only for the addressee(s) named above. Access to this email by anyone else is unauthorised. If you are not the intended recipient of this message any disclosure, copying, distribution or any action taken in reliance on it is prohibited and may be unlawful. Emap plc and or its subsidiaries do not warrant that any attachments are free from viruses or other defects and accept no liability for any losses resulting from infected email transmissions. Please note that any views expressed in this email may be those of the originator and do not necessarily reflect those of this organisation. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: ActionForm and request parameters
I feel like I am being really dense here...I must be missing something. I understand that an action is executed after a submit (or am I wrong here as well?). So what I want to do is this: page1.jsp // This has a link to page2.jsp?parm=X I have a form bean for page2 that should populate the form before it is displayed. I need to use the parm value to do this properly. So where do I place an action that will have access both to the parameter and to the form bean? Thanks again for all the help. Bryan -- Bryan Glennon (mailto:[EMAIL PROTECTED]) BPG Consulting, Inc. (http://www.bpgc.com) Tech Question? (mailto:[EMAIL PROTECTED]) -Original Message- From: Brian Holzer [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 24, 2002 12:40 PM To: [EMAIL PROTECTED] Subject: RE: ActionForm and request parameters If you are doing an initial display, are you not loading the form values from within an Action? If so, request parameters are easily accessed as the request is one of the parameters to your perform() method by using the request.getParameter( paramName ); Brian [EMAIL PROTECTED] 01/24/02 11:54am But what about the initial display? In order to populate the fields so that the initial getXXX() calls will display the correct data, I need to use a request parameter as a lookup key. Thanks, Bryan -- Bryan Glennon (mailto:[EMAIL PROTECTED]) BPG Consulting, Inc. (http://www.bpgc.com) Tech Question? (mailto:[EMAIL PROTECTED]) -Original Message- From: Martin Farrell [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 24, 2002 11:39 AM To: 'Struts Users Mailing List' Subject: RE: ActionForm and request parameters Hi You can just use the get set methods within a form, and use the validate method to control what variables are filled in when. alternatively use the action.perform method to check what parameters should be collected when martin -Original Message- From: Bryan P. Glennon [mailto:[EMAIL PROTECTED]] Sent: 24 January 2002 17:41 To: [EMAIL PROTECTED] Subject: ActionForm and request parameters Morning - Is there anyway to get access to the request parameters in an ActionForm bean? I need one of the parameters to do a lookup so that I can correctly populate the form. Thanks, Bryan -- Bryan Glennon (mailto:[EMAIL PROTECTED]) BPG Consulting, Inc. (http://www.bpgc.com) Tech Question? (mailto:[EMAIL PROTECTED]) -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] ** For great Emap magazine subscription gift offers visit http://www.emapmagazines.co.uk ** The information in this email is intended only for the addressee(s) named above. Access to this email by anyone else is unauthorised. If you are not the intended recipient of this message any disclosure, copying, distribution or any action taken in reliance on it is prohibited and may be unlawful. Emap plc and or its subsidiaries do not warrant that any attachments are free from viruses or other defects and accept no liability for any losses resulting from infected email transmissions. Please note that any views expressed in this email may be those of the originator and do not necessarily reflect those of this organisation. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Includes and processing time
Hi - This is really more of a JSP question, but since it involves struts tags I figured I'd give it a shot here. I have a page which contains a form built using the html:form taglib. Based on the users selection from that form, I go off and do some processing and redirect the user back to the same page. During the processing, an attribute gets set to indicate which detail information to include. I try to include this detail page (which is also an html:form form) by doing a jsp:include. Basically, the page looks like this: html:form... Navigation form /html:form Static stuff here jsp:include page=%=detailPage% / My problem is that the tags in the included page never get processed. So, is there anyway I can make this work? Sorry again for the OT post. Cheers, Bryan -- Bryan Glennon (mailto:[EMAIL PROTECTED]) BPG Consulting, Inc. (http://www.bpgc.com) Tech Question? (mailto:[EMAIL PROTECTED]) -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]