About Datasource
Hii All, Any one know how to get multiple Datasource from Struts. Because i think in Struts-config.xml, we are able to specify only one Datasource. Also I got an error when I configure my datasources in tomcat's sever.xml context /context I couldnt able to get that datasource name in my Strtus's application.But my ordinary application can able to ge the Datasources from server.xml. Why this is happend??? Thanx in Advance Kalaiselvna.S -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
html:form
Hi, name - The attribute name of the bean whose properties are consulted to determine which option should be pre-selected when rendering this input field. If not specified, the bean associated with the enclosing html:form tag is utilized. The above is the doc. for html:form .. If I use the following, html:form action=mainscreen.action /html:form form-bean name=reportParameterForm type=com.hcl.smartmanage.web.ReportParameterForm/ actionpath=/mainscreen type=com.hcl.smartmanage.web.action.SetupAction name=reportParameterForm scope=request input=/mainscreen.jsp /action --- Will it pick up 'ReportParameterFormBean' automatically ? I am asking this because the following doesn't specify any JSP bean name. So it should pick it up the bean associated with the html:form .. tag. html:select property=wanLinks size=1 html:options collection=wanLinkOptions property=value labelProperty=label/ /html:select bye, Mohan -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: html:form
It will pick up property values from the bean ReportParameterForm and NOT 'ReportParameterFormBean' , these two names are different as far as i know Deepank - Original Message - From: Mohan Radhakrishnan [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, September 30, 2002 1:03 PM Subject: html:form Hi, name - The attribute name of the bean whose properties are consulted to determine which option should be pre-selected when rendering this input field. If not specified, the bean associated with the enclosing html:form tag is utilized. The above is the doc. for html:form .. If I use the following, html:form action=mainscreen.action /html:form form-bean name=reportParameterForm type=com.hcl.smartmanage.web.ReportParameterForm/ actionpath=/mainscreen type=com.hcl.smartmanage.web.action.SetupAction name=reportParameterForm scope=request input=/mainscreen.jsp /action --- Will it pick up 'ReportParameterFormBean' automatically ? I am asking this because the following doesn't specify any JSP bean name. So it should pick it up the bean associated with the html:form .. tag. html:select property=wanLinks size=1 html:options collection=wanLinkOptions property=value labelProperty=label/ /html:select bye, Mohan -- 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: Incomplete page!!!
You were right, two properties were missing in the ActionForm!!! It wasn't so strange!!! Thanks... Peter S. Hamlen wrote: Yep, we've seen the same behavior a lot. The trick is that there is SOME error occuring on the page (in our case, it was often non-existent property references in our JSP tags). You can narrow it down fastest by looking at your log4j logs (or whatever logging mechanism you're using.) Note that the this is different from the Tomcat logs, which unfortunately won't show the error message (or at least didn't in our case.) Another approach, which is slower but works if you don't know where your log4j logs are, is: 1) Start truncating the page until it all shows up, and then slowly add bits of the JSP back into the file. Eventually you'll add some JSP tag and it won't display everything and that will be your troublesome JSP tag. I recommend checking the logs, though. HTH -Peter On Fri, 2002-09-27 at 11:39, Vincent Berruchon wrote: Hi, I use Tomcat 4 with Stuts 1.02 and I got a strange problem on a JSP the server send me an imcomplete html page. It seems to send the same amount of, like if a buffer was full after 7 or 8 kb... it stops and don't send the end of the JSP (it's HTML at this point) page. The log tells nothing about that (in debug level 5). Got an idea?? Thanks -- 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]
RE: html:form
HI, O.K. It is ReportParameterForm. I am checking this because of the following error. javax.servlet.ServletException: Cannot find bean under name wanLinkOptions I am referring to the html select example from the Struts examples package. bye, mohan -Original Message- From: deepank [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 1:47 PM To: Struts Users Mailing List Subject: Re: html:form It will pick up property values from the bean ReportParameterForm and NOT 'ReportParameterFormBean' , these two names are different as far as i know Deepank - Original Message - From: Mohan Radhakrishnan [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, September 30, 2002 1:03 PM Subject: html:form Hi, name - The attribute name of the bean whose properties are consulted to determine which option should be pre-selected when rendering this input field. If not specified, the bean associated with the enclosing html:form tag is utilized. The above is the doc. for html:form .. If I use the following, html:form action=mainscreen.action /html:form form-bean name=reportParameterForm type=com.hcl.smartmanage.web.ReportParameterForm/ actionpath=/mainscreen type=com.hcl.smartmanage.web.action.SetupAction name=reportParameterForm scope=request input=/mainscreen.jsp /action --- Will it pick up 'ReportParameterFormBean' automatically ? I am asking this because the following doesn't specify any JSP bean name. So it should pick it up the bean associated with the html:form .. tag. html:select property=wanLinks size=1 html:options collection=wanLinkOptions property=value labelProperty=label/ /html:select bye, Mohan -- 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]
About Datasource
Hii All, Any one know how to get multiple Datasource from Struts. Because i think in Struts-config.xml, we are able to specify only one Datasource. Also I got an error when I configure my datasources in tomcat's sever.xml context /context I couldnt able to get that datasource name in my Strtus's application.But my ordinary application can able to ge the Datasources from server.xml. Why this is happend??? Thanx in Advance Kalaiselvna.S
displaying result in jsp without set/getAttribute
Hi I've been swimming through the docs but may have overlooked this, please help if you can I want a jsp to display a result after the Action is done , but I don't want to use set/getAttribute(). Is there another solution or is setAttribute the only way to pass the data to the jsp? Thanks in advance for any help with this newbie problem -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: tabsLayout.jsp ServletException??
So, the web server can't find the specified class. Can you check if the class is present in WEB-INF/classes/org/apache/struts/webapp/tiles/portal/. ? If not, check if it is in the war file. If still not there, it is a bug. Do you have the latest version of Tiles or Struts ? Cedric Curtney Jacobs wrote: Hi, thank you for replying. As you suggested, I tried to see if the tiles-doc.war files work for my configuation. I am still getting the same error with an additional error that org.apache.struts.webapp.tiles.portal.UserMenuAction is not found. I have tried browsing through the API for this class and I could not find it. Hmmm. The following is the exact error I got: [ServletException in:/layouts/vboxLayout.jsp] Error - Class not found :org.apache.struts.webapp.tiles.portal.UserMenuAction' [ServletException in:/layouts/tabsLayout.jsp] null' Again, anymore suggestion/advice would be helpful. _CJ On Friday 27 September 2002 10:12 am, Cedric Dumoulin wrote: Hi, Sorry for this late answer, I am abroad since 2 weeks, and have some trouble with my mails. Don't you have more message error ? Maybe you have a problem with one of your tiles. Can you try them separately, especially the ones inserted inside tabs. Also, can you confirm that tabs from tiles-doc war files work for your configuration ? Cedric Curtney Jacobs wrote: Greetings everyone!! I am trying to incoporate a tab layout in one of my jsp pages. I have download the tiles layout examples from the tiles website and I have configured my tiles-defs.xml similar to the examples. However I am getting the following error message: [ServletException in:/layout/tabsLayout.jsp]' Any comments or suggestions would be greatly appreciated. Thank you. ps. The Following is what my tiles-defs.xml look like: tiles-definitions !-- -- !-- Master Layout-- !-- -- !-- Master layout and default layout used by all pages -- definition name=sesm.master.page path=/layout/classicLayout.jsp put name=title value=Special Education Student Management Master Layout / put name=header value=/common/default_header.jsp / put name=menuvalue=/common/default_menu.jsp / put name=footer value=/common/default_footer.jsp / put name=bodyvalue=/common/default_body.jsp / /definition definition name=sesm.index.page extends=sesm.master.page put name=title value=Specia Education Student Management (SESM) / put name=body value=sesm.tab.body / /definition definition name=sesm.tab.page extends=sesm.master.page put name=title value=SESM TABS / put name=body value=sesm.tab.body / /definition definition name=sesm.tab.body path=/layout/tabsLayout.jsp put name=selectedIndex value=0 / put name=parameterName value=selected / putList name=tabList item value=Header link=/common/default_header.jsp classtype=org.apache.struts.tiles.beans.SimpleMenuItem/ item value=Footer link=/common/default_footer.jsp classtype=org.apache.struts.tiles.beans.SimpleMenuItem/ /putList /definition /tiles-definitions I have checked my -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Tiles definition (help)
The Tiles framework provides a way to build web pages by assembling page fragment. The Tiles Definition contains one assemblage that can be reuse in other assemblage. The definition name is a unique identifier of this assemblage, not an url. So, you need to link the definition to an URL. This can be done in a page as you suggest, or with a struts action forwarding to the tiles definition. Cedric Heligon Sandra wrote: I want to use a common look for each page so I defined a file classicLayout.jsp. Then for each page I define a new entry site.name page.page in Tiles.xml where I point on a specific body for example login_body.jsp for the login page. But I don't understand well I must have a first file login.jsp: tiles:insert definition=site.login.page flush=true / login_body.jsp: html:form action=/LoginAction focus=username ... /html:form It is not the best solution,isn't it ? I can not create two files for the same page, one to point on the best tiles definition and an other to define the body. How does it works ? In each body file I have to use the struts html:form, in order to automatically manage cookies, isn't it ? Thanks for your help -- 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: tiles-definitions is incomplete
You try to parse an uncomplete tiles xml configuration file. Maybe you have added a new war file like struts-blank.war in your application ? In Struts 1.1b2 and later, tiles are enable from struts-config.xml, with the appropriate tags. Hope this help, Cedric Tuan H. Le wrote: Hi, I just found this error in tomcat log, and I couldn't figure out the reason for causing this error when I don't use struts-tiles tag. Though, I didn't see this error before. I must have modified the web.xml file. Here is the error message with the web.xml file Please advise on troubleshooting this error. Thanks in advance for your help! Tuan org.xml.sax.SAXParseException: The content of element type tiles-definitions is incomplete, it must match (definition)+. at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:232) at org.apache.xerces.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:173) at org.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:362) at org.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:296) at org.apache.xerces.impl.dtd.XMLDTDValidator.handleEndElement(XMLDTDValidator.java:1953) at org.apache.xerces.impl.dtd.XMLDTDValidator.endElement(XMLDTDValidator.java:878) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.handleEndElement(XMLDocumentFragmentScannerImpl.java:1144) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:987) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1445) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:333) at org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:524) at org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:580) at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:152) at org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1169) at org.apache.commons.digester.Digester.parse(Digester.java:1514) at org.apache.struts.tiles.xmlDefinition.XmlParser.parse(XmlParser.java:341) at org.apache.struts.tiles.xmlDefinition.I18nFactorySet.parseXmlFile(I18nFactorySet.java:529) at org.apache.struts.tiles.xmlDefinition.I18nFactorySet.parseXmlFiles(I18nFactorySet.java:466) at org.apache.struts.tiles.xmlDefinition.I18nFactorySet.createDefaultFactory(I18nFactorySet.java:294) at org.apache.struts.tiles.xmlDefinition.I18nFactorySet.initFactory(I18nFactorySet.java:267) at org.apache.struts.tiles.xmlDefinition.I18nFactorySet.initFactory(I18nFactorySet.java:215) at org.apache.struts.tiles.definition.ComponentDefinitionsFactoryWrapper.init(ComponentDefinitionsFactoryWrapper.java:69) at org.apache.struts.tiles.DefinitionsUtil.createDefinitionsFactory(DefinitionsUtil.java:276) at org.apache.struts.tiles.TilesPlugin.init(TilesPlugin.java:147) at org.apache.struts.action.ActionServlet.initApplicationPlugIns(ActionServlet.java:991) at org.apache.struts.action.ActionServlet.init(ActionServlet.java:458) at javax.servlet.GenericServlet.init(GenericServlet.java:256) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:924) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:813) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3342) at org.apache.catalina.core.StandardContext.start(StandardContext.java:3534) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:821) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:807) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:579) at org.apache.catalina.core.StandardHostDeployer.install(StandardHostDeployer.java:257) at org.apache.catalina.core.StandardHost.install(StandardHost.java:772) at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:502) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:410) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:879) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:368) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:166) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1196) at org.apache.catalina.core.StandardHost.start(StandardHost.java:738) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1188) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:347) at
Re: html:form
This is because u may not have stored the bean wanLinkOptions in request or session, the scope u may be using in ur application. u must store this bean in some scope(probably in your action class) - Original Message - From: Mohan Radhakrishnan [EMAIL PROTECTED] To: 'Struts Users Mailing List' [EMAIL PROTECTED] Sent: Monday, September 30, 2002 2:34 PM Subject: RE: html:form HI, O.K. It is ReportParameterForm. I am checking this because of the following error. javax.servlet.ServletException: Cannot find bean under name wanLinkOptions I am referring to the html select example from the Struts examples package. bye, mohan -Original Message- From: deepank [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 1:47 PM To: Struts Users Mailing List Subject: Re: html:form It will pick up property values from the bean ReportParameterForm and NOT 'ReportParameterFormBean' , these two names are different as far as i know Deepank - Original Message - From: Mohan Radhakrishnan [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, September 30, 2002 1:03 PM Subject: html:form Hi, name - The attribute name of the bean whose properties are consulted to determine which option should be pre-selected when rendering this input field. If not specified, the bean associated with the enclosing html:form tag is utilized. The above is the doc. for html:form .. If I use the following, html:form action=mainscreen.action /html:form form-bean name=reportParameterForm type=com.hcl.smartmanage.web.ReportParameterForm/ actionpath=/mainscreen type=com.hcl.smartmanage.web.action.SetupAction name=reportParameterForm scope=request input=/mainscreen.jsp /action --- Will it pick up 'ReportParameterFormBean' automatically ? I am asking this because the following doesn't specify any JSP bean name. So it should pick it up the bean associated with the html:form .. tag. html:select property=wanLinks size=1 html:options collection=wanLinkOptions property=value labelProperty=label/ /html:select bye, Mohan -- 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]
Struts ActionMapping / OC4J problem
Hi. Several days ago, I posted a message relating to configuring Struts to run properly on OC4J. The actual problem was that JDeveloper's wizard for creating Action classes, does not create a perform(), but an execute() method, which I beleive is the old version (?). The Action class that worked properly was hand-coded by me. Kind regards. Thomas Delnoij -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: html:form
Hi, The bean should be associated with the html:form tag according to the struts example. The example html:select property=collectionSelect size=10 multiple=true html:options collection=options property=value labelProperty=label/ /html:select doesn't specify any bean name. Mine is similar. html:select property=wanLinks size=1 html:options collection=wanLinkOptions property=value labelProperty=label/ /html:select bye, Mohan -Original Message- From: deepank [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 4:04 PM To: Struts Users Mailing List Subject: Re: html:form This is because u may not have stored the bean wanLinkOptions in request or session, the scope u may be using in ur application. u must store this bean in some scope(probably in your action class) - Original Message - From: Mohan Radhakrishnan [EMAIL PROTECTED] To: 'Struts Users Mailing List' [EMAIL PROTECTED] Sent: Monday, September 30, 2002 2:34 PM Subject: RE: html:form HI, O.K. It is ReportParameterForm. I am checking this because of the following error. javax.servlet.ServletException: Cannot find bean under name wanLinkOptions I am referring to the html select example from the Struts examples package. bye, mohan -Original Message- From: deepank [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 1:47 PM To: Struts Users Mailing List Subject: Re: html:form It will pick up property values from the bean ReportParameterForm and NOT 'ReportParameterFormBean' , these two names are different as far as i know Deepank - Original Message - From: Mohan Radhakrishnan [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, September 30, 2002 1:03 PM Subject: html:form Hi, name - The attribute name of the bean whose properties are consulted to determine which option should be pre-selected when rendering this input field. If not specified, the bean associated with the enclosing html:form tag is utilized. The above is the doc. for html:form .. If I use the following, html:form action=mainscreen.action /html:form form-bean name=reportParameterForm type=com.hcl.smartmanage.web.ReportParameterForm/ actionpath=/mainscreen type=com.hcl.smartmanage.web.action.SetupAction name=reportParameterForm scope=request input=/mainscreen.jsp /action --- Will it pick up 'ReportParameterFormBean' automatically ? I am asking this because the following doesn't specify any JSP bean name. So it should pick it up the bean associated with the html:form .. tag. html:select property=wanLinks size=1 html:options collection=wanLinkOptions property=value labelProperty=label/ /html:select bye, Mohan -- 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] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Struts ActionMapping / OC4J problem
Execute is the new versión (1.1b2). Perform is the old metod (1.0.2). Regads. -Mensaje original- De: Thomas Delnoij [mailto:[EMAIL PROTECTED]] Enviado el: lunes, 30 de septiembre de 2002 12:33 Para: [EMAIL PROTECTED] Asunto: Struts ActionMapping / OC4J problem Hi. Several days ago, I posted a message relating to configuring Struts to run properly on OC4J. The actual problem was that JDeveloper's wizard for creating Action classes, does not create a perform(), but an execute() method, which I beleive is the old version (?). The Action class that worked properly was hand-coded by me. Kind regards. Thomas Delnoij -- 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: Pre-populating ActionForms
Instead of forwarding to 'setup.jsp' that has no presentation, why not forward to 'setup.do'. If there is not presentation, and just action, shouldn't it BE an action rather than a (non)presentation component. Your setup.do action would then perform the prepopulation of the form and forward to the appropriate view component. In our current system, we are closly following this model; presentation is seperate from behavior, and it is working out very nicely. Dave Derry - Original Message - From: Mohan Radhakrishnan [EMAIL PROTECTED] Hi, I have actually set up a 'Setup' form and action. After login, I forward to setup.jsp, that doesn't show anything(though is is a jsp) but pre-populates the form. How do you forward from there to the JSP that shows the pre-populated form ? There is no submit action on setup.jsp. bye, Mohan -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Pre-populating ActionForms
+1 -Original Message- From: Dave Derry [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 19:11 To: Struts Users Mailing List Subject: Re: Pre-populating ActionForms Instead of forwarding to 'setup.jsp' that has no presentation, why not forward to 'setup.do'. If there is not presentation, and just action, shouldn't it BE an action rather than a (non)presentation component. Your setup.do action would then perform the prepopulation of the form and forward to the appropriate view component. In our current system, we are closly following this model; presentation is seperate from behavior, and it is working out very nicely. Dave Derry - Original Message - From: Mohan Radhakrishnan [EMAIL PROTECTED] Hi, I have actually set up a 'Setup' form and action. After login, I forward to setup.jsp, that doesn't show anything(though is is a jsp) but pre-populates the form. How do you forward from there to the JSP that shows the pre-populated form ? There is no submit action on setup.jsp. bye, Mohan -- 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: Status of Validator not validating sub-applications bug (#10348)
Hi Micheal, I am trying to use Validator with Struts 1.1 b2. I am not using dynaforms. But I have multiple sub applications in my application. Can you share you code (or your insight for it) with me. Thanks in advance. Regards, Vikas Sangwan. -Original Message- From: Michael Delamere [mailto:[EMAIL PROTECTED]] Sent: Thursday, September 12, 2002 10:40 PM To: Struts Users Mailing List Subject: Re: Status of Validator not validating sub-applications bug (#10348) Doug, I´m not having any problems with it, although having said that I haven´t tried it with dynaforms. Regards, Michael - Original Message - From: Doug Bryant [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Thursday, September 12, 2002 6:54 PM Subject: Status of Validator not validating sub-applications bug (#10348) Does anyone know the status of the bug about the validator not validating sub-applications? I noticed that bug mentioned in the 1.1 beta 2 release notes. We have developed an application using 1.1 and are getting ready to implement page level validation for our sub-applications. If no fix is in place or a fix will not be in place any time soon, could you suggest workaround for the bug or a place to start looking at the source. I should mention that we are using dynaforms so there is not validate method on the action to override. Thanks very much in advance. Doug -- 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]
Re: html:form
When u use the collection attribute of the options tag, u must store the bean u r trying to access by the collection attribute in some scope. Its not the same bean as the one attributed with your action mapping. It will be some collection like a Vector, ArrayList etc. stored in the some scope Deepank - Original Message - From: Mohan Radhakrishnan [EMAIL PROTECTED] To: 'Struts Users Mailing List' [EMAIL PROTECTED] Sent: Monday, September 30, 2002 4:11 PM Subject: RE: html:form Hi, The bean should be associated with the html:form tag according to the struts example. The example html:select property=collectionSelect size=10 multiple=true html:options collection=options property=value labelProperty=label/ /html:select doesn't specify any bean name. Mine is similar. html:select property=wanLinks size=1 html:options collection=wanLinkOptions property=value labelProperty=label/ /html:select bye, Mohan -Original Message- From: deepank [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 4:04 PM To: Struts Users Mailing List Subject: Re: html:form This is because u may not have stored the bean wanLinkOptions in request or session, the scope u may be using in ur application. u must store this bean in some scope(probably in your action class) - Original Message - From: Mohan Radhakrishnan [EMAIL PROTECTED] To: 'Struts Users Mailing List' [EMAIL PROTECTED] Sent: Monday, September 30, 2002 2:34 PM Subject: RE: html:form HI, O.K. It is ReportParameterForm. I am checking this because of the following error. javax.servlet.ServletException: Cannot find bean under name wanLinkOptions I am referring to the html select example from the Struts examples package. bye, mohan -Original Message- From: deepank [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 1:47 PM To: Struts Users Mailing List Subject: Re: html:form It will pick up property values from the bean ReportParameterForm and NOT 'ReportParameterFormBean' , these two names are different as far as i know Deepank - Original Message - From: Mohan Radhakrishnan [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, September 30, 2002 1:03 PM Subject: html:form Hi, name - The attribute name of the bean whose properties are consulted to determine which option should be pre-selected when rendering this input field. If not specified, the bean associated with the enclosing html:form tag is utilized. The above is the doc. for html:form .. If I use the following, html:form action=mainscreen.action /html:form form-bean name=reportParameterForm type=com.hcl.smartmanage.web.ReportParameterForm/ actionpath=/mainscreen type=com.hcl.smartmanage.web.action.SetupAction name=reportParameterForm scope=request input=/mainscreen.jsp /action --- Will it pick up 'ReportParameterFormBean' automatically ? I am asking this because the following doesn't specify any JSP bean name. So it should pick it up the bean associated with the html:form .. tag. html:select property=wanLinks size=1 html:options collection=wanLinkOptions property=value labelProperty=label/ /html:select bye, Mohan -- 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] -- 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]
Serving XML and dynamically generated Flash (jgenerator) content with struts
Title: Serving XML and dynamically generated Flash (jgenerator) content with struts Hi, there! Im kinda new to struts and have a few questions regarding it: 1. is it possible to serve xml using struts? We're currently using 'stand-alone servlets to generate xml that'sread by flash movies, but we're seeing a need for things like internationalisation and application flow. Is there a way of avoiding the jsp's in the view layer and use servlets (which are way better suited for xml than jsp's) I've checked the archives, but it's real hard to find any good answers... 2. We're also using jgenerator to generate dynamic flash - only those of you knowing jgenerator should answer to this question - Where in the mvc-model / struts architecture would it make sense to generate flash content? Any advice would be appreciated, Cheers, Stef. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Serving XML and dynamically generated Flash (jgenerator) contentwith struts
Hi Stefan, You may want to check out stxx. From your email it seems like it should do everything you need it to do. stxx - http://www.openroad.ca/opencode/stxx [EMAIL PROTECTED] wrote: Hi, there! Im kinda new to struts and have a few questions regarding it: 1. is it possible to serve xml using struts? We're currently using 'stand-alone servlets to generate xml that'sread by flash movies, but we're seeing a need for things like internationalisation and application flow. Is there a way of avoiding the jsp's in the view layer and use servlets (which are way better suited for xml than jsp's) I've checked the archives, but it's real hard to find any good answers... 2. We're also using jgenerator to generate dynamic flash - only those of you knowing jgenerator should answer to this question - Where in the mvc-model / struts architecture would it make sense to generate flash content? Any advice would be appreciated, Cheers, Stef. -- 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]
Differences in error validation between 1.0 and 1.1b?
I have recently upgraded to struts 1.1b and I notice that all error messages stored in ActionErrors from the validate-method of the form bean has disappeared when trying to display them using html:errors/. The only change I have made is upgrading struts. Something has happened. What? Here is my validate-code: public org.apache.struts.action.ActionErrors validate( org.apache.struts.action.ActionMapping mapping, javax.servlet.http.HttpServletRequest request) { ActionErrors errors = new ActionErrors(); request. if (save.equalsIgnoreCase(action)) { if (.equalsIgnoreCase(getPartNo())) { errors.add(partNo, new ActionError(Part.ePNOM)); } } return errors; } In the jsp I just have: html:errors/ Please help /Erik -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Differences in error validation between 1.0 and 1.1b?
Don't you have to call the method saveErrors() ? Regards, Ronald - Original Message - From: Billerby Erik [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, September 30, 2002 2:29 PM Subject: Differences in error validation between 1.0 and 1.1b? I have recently upgraded to struts 1.1b and I notice that all error messages stored in ActionErrors from the validate-method of the form bean has disappeared when trying to display them using html:errors/. The only change I have made is upgrading struts. Something has happened. What? Here is my validate-code: public org.apache.struts.action.ActionErrors validate( org.apache.struts.action.ActionMapping mapping, javax.servlet.http.HttpServletRequest request) { ActionErrors errors = new ActionErrors(); request. if (save.equalsIgnoreCase(action)) { if (.equalsIgnoreCase(getPartNo())) { errors.add(partNo, new ActionError(Part.ePNOM)); } } return errors; } In the jsp I just have: html:errors/ Please help /Erik -- 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: Differences in error validation between 1.0 and 1.1b?
2002. szeptember 30. 14:36 dátummal Ronald Rotteveel ezt írtad: Don't you have to call the method saveErrors() ? No. Not in the validate method. It returns ActionErrors. Do you have the appropriate message in your resourcebundle? Tib -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
html:hidden fields
All: I have what seems to be a fairly common situation which is not producing the results I expected: On my JSPs and in my ActionForms, I have a field which represents an artificial key for a database table. On an update, this field will have a value, but on a create, it must be null. I populate the ActionForm from a data bean, and as long as the field on my JSP is an html:text, everything works fine -- the form gets populated, and, on a commit (for an update), the key gets populated in the data bean just before the database operation. However, I don't really want my users to see the artificial key or, indeed, even know that there is such a thing, so I changed the field on the JSP to an html:hidden. Now the value in the data bean no longer gets populated. This doesn't seem to be a function of the BeanUtils.populate() method, since the API documentation simply says that that all properties of the source bean for which the target bean has a property of the same name -- and a corresponding setter method -- will be transferred. Okay, my key field passes that test. Can anyone tell me why it doesn't get transferred to the data bean? Charles McClain Phone: 603.659.2046 email:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: html:hidden fields
On Mon, 30 Sep 2002, Charles McClain wrote: I have what seems to be a fairly common situation which is not producing the results I expected: On my JSPs and in my ActionForms, I have a field which represents an artificial key for a database table. On an update, this field will have a value, but on a create, it must be null. I populate the ActionForm from a data bean, and as long as the field on my JSP is an html:text, everything works fine -- the form gets populated, and, on a commit (for an update), the key gets populated in the data bean just before the database operation. Is the only change you made going from html:text property=field/ to html:hidden property=field/ ? Make sure you still have the field inside the form tags. Also, take a look at the page source and see if the value is correct in the code and that it exists. dave -- Dave Weis I believe there are more instances of the abridgment [EMAIL PROTECTED] of the freedom of the people by gradual and silent encroachments of those in power than by violent and sudden usurpations.- James Madison -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Differences in error validation between 1.0 and 1.1b?
Thanks! That did the job! Before I saw a message like this ???en.Part.partNo??? instead of the message, but it seems like they fixed that. Regards /Erik -Original Message- From: Gemes Tibor [mailto:[EMAIL PROTECTED]] Sent: den 30 september 2002 14:43 To: Struts Users Mailing List Subject: Re: Differences in error validation between 1.0 and 1.1b? 2002. szeptember 30. 14:36 dátummal Ronald Rotteveel ezt írtad: Don't you have to call the method saveErrors() ? No. Not in the validate method. It returns ActionErrors. Do you have the appropriate message in your resourcebundle? Tib -- 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: to the bookstore!
Vincent, I highly reccomend Patterns of Enterprise Application Architecture, by Martin Fowler. I'm not sure if it's published yet, but you can read most of it on his web site (www.martinfowler.com/isa). It compliments Core J2EE Patterns very well. - Jeff -Original Message- From: Vincent Stoessel [mailto:[EMAIL PROTECTED]] Sent: Friday, September 27, 2002 5:49 PM To: Struts Users Subject: to the bookstore! I am going to the bookstore this weekend. Any struts/jsp/j2ee/patterns related recommendations? I was thinking about picking up Core J2EE Patterns to learn more about DAO and other recommended patterns. I got Masterering Jakarta Struts, btw. It is a great book for a beginner like me. I use is as a reference while I build struts apps and read a chapter a day on the train to work. -- Vincent Stoessel Linux Systems Developer vincent xaymaca.com -- 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]
SURVEY: Proper Way To Pre-populate ActionForms
I was wondering what the overall philosophy is in the Struts Users community in regards to pre-populating action forms? I sent a message out late last week asking for help on how to manually instantiate and pre-populate an action form (prior to forwarding to a JS) in Struts 1.1. That's when I realized this may be considered bad practice. Here are some comments I received: Eddie Bush: No, no. Actions/Forms have a contract -- the form 'will' be created. You should not take this upon yourself. What you need to do is pre-face the page with a 'populate' action. Expect it to be there James Turner: I can still point to cases where you need to manually pre-populate. For example, if you have multiple forms on a single JSP page, you either need to pre-populate the forms manually, or you'd have to daisy-chain a bunch of actions together, each one of which was responsible for pre-populating a single form. This seems clumsy to me. Maybe what we need is an authoritative way (i.e., an API) to instantiate DynaForms. What are others doing here? BTW, if manually pre-populating an action form is acceptable, does it make sense to create a method in the RequestUtils package making this easy to do for a DynaForm (Struts 1.1). For example (code provided by James Turner): ApplicationConfig appConfig = (ApplicationConfig)request.getAttribute(Action.APPLICATION_KEY); FormBeanConfig formBeanConfig = appConfig.findFormBeanConfig(myDynaActionForm); String beanType = formBeanConfig.getType(); DynaActionForm bean; DynaActionFormClass formClass = DynaActionFormClass.createDynaActionFormClass(formBeanConfig); return (DynaActionForm) formClass.newInstance(); Thanks! JOHN -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: html:hidden fields
Dave: My apologies. I just now changed the fields to html:hidden, and the screen still works. I encountered this problem early on in converting my application to Struts, and I just made the fields html:text during development as a workaround, since it was useful to display the keys for testing anyway. I should have re-tested before I posted my question. I suspect that, as you indicated, I may have had the fields outside the form in an attempt to bury them in some unused piece of screen real estate. Anyway, thanks for the reply. Your implication that it should work at least prompted me to go back and re-test. -Original Message- From: Dave Weis [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 8:49 AM To: Struts Users Mailing List Subject: Re: html:hidden fields On Mon, 30 Sep 2002, Charles McClain wrote: I have what seems to be a fairly common situation which is not producing the results I expected: On my JSPs and in my ActionForms, I have a field which represents an artificial key for a database table. On an update, this field will have a value, but on a create, it must be null. I populate the ActionForm from a data bean, and as long as the field on my JSP is an html:text, everything works fine -- the form gets populated, and, on a commit (for an update), the key gets populated in the data bean just before the database operation. Is the only change you made going from html:text property=field/ to html:hidden property=field/ ? Make sure you still have the field inside the form tags. Also, take a look at the page source and see if the value is correct in the code and that it exists. dave -- Dave Weis I believe there are more instances of the abridgment [EMAIL PROTECTED] of the freedom of the people by gradual and silent encroachments of those in power than by violent and sudden usurpations.- James Madison -- 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: logic:iterate with nested html:img
Awesome! No problem ;-) Vinh Tran wrote: Eddie: I figured out that EL is working fine and it does indeed work with all types of tags. Thanks again. Vinh -- Eddie Bush -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: About Datasource
You can define multiple datasources in struts-config.xml by having mulitple datasource elements inside the datasources element. You need to give each datasource a unique name (or key) so that you can retrieve them from the ServletContext to use them. See the struts dtd for the syntax of the datasource element. Dave From: Kalaiselvan [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Subject: About Datasource Date: Mon, 30 Sep 2002 14:48:18 +0530 Hii All, Any one know how to get multiple Datasource from Struts. Because i think in Struts-config.xml, we are able to specify only one Datasource. Also I got an error when I configure my datasources in tomcat's sever.xml context /context I couldnt able to get that datasource name in my Strtus's application.But my ordinary application can able to ge the Datasources from server.xml. Why this is happend??? Thanx in Advance Kalaiselvna.S _ Send and receive Hotmail on your mobile device: http://mobile.msn.com -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: SURVEY: Proper Way To Pre-populate ActionForms
I do the same as Eddie. Put an action in front of the form that sets its initial values. Dave From: Hohlen, John [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: Struts-Help (E-mail) [EMAIL PROTECTED] CC: '[EMAIL PROTECTED]' [EMAIL PROTECTED] Subject: SURVEY: Proper Way To Pre-populate ActionForms Date: Mon, 30 Sep 2002 08:22:29 -0500 I was wondering what the overall philosophy is in the Struts Users community in regards to pre-populating action forms? I sent a message out late last week asking for help on how to manually instantiate and pre-populate an action form (prior to forwarding to a JS) in Struts 1.1. That's when I realized this may be considered bad practice. Here are some comments I received: Eddie Bush: No, no. Actions/Forms have a contract -- the form 'will' be created. You should not take this upon yourself. What you need to do is pre-face the page with a 'populate' action. Expect it to be there James Turner: I can still point to cases where you need to manually pre-populate. For example, if you have multiple forms on a single JSP page, you either need to pre-populate the forms manually, or you'd have to daisy-chain a bunch of actions together, each one of which was responsible for pre-populating a single form. This seems clumsy to me. Maybe what we need is an authoritative way (i.e., an API) to instantiate DynaForms. What are others doing here? BTW, if manually pre-populating an action form is acceptable, does it make sense to create a method in the RequestUtils package making this easy to do for a DynaForm (Struts 1.1). For example (code provided by James Turner): ApplicationConfig appConfig = (ApplicationConfig)request.getAttribute(Action.APPLICATION_KEY); FormBeanConfig formBeanConfig = appConfig.findFormBeanConfig(myDynaActionForm); String beanType = formBeanConfig.getType(); DynaActionForm bean; DynaActionFormClass formClass = DynaActionFormClass.createDynaActionFormClass(formBeanConfig); return (DynaActionForm) formClass.newInstance(); Thanks! JOHN -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] _ MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: SURVEY: Proper Way To Pre-populate ActionForms
Me too. -Mensaje original- De: David Graham [mailto:[EMAIL PROTECTED]] Enviado el: lunes, 30 de septiembre de 2002 15:34 Para: [EMAIL PROTECTED] Asunto: Re: SURVEY: Proper Way To Pre-populate ActionForms I do the same as Eddie. Put an action in front of the form that sets its initial values. Dave From: Hohlen, John [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: Struts-Help (E-mail) [EMAIL PROTECTED] CC: '[EMAIL PROTECTED]' [EMAIL PROTECTED] Subject: SURVEY: Proper Way To Pre-populate ActionForms Date: Mon, 30 Sep 2002 08:22:29 -0500 I was wondering what the overall philosophy is in the Struts Users community in regards to pre-populating action forms? I sent a message out late last week asking for help on how to manually instantiate and pre-populate an action form (prior to forwarding to a JS) in Struts 1.1. That's when I realized this may be considered bad practice. Here are some comments I received: Eddie Bush: No, no. Actions/Forms have a contract -- the form 'will' be created. You should not take this upon yourself. What you need to do is pre-face the page with a 'populate' action. Expect it to be there James Turner: I can still point to cases where you need to manually pre-populate. For example, if you have multiple forms on a single JSP page, you either need to pre-populate the forms manually, or you'd have to daisy-chain a bunch of actions together, each one of which was responsible for pre-populating a single form. This seems clumsy to me. Maybe what we need is an authoritative way (i.e., an API) to instantiate DynaForms. What are others doing here? BTW, if manually pre-populating an action form is acceptable, does it make sense to create a method in the RequestUtils package making this easy to do for a DynaForm (Struts 1.1). For example (code provided by James Turner): ApplicationConfig appConfig = (ApplicationConfig)request.getAttribute(Action.APPLICATION_KEY); FormBeanConfig formBeanConfig = appConfig.findFormBeanConfig(myDynaActionForm); String beanType = formBeanConfig.getType(); DynaActionForm bean; DynaActionFormClass formClass = DynaActionFormClass.createDynaActionFormClass(formBeanConfig); return (DynaActionForm) formClass.newInstance(); Thanks! JOHN -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] _ MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx -- 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: all this traffic
Setting up your mail reader to automatically forward STRUTS-USER messages to a separate folder, and then sorting by thread, is a trivially easy approach to dealing with volume issues. Your inbox is no longer clogged, you can go read Struts mail when you have time, and can ignore entire irrelevant threads with a single command to advance to the next thread. Indeed, that is in fact my method of choice for using this list. All one has to do is look at subject headers to asses interest and move on. I usually read everything I want to read and then delete the contents of the folder. There are some drawbacks to this approach [or any client-based solution] though, most notably if you have low size limits on your mail account or if you access your mail remotely on a regular basis (ie. a traveller). Sitting in a hotel room waiting to communicate with Exchange (or worse POP3) becomes rather burdensome when there are 1k+ unread messages in the Struts folder. Overall, still the best approach, but I can definitely see why some people might want to reduce volume. However, I'm not big on the struts-newbie list idea myself. -Chris -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Serving XML and dynamically generated Flash (jgenerator) contentwith struts
[EMAIL PROTECTED] wrote: Hi, there! I?m kinda new to struts and have a few questions regarding it: 1. is it possible to serve xml using struts? We're currently using 'stand-alone servlets to generate xml that'sread by flash movies, but we're seeing a need for things like internationalisation and application flow. Yes. I hear stxx is good (I haven't tried it though) Is there a way of avoiding the jsp's in the view layer and use servlets (which are way better suited for xml than jsp's) JSPs are servlets ;-) ... check out stxx I've checked the archives, but it's real hard to find any good answers... Always run your questions through Google. You will be literally *amazed* at how many hits you get on the mail archive :-) 2. We're also using jgenerator to generate dynamic flash - only those of you knowing jgenerator should answer to this question - Where in the mvc-model / struts architecture would it make sense to generate flash content? Any advice would be appreciated, Cheers, Stef. -- Eddie Bush -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Serving XML and dynamically generated Flash (jgenerator) content with struts
Thanks for the tip! However, I do not want to transform the xml ... I want a flash-movie to interpret it and transform it into flash-objects (I really just want to return content of type text/xml to the user. Is there something like a xslt no-op? Now, let's say stxx solves my problem related to XML. How do I return other mime-types like pdf for instance? Cheers, Stef. -Original Message- From: Jeff Pennal [mailto:[EMAIL PROTECTED]] Sent: Montag, 30. September 2002 14:09 To: Struts Users Mailing List Subject: Re: Serving XML and dynamically generated Flash (jgenerator) content with struts Hi Stefan, You may want to check out stxx. From your email it seems like it should do everything you need it to do. stxx - http://www.openroad.ca/opencode/stxx [EMAIL PROTECTED] wrote: Hi, there! I'm kinda new to struts and have a few questions regarding it: 1. is it possible to serve xml using struts? We're currently using 'stand-alone servlets to generate xml that'sread by flash movies, but we're seeing a need for things like internationalisation and application flow. Is there a way of avoiding the jsp's in the view layer and use servlets (which are way better suited for xml than jsp's) I've checked the archives, but it's real hard to find any good answers... 2. We're also using jgenerator to generate dynamic flash - only those of you knowing jgenerator should answer to this question - Where in the mvc-model / struts architecture would it make sense to generate flash content? Any advice would be appreciated, Cheers, Stef. -- 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]
RE: Serving XML and dynamically generated Flash (jgenerator) content with struts
in your action class: PrintWriter out = new PrintWriter (response.getOutputStream()); out.println(yourXmlString); return null; Joe -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Tuesday, 1 October 2002 12:03 AM To: [EMAIL PROTECTED] Subject: RE: Serving XML and dynamically generated Flash (jgenerator) content with struts Thanks for the tip! However, I do not want to transform the xml ... I want a flash-movie to interpret it and transform it into flash-objects (I really just want to return content of type text/xml to the user. Is there something like a xslt no-op? Now, let's say stxx solves my problem related to XML. How do I return other mime-types like pdf for instance? Cheers, Stef. -Original Message- From: Jeff Pennal [mailto:[EMAIL PROTECTED]] Sent: Montag, 30. September 2002 14:09 To: Struts Users Mailing List Subject: Re: Serving XML and dynamically generated Flash (jgenerator) content with struts Hi Stefan, You may want to check out stxx. From your email it seems like it should do everything you need it to do. stxx - http://www.openroad.ca/opencode/stxx [EMAIL PROTECTED] wrote: Hi, there! I'm kinda new to struts and have a few questions regarding it: 1. is it possible to serve xml using struts? We're currently using 'stand-alone servlets to generate xml that'sread by flash movies, but we're seeing a need for things like internationalisation and application flow. Is there a way of avoiding the jsp's in the view layer and use servlets (which are way better suited for xml than jsp's) I've checked the archives, but it's real hard to find any good answers... 2. We're also using jgenerator to generate dynamic flash - only those of you knowing jgenerator should answer to this question - Where in the mvc-model / struts architecture would it make sense to generate flash content? Any advice would be appreciated, Cheers, Stef. -- 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]
RE: Serving XML and dynamically generated Flash (jgenerator) content with struts
You can also set the content type in your response object like so: response.setContentType(text\html); response.setContentType(text\pdf); etc... -Original Message- From: Joe Latty [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 10:34 AM To: Struts Users Mailing List Subject: RE: Serving XML and dynamically generated Flash (jgenerator) content with struts in your action class: PrintWriter out = new PrintWriter (response.getOutputStream()); out.println(yourXmlString); return null; Joe -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Tuesday, 1 October 2002 12:03 AM To: [EMAIL PROTECTED] Subject: RE: Serving XML and dynamically generated Flash (jgenerator) content with struts Thanks for the tip! However, I do not want to transform the xml ... I want a flash-movie to interpret it and transform it into flash-objects (I really just want to return content of type text/xml to the user. Is there something like a xslt no-op? Now, let's say stxx solves my problem related to XML. How do I return other mime-types like pdf for instance? Cheers, Stef. -Original Message- From: Jeff Pennal [mailto:[EMAIL PROTECTED]] Sent: Montag, 30. September 2002 14:09 To: Struts Users Mailing List Subject: Re: Serving XML and dynamically generated Flash (jgenerator) content with struts Hi Stefan, You may want to check out stxx. From your email it seems like it should do everything you need it to do. stxx - http://www.openroad.ca/opencode/stxx [EMAIL PROTECTED] wrote: Hi, there! I'm kinda new to struts and have a few questions regarding it: 1. is it possible to serve xml using struts? We're currently using 'stand-alone servlets to generate xml that'sread by flash movies, but we're seeing a need for things like internationalisation and application flow. Is there a way of avoiding the jsp's in the view layer and use servlets (which are way better suited for xml than jsp's) I've checked the archives, but it's real hard to find any good answers... 2. We're also using jgenerator to generate dynamic flash - only those of you knowing jgenerator should answer to this question - Where in the mvc-model / struts architecture would it make sense to generate flash content? Any advice would be appreciated, Cheers, Stef. -- 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] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
[OT - Java] How can I do this in Java?
OK - off topic, but Sun's java forum sucks, and there are an incredible number of Java guru's on this list, so I thought I'd throw this out here. (That and I am using this in a custom validation routine :-))Any help would be GREATLY appreciated! Here's the scenario - I've got a series of static constants that represent Java regular expressions. These RE's are used to validate driver license formats for the 50 states + DC. The strings look like this: public static final String AK = ^[0-9]{1,7}$; public static final String AL = ^[0-9]{7}$; public static final String AR = ^[0-9]{8,9}$; public static final String AZ = ^[0-9ABDY][0-9]{8}$|^[A-Z][0-9]{3,6}$|^[A-Z]{2}[0-9]{3,5}$; public static final String CA = ^[A-Z][0-9]{4,7}$; public static final String CO = ^[A-Z][0-9]{1,6}$|^[A-Z]{2}[0-9]{1,6}$|^[0-9]{9}$; etc. etc. etc. On my form I have a drop-down box of states, and a field for the license number. In my custom validator routine, I pick up the value of the state, and build a string to represent the constant - i.e. private static boolean validateDriversLicenseNumber(String licenseState, String licenseNumber) { String licenseConstant = Constants. + licenseState; I then want to use licenseConstant in a Pattern / Match: Pattern p = Pattern.compile(licenseConstant, Pattern.CASE_INSENSITIVE); Match m = p.matcher(licenseNumber); return (m.find()); } Obviously the line String licenseConstant = Constants. + licenseState; does not give me the value of Constant.state name; the question I have is, is there a method (or something) that will allow me to build such a string, and return the value (i.e. the regular expression)? Or is there a better way of doing this? TIA! Jerry Jalenak Web Publishing LabOne, Inc. 10101 Renner Blvd. Lenexa, KS 66219 (913) 577-1496 [EMAIL PROTECTED] This transmission (and any information attached to it) may be confidential and is intended solely for the use of the individual or entity to which it is addressed. If you are not the intended recipient or the person responsible for delivering the transmission to the intended recipient, be advised that you have received this transmission in error and that any use, dissemination, forwarding, printing, or copying of this information is strictly prohibited. If you have received this transmission in error, please immediately notify LabOne at (800)388-4675. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: [OT - Java] How can I do this in Java?
sounds like a job for reflection (java.lang.reflect.*;) Have you looked at java.lang.Class and java.lang.reflect.Field? -Original Message- From: Jerry Jalenak [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 7:50 AM To: '[EMAIL PROTECTED]' Subject: [OT - Java] How can I do this in Java? OK - off topic, but Sun's java forum sucks, and there are an incredible number of Java guru's on this list, so I thought I'd throw this out here. (That and I am using this in a custom validation routine :-))Any help would be GREATLY appreciated! Here's the scenario - I've got a series of static constants that represent Java regular expressions. These RE's are used to validate driver license formats for the 50 states + DC. The strings look like this: public static final String AK = ^[0-9]{1,7}$; public static final String AL = ^[0-9]{7}$; public static final String AR = ^[0-9]{8,9}$; public static final String AZ = ^[0-9ABDY][0-9]{8}$|^[A-Z][0-9]{3,6}$|^[A-Z]{2}[0-9]{3,5}$; public static final String CA = ^[A-Z][0-9]{4,7}$; public static final String CO = ^[A-Z][0-9]{1,6}$|^[A-Z]{2}[0-9]{1,6}$|^[0-9]{9}$; etc. etc. etc. On my form I have a drop-down box of states, and a field for the license number. In my custom validator routine, I pick up the value of the state, and build a string to represent the constant - i.e. private static boolean validateDriversLicenseNumber(String licenseState, String licenseNumber) { String licenseConstant = Constants. + licenseState; I then want to use licenseConstant in a Pattern / Match: Pattern p = Pattern.compile(licenseConstant, Pattern.CASE_INSENSITIVE); Match m = p.matcher(licenseNumber); return (m.find()); } Obviously the line String licenseConstant = Constants. + licenseState; does not give me the value of Constant.state name; the question I have is, is there a method (or something) that will allow me to build such a string, and return the value (i.e. the regular expression)? Or is there a better way of doing this? TIA! Jerry Jalenak Web Publishing LabOne, Inc. 10101 Renner Blvd. Lenexa, KS 66219 (913) 577-1496 [EMAIL PROTECTED] This transmission (and any information attached to it) may be confidential and is intended solely for the use of the individual or entity to which it is addressed. If you are not the intended recipient or the person responsible for delivering the transmission to the intended recipient, be advised that you have received this transmission in error and that any use, dissemination, forwarding, printing, or copying of this information is strictly prohibited. If you have received this transmission in error, please immediately notify LabOne at (800)388-4675. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Property errors.prefix not used by HTML:errors ?
What version of struts are you using? James Mitchell Software Engineer\Struts Evangelist Struts-Atlanta, the Open Minded Developer Network http://www.open-tools.org/struts-atlanta -Original Message- From: Pel Oliver Kristiansen [mailto:[EMAIL PROTECTED]] Sent: Sunday, September 29, 2002 5:46 PM To: [EMAIL PROTECTED] Subject: Property errors.prefix not used by HTML:errors ? Hi all ! Complete newbe trying to get the html:errors to print pretty. I include the following into my ApplicationResources.properties errors.header=Feil oppstod!font color=red errors.prefix=* errors.sufffix=br errors.header=/font (ignore the lame tags they are just for testing) The errors.header and errors.header are displayed but the errors.prefix and errors.sufffix are not. (HTML example output:) Feil oppstod!font color=red Feltet inneholder for mye informasjon Feltet Navn er ikke utfyllt /font Any pointers ? Pel O. Kristiansen Join 18 million Eudora users by signing up for a free Eudora Web-Mail account at http://www.eudoramail.com -- 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: [OT - Java] How can I do this in Java?
Jason, Thanks for the quick reply. I just took at look at the API's, but don't yet understand enough about reflection to know how to implement it. Just looking at the methods I don't see a way to do what I want - any chance that you'd have some sample code laying about? Jerry -Original Message- From: Taylor, Jason [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 9:59 AM To: 'Struts Users Mailing List' Subject: RE: [OT - Java] How can I do this in Java? sounds like a job for reflection (java.lang.reflect.*;) Have you looked at java.lang.Class and java.lang.reflect.Field? -Original Message- From: Jerry Jalenak [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 7:50 AM To: '[EMAIL PROTECTED]' Subject: [OT - Java] How can I do this in Java? OK - off topic, but Sun's java forum sucks, and there are an incredible number of Java guru's on this list, so I thought I'd throw this out here. (That and I am using this in a custom validation routine :-))Any help would be GREATLY appreciated! Here's the scenario - I've got a series of static constants that represent Java regular expressions. These RE's are used to validate driver license formats for the 50 states + DC. The strings look like this: public static final String AK = ^[0-9]{1,7}$; public static final String AL = ^[0-9]{7}$; public static final String AR = ^[0-9]{8,9}$; public static final String AZ = ^[0-9ABDY][0-9]{8}$|^[A-Z][0-9]{3,6}$|^[A-Z]{2}[0-9]{3,5}$; public static final String CA = ^[A-Z][0-9]{4,7}$; public static final String CO = ^[A-Z][0-9]{1,6}$|^[A-Z]{2}[0-9]{1,6}$|^[0-9]{9}$; etc. etc. etc. On my form I have a drop-down box of states, and a field for the license number. In my custom validator routine, I pick up the value of the state, and build a string to represent the constant - i.e. private static boolean validateDriversLicenseNumber(String licenseState, String licenseNumber) { String licenseConstant = Constants. + licenseState; I then want to use licenseConstant in a Pattern / Match: Pattern p = Pattern.compile(licenseConstant, Pattern.CASE_INSENSITIVE); Match m = p.matcher(licenseNumber); return (m.find()); } Obviously the line String licenseConstant = Constants. + licenseState; does not give me the value of Constant.state name; the question I have is, is there a method (or something) that will allow me to build such a string, and return the value (i.e. the regular expression)? Or is there a better way of doing this? TIA! Jerry Jalenak Web Publishing LabOne, Inc. 10101 Renner Blvd. Lenexa, KS 66219 (913) 577-1496 [EMAIL PROTECTED] This transmission (and any information attached to it) may be confidential and is intended solely for the use of the individual or entity to which it is addressed. If you are not the intended recipient or the person responsible for delivering the transmission to the intended recipient, be advised that you have received this transmission in error and that any use, dissemination, forwarding, printing, or copying of this information is strictly prohibited. If you have received this transmission in error, please immediately notify LabOne at (800)388-4675. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] This transmission (and any information attached to it) may be confidential and is intended solely for the use of the individual or entity to which it is addressed. If you are not the intended recipient or the person responsible for delivering the transmission to the intended recipient, be advised that you have received this transmission in error and that any use, dissemination, forwarding, printing, or copying of this information is strictly prohibited. If you have received this transmission in error, please immediately notify LabOne at (800)388-4675. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: About Datasource
Hi, I'm experiencing this same problem. If you have a solution, please post. Thanks, Tuan -Original Message- From: Kalaiselvan [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 2:18 AM To: Struts Users Mailing List Subject: About Datasource Hii All, Any one know how to get multiple Datasource from Struts. Because i think in Struts-config.xml, we are able to specify only one Datasource. Also I got an error when I configure my datasources in tomcat's sever.xml context /context I couldnt able to get that datasource name in my Strtus's application.But my ordinary application can able to ge the Datasources from server.xml. Why this is happend??? Thanx in Advance Kalaiselvna.S -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Access JSP in the WEB-INF
I was reading that I should put all my JSP inside the WEB-INF dir so clients cant access them without going to the controller. My issues is that How do I access them?? can someone please tell me how to setup my Action so I can display the JSP files?? -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Access JSP in the WEB-INF
Once they are under web-inf a direct access from the client will not be allowed by the container, however forwards on the server side are allowed, thus to get to the JSP you can forward to it from an Action. The benefit of this is that users will not be able to hit your JSP without first going through an Action, and thus through the struts front-controller thinghy. You can thus ensure that everything is set up that that JSP needs (ie: beans in the request etc...) or could redirect them to another jsp or action if business logic demanded it... -Original Message- From: Smith, Johnathan M. [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 23:08 To: '[EMAIL PROTECTED]' Subject: Access JSP in the WEB-INF I was reading that I should put all my JSP inside the WEB-INF dir so clients cant access them without going to the controller. My issues is that How do I access them?? can someone please tell me how to setup my Action so I can display the JSP files?? -- 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: About Datasource
Try this data-sources data-source key=DataSource1 set-property property=autoCommit value=false / set-property property=driverClass value=oracle.jdbc.driver.OracleDriver / set-property property=maxCount value=10 / set-property property=minCount value=1 / set-property property=password value=your userID / set-property property=url value=jdbc:oracle:thin:@:: / set-property property=user value=your password / /data-source data-source key=DataSource2 set-property property=autoCommit value=false / set-property property=driverClass value=oracle.jdbc.driver.OracleDriver / set-property property=maxCount value=10 / set-property property=minCount value=1 / set-property property=password value=your userID / set-property property=url value=jdbc:oracle:thin:@:: / set-property property=user value=your password / /data-source /data-sources Then in your Action you can reference the data-source by ds = (DataSource) servlet.getServletContext().getAttribute(DataSource1); // or DataSource2, etc. HTH, Jerry -Original Message- From: Tuan H. Le [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 10:08 AM To: Struts Users Mailing List Subject: RE: About Datasource Hi, I'm experiencing this same problem. If you have a solution, please post. Thanks, Tuan -Original Message- From: Kalaiselvan [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 2:18 AM To: Struts Users Mailing List Subject: About Datasource Hii All, Any one know how to get multiple Datasource from Struts. Because i think in Struts-config.xml, we are able to specify only one Datasource. Also I got an error when I configure my datasources in tomcat's sever.xml context /context I couldnt able to get that datasource name in my Strtus's application.But my ordinary application can able to ge the Datasources from server.xml. Why this is happend??? Thanx in Advance Kalaiselvna.S -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] This transmission (and any information attached to it) may be confidential and is intended solely for the use of the individual or entity to which it is addressed. If you are not the intended recipient or the person responsible for delivering the transmission to the intended recipient, be advised that you have received this transmission in error and that any use, dissemination, forwarding, printing, or copying of this information is strictly prohibited. If you have received this transmission in error, please immediately notify LabOne at (800)388-4675. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: [OT - Java] How can I do this in Java?
I don't happen to have any sample code that does exactly what you're doing, but off the top of my head (with a little help from sun's javadoc) I'd say it's something like: import java.lang.reflect.Field; String stateCode = AK; Class constantClass = Class.forName(com.yourdomain.yourapp.Constants); Field stateField = constantClass.getDeclaredField(stateCode); String stateRegExp = (String) stateField.get(constantClass); System.err.println(regexp for +stateCode+: +stateRegExp); I don't really know any more about reflection than you, I just followed the trail from java.lang.Class to java.lang.reflect.Field. Once you've done it once, you see it's no mystery-- you're just doing runtime compiling. HTH-- This is just how I'd start, as I haven't tested or used this code. If I'm wrong, I'm sure you can figure out what I missed by studying the API docs. If, on the other hand, you don't like reading javadocs and generating your own test cases, LOL! -JT -Original Message- From: Jerry Jalenak [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 8:05 AM To: 'Struts Users Mailing List' Subject: RE: [OT - Java] How can I do this in Java? Jason, Thanks for the quick reply. I just took at look at the API's, but don't yet understand enough about reflection to know how to implement it. Just looking at the methods I don't see a way to do what I want - any chance that you'd have some sample code laying about? Jerry -Original Message- From: Taylor, Jason [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 9:59 AM To: 'Struts Users Mailing List' Subject: RE: [OT - Java] How can I do this in Java? sounds like a job for reflection (java.lang.reflect.*;) Have you looked at java.lang.Class and java.lang.reflect.Field? -Original Message- From: Jerry Jalenak [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 7:50 AM To: '[EMAIL PROTECTED]' Subject: [OT - Java] How can I do this in Java? OK - off topic, but Sun's java forum sucks, and there are an incredible number of Java guru's on this list, so I thought I'd throw this out here. (That and I am using this in a custom validation routine :-))Any help would be GREATLY appreciated! Here's the scenario - I've got a series of static constants that represent Java regular expressions. These RE's are used to validate driver license formats for the 50 states + DC. The strings look like this: public static final String AK = ^[0-9]{1,7}$; public static final String AL = ^[0-9]{7}$; public static final String AR = ^[0-9]{8,9}$; public static final String AZ = ^[0-9ABDY][0-9]{8}$|^[A-Z][0-9]{3,6}$|^[A-Z]{2}[0-9]{3,5}$; public static final String CA = ^[A-Z][0-9]{4,7}$; public static final String CO = ^[A-Z][0-9]{1,6}$|^[A-Z]{2}[0-9]{1,6}$|^[0-9]{9}$; etc. etc. etc. On my form I have a drop-down box of states, and a field for the license number. In my custom validator routine, I pick up the value of the state, and build a string to represent the constant - i.e. private static boolean validateDriversLicenseNumber(String licenseState, String licenseNumber) { String licenseConstant = Constants. + licenseState; I then want to use licenseConstant in a Pattern / Match: Pattern p = Pattern.compile(licenseConstant, Pattern.CASE_INSENSITIVE); Match m = p.matcher(licenseNumber); return (m.find()); } Obviously the line String licenseConstant = Constants. + licenseState; does not give me the value of Constant.state name; the question I have is, is there a method (or something) that will allow me to build such a string, and return the value (i.e. the regular expression)? Or is there a better way of doing this? TIA! Jerry Jalenak Web Publishing LabOne, Inc. 10101 Renner Blvd. Lenexa, KS 66219 (913) 577-1496 [EMAIL PROTECTED] This transmission (and any information attached to it) may be confidential and is intended solely for the use of the individual or entity to which it is addressed. If you are not the intended recipient or the person responsible for delivering the transmission to the intended recipient, be advised that you have received this transmission in error and that any use, dissemination, forwarding, printing, or copying of this information is strictly prohibited. If you have received this transmission in error, please immediately notify LabOne at (800)388-4675. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] This transmission (and any information attached to it) may be confidential and is intended solely for the use of the individual or entity to which it is addressed. If you are not the intended recipient or the person responsible for delivering the transmission to the intended
RE: all this traffic
Since March of 2001, there has been almost 27K emails sent to the list. Why the continuous pouring of emails? Maybe another technique has to be developed for people to research problems. By the way - the separate folder technique works until you take a trip for week and things get back logged. - Malcolm -Original Message- From: Assenza, Chris [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 8:43 AM To: 'Struts Users Mailing List' Subject: RE: all this traffic Setting up your mail reader to automatically forward STRUTS-USER messages to a separate folder, and then sorting by thread, is a trivially easy approach to dealing with volume issues. Your inbox is no longer clogged, you can go read Struts mail when you have time, and can ignore entire irrelevant threads with a single command to advance to the next thread. Indeed, that is in fact my method of choice for using this list. All one has to do is look at subject headers to asses interest and move on. I usually read everything I want to read and then delete the contents of the folder. There are some drawbacks to this approach [or any client-based solution] though, most notably if you have low size limits on your mail account or if you access your mail remotely on a regular basis (ie. a traveller). Sitting in a hotel room waiting to communicate with Exchange (or worse POP3) becomes rather burdensome when there are 1k+ unread messages in the Struts folder. Overall, still the best approach, but I can definitely see why some people might want to reduce volume. However, I'm not big on the struts-newbie list idea myself. -Chris -- 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: [OT - Java] How can I do this in Java?
On Mon, Sep 30, 2002 at 07:59:18AM -0700, Taylor, Jason wrote: sounds like a job for reflection (java.lang.reflect.*;) Have you looked at java.lang.Class and java.lang.reflect.Field? I suppose reflection would work, but what's wrong with a simple HashMap or possibly even a simple array as a lookup table? (Of course, I wouldn't put the HashMap itself in any public API, but even doing that is better than using reflection, IMO.) If you just make your states ints or some data type that can return a simple int identifier, you can use them as indexes into an array of the regexp string. If you don't like that approach, simply build a HashMap with the state as the key, and the regexp string as the value. // Simple example of using the HashMap that lets you keep // the API you've shown us, and you don't have to resort to // using reflection. public class StateAbbrToLicenseRegExpThingy { private static final HashMap s_stateToLicenseRE = new HashMap(); static { s_stateToLicenseRE.put(AK, ^[0-9]{1,7}$); s_stateToLicenseRE.put(AL, ^[0-9]{7}$); s_stateToLicenseRE.put(AR, ^[0-9]{8,9}$); // etc. } public static String getLicenseRegExpForState(String state) { // Add error checking as desired here. return (String)s_stateToLicenseRE.get(state); } } -Original Message- From: Jerry Jalenak [mailto:[EMAIL PROTECTED]] OK - off topic, but Sun's java forum sucks, and there are an incredible number of Java guru's on this list, so I thought I'd throw this out here. (That and I am using this in a custom validation routine :-)) Any help would be GREATLY appreciated! Here's the scenario - I've got a series of static constants that represent Java regular expressions. These RE's are used to validate driver license formats for the 50 states + DC. The strings look like this: public static final String AK = ^[0-9]{1,7}$; public static final String AL = ^[0-9]{7}$; public static final String AR = ^[0-9]{8,9}$; On my form I have a drop-down box of states, and a field for the license number. In my custom validator routine, I pick up the value of the state, and build a string to represent the constant - i.e. private static boolean validateDriversLicenseNumber(String licenseState, String licenseNumber) { String licenseConstant = Constants. + licenseState; I then want to use licenseConstant in a Pattern / Match: Pattern p = Pattern.compile(licenseConstant, Pattern.CASE_INSENSITIVE); Match m = p.matcher(licenseNumber); return (m.find()); } Obviously the line String licenseConstant = Constants. + licenseState; does not give me the value of Constant.state name ; the question I have is, is there a method (or something) that will allow me to build such a string, and return the value (i.e. the regular expression)? Or is there a better way of doing this? Use a lookup table as shown above to get the regexp for the state. Cheers, John -- end of line -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: html:hidden fields
The server cannot tell the difference between an input field that was visible (html:text) and invisible (html:hidden) -- when the form is submitted, they both look the same. Therefore, your problem is being caused by something else. Likely culprits: * No setter method (or a case match problem). * More than one setter method with different datatypes (this is not allowed by the JavaBeans spec, so it will cause Java to think there is no such property on this bean). Craig On Mon, 30 Sep 2002, Charles McClain wrote: Date: Mon, 30 Sep 2002 08:40:53 -0400 From: Charles McClain [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: Struts User Mailing List [EMAIL PROTECTED] Subject: html:hidden fields All: I have what seems to be a fairly common situation which is not producing the results I expected: On my JSPs and in my ActionForms, I have a field which represents an artificial key for a database table. On an update, this field will have a value, but on a create, it must be null. I populate the ActionForm from a data bean, and as long as the field on my JSP is an html:text, everything works fine -- the form gets populated, and, on a commit (for an update), the key gets populated in the data bean just before the database operation. However, I don't really want my users to see the artificial key or, indeed, even know that there is such a thing, so I changed the field on the JSP to an html:hidden. Now the value in the data bean no longer gets populated. This doesn't seem to be a function of the BeanUtils.populate() method, since the API documentation simply says that that all properties of the source bean for which the target bean has a property of the same name -- and a corresponding setter method -- will be transferred. Okay, my key field passes that test. Can anyone tell me why it doesn't get transferred to the data bean? Charles McClain Phone: 603.659.2046 email:[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]
RE: Access JSP in the WEB-INF
Im in a bit of a rush right now to try and get a taxi home before the midnight charge kicks in, but Im sure there are many others out there who can give you a good example (right guys???) -Original Message- From: Smith, Johnathan M. [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 23:34 To: '[EMAIL PROTECTED]' Subject: RE: Access JSP in the WEB-INF Can you send me a sample on how to do this in my action -Original Message- From: Andrew Hill [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 11:14 AM To: Struts Users Mailing List Subject: RE: Access JSP in the WEB-INF Once they are under web-inf a direct access from the client will not be allowed by the container, however forwards on the server side are allowed, thus to get to the JSP you can forward to it from an Action. The benefit of this is that users will not be able to hit your JSP without first going through an Action, and thus through the struts front-controller thinghy. You can thus ensure that everything is set up that that JSP needs (ie: beans in the request etc...) or could redirect them to another jsp or action if business logic demanded it... -Original Message- From: Smith, Johnathan M. [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 23:08 To: '[EMAIL PROTECTED]' Subject: Access JSP in the WEB-INF I was reading that I should put all my JSP inside the WEB-INF dir so clients cant access them without going to the controller. My issues is that How do I access them?? can someone please tell me how to setup my Action so I can display the JSP files?? -- 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: [OT - Java] How can I do this in Java?
Jason - Thanks for the code snippet - worked like a charm first time! I tend to get lost in JavaDoc sometimes, so this was a nice example to have on how to wind my way through to the answer! Thanks again! John - Thanks for the suggestion on using the HashMap. I'm going to file it away for now and use Jason's reflection method - but it never hurts to have a couple of different methods to use on something like this! Thanks guys! Jerry -Original Message- From: Taylor, Jason [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 10:28 AM To: 'Struts Users Mailing List' Subject: RE: [OT - Java] How can I do this in Java? I don't happen to have any sample code that does exactly what you're doing, but off the top of my head (with a little help from sun's javadoc) I'd say it's something like: import java.lang.reflect.Field; String stateCode = AK; Class constantClass = Class.forName(com.yourdomain.yourapp.Constants); Field stateField = constantClass.getDeclaredField(stateCode); String stateRegExp = (String) stateField.get(constantClass); System.err.println(regexp for +stateCode+: +stateRegExp); I don't really know any more about reflection than you, I just followed the trail from java.lang.Class to java.lang.reflect.Field. Once you've done it once, you see it's no mystery-- you're just doing runtime compiling. HTH-- This is just how I'd start, as I haven't tested or used this code. If I'm wrong, I'm sure you can figure out what I missed by studying the API docs. If, on the other hand, you don't like reading javadocs and generating your own test cases, LOL! -JT -Original Message- From: Jerry Jalenak [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 8:05 AM To: 'Struts Users Mailing List' Subject: RE: [OT - Java] How can I do this in Java? Jason, Thanks for the quick reply. I just took at look at the API's, but don't yet understand enough about reflection to know how to implement it. Just looking at the methods I don't see a way to do what I want - any chance that you'd have some sample code laying about? Jerry -Original Message- From: Taylor, Jason [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 9:59 AM To: 'Struts Users Mailing List' Subject: RE: [OT - Java] How can I do this in Java? sounds like a job for reflection (java.lang.reflect.*;) Have you looked at java.lang.Class and java.lang.reflect.Field? -Original Message- From: Jerry Jalenak [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 7:50 AM To: '[EMAIL PROTECTED]' Subject: [OT - Java] How can I do this in Java? OK - off topic, but Sun's java forum sucks, and there are an incredible number of Java guru's on this list, so I thought I'd throw this out here. (That and I am using this in a custom validation routine :-))Any help would be GREATLY appreciated! Here's the scenario - I've got a series of static constants that represent Java regular expressions. These RE's are used to validate driver license formats for the 50 states + DC. The strings look like this: public static final String AK = ^[0-9]{1,7}$; public static final String AL = ^[0-9]{7}$; public static final String AR = ^[0-9]{8,9}$; public static final String AZ = ^[0-9ABDY][0-9]{8}$|^[A-Z][0-9]{3,6}$|^[A-Z]{2}[0-9]{3,5}$; public static final String CA = ^[A-Z][0-9]{4,7}$; public static final String CO = ^[A-Z][0-9]{1,6}$|^[A-Z]{2}[0-9]{1,6}$|^[0-9]{9}$; etc. etc. etc. On my form I have a drop-down box of states, and a field for the license number. In my custom validator routine, I pick up the value of the state, and build a string to represent the constant - i.e. private static boolean validateDriversLicenseNumber(String licenseState, String licenseNumber) { String licenseConstant = Constants. + licenseState; I then want to use licenseConstant in a Pattern / Match: Pattern p = Pattern.compile(licenseConstant, Pattern.CASE_INSENSITIVE); Match m = p.matcher(licenseNumber); return (m.find()); } Obviously the line String licenseConstant = Constants. + licenseState; does not give me the value of Constant.state name; the question I have is, is there a method (or something) that will allow me to build such a string, and return the value (i.e. the regular expression)? Or is there a better way of doing this? TIA! Jerry Jalenak Web Publishing LabOne, Inc. 10101 Renner Blvd. Lenexa, KS 66219 (913) 577-1496 [EMAIL PROTECTED] This transmission (and any information attached to it) may be confidential and is intended solely for the use of the individual or entity to which it is addressed. If you are not the intended
RE: html:options
The first technique couples your presentation with your business logic more closely than does the latter. So, my preference would be using the html:options. You can maintain the collection that makes up the options in the form bean for the page. Initialization must be handled via the associated action class. Sri -Original Message- From: Doug Dates [mailto:[EMAIL PROTECTED]] Sent: Sunday, September 29, 2002 8:35 PM To: Struts Users Mailing List Subject: html:options I want to display a dropdown list. The list items are By First Name, By Last Name, By Date. I think I can do it by the following way: html:select size=1 property=choice html:option value=fName By First Name /html:option html:option value=fName By Last Name /html:option html:option value=fName By Date /html:option /html:select Is there any disadvantages to use above approach compared with using html:options...? If I use html:options ... instead of using above individual html:option...,as following: html:select property=choice size=1 html:options collection=%= myArrayList % property=value labelProperty=label/ /html:select where should I set myArrayList? in init method of my servlet class, or in my action form bean, or somewhere else? I am not quite understand it. Could some one please help me? Thank you Doug __ Post your free ad now! http://personals.yahoo.ca -- 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: all this traffic
On Mon, 30 Sep 2002, Malcolm Davis wrote: Date: Mon, 30 Sep 2002 10:41:53 -0500 From: Malcolm Davis [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Subject: RE: all this traffic Since March of 2001, there has been almost 27K emails sent to the list. Why the continuous pouring of emails? Maybe another technique has to be developed for people to research problems. I'm open to suggestion, but I can tell you from experience that splitting the list is not the right answer -- for people *asking* the questions or for the questions *answering* them. I've seen this tried several times in various high volume scenarios, and it always tends to degenerate to some combination of: * Newbie questions still get asked on the non-newbie list (nobody really wants to consider themselves a newbie). * About 10% of the questions get cross-posted to both lists, no matter how many time you yell at people. * A question gets asked and answered on one of the lists, but the user searches the other one, doesn't see the answer, and asks the same question again. Personally, I'm unwilling to add to my own time commitment by scanning yet another list every morning. By the way - the separate folder technique works until you take a trip for week and things get back logged. Sounds like poorly designed or configured mail reader software to me. I mark the STRUTS-USER folder not to be downloaded when I'm accessing via modem, so that Netscape won't bother trying to sync my local copy, and then turn download back on again when I'm back to high speed connections. - Malcolm Craig -Original Message- From: Assenza, Chris [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 8:43 AM To: 'Struts Users Mailing List' Subject: RE: all this traffic Setting up your mail reader to automatically forward STRUTS-USER messages to a separate folder, and then sorting by thread, is a trivially easy approach to dealing with volume issues. Your inbox is no longer clogged, you can go read Struts mail when you have time, and can ignore entire irrelevant threads with a single command to advance to the next thread. Indeed, that is in fact my method of choice for using this list. All one has to do is look at subject headers to asses interest and move on. I usually read everything I want to read and then delete the contents of the folder. There are some drawbacks to this approach [or any client-based solution] though, most notably if you have low size limits on your mail account or if you access your mail remotely on a regular basis (ie. a traveller). Sitting in a hotel room waiting to communicate with Exchange (or worse POP3) becomes rather burdensome when there are 1k+ unread messages in the Struts folder. Overall, still the best approach, but I can definitely see why some people might want to reduce volume. However, I'm not big on the struts-newbie list idea myself. -Chris -- 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]
RE: SURVEY: Proper Way To Pre-populate ActionForms
My problem with doing database lookups in ActionForm.reset() is that an exception may occur and it's not as easy to handle as it when doing things within the Action class (where you can just forward things to an error.jsp). I find that if I trap the exception, the populate method may have problems because reset() didn't complete and the controller will throw an exception to the container's handler, and if I don't trap it, the controller again handles the exception. Is this the reason you recommend not doing DB lookups in ActionForm.reset(), or are there other considerations that make it undesirable? -JT -Original Message- From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 8:43 AM To: Struts Users Mailing List Cc: '[EMAIL PROTECTED]' Subject: Re: SURVEY: Proper Way To Pre-populate ActionForms The struts-example app (which uses a separate action for the setup) is the method that I recommend for manually setting up an ActionForm instance, plus any other beans that need to be looked up and placed in request scope. To remind you of the relationships, the actions and the JSP page are named similarly: * editRegistration.do -- Set up the registration.jsp form bean * registration.do -- The input page for registration information * saveRegistration.do -- Save the new or updated registration information to the database It's fine to rely on the auto-creation of the form bean if you don't need to look up any database information (i.e. you're going to be doing a create type transaction), where you just make your reset() method set up all the defaults. However, if you're going to do an edit transaction against existing data from the database, I prefer to look that up in a setup action rather than make the reset() method have to go to the database itself. Craig McClanahan On Mon, 30 Sep 2002, Hohlen, John wrote: Date: Mon, 30 Sep 2002 08:22:29 -0500 From: Hohlen, John [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: Struts-Help (E-mail) [EMAIL PROTECTED] Cc: '[EMAIL PROTECTED]' [EMAIL PROTECTED] Subject: SURVEY: Proper Way To Pre-populate ActionForms I was wondering what the overall philosophy is in the Struts Users community in regards to pre-populating action forms? I sent a message out late last week asking for help on how to manually instantiate and pre-populate an action form (prior to forwarding to a JS) in Struts 1.1. That's when I realized this may be considered bad practice. Here are some comments I received: Eddie Bush: No, no. Actions/Forms have a contract -- the form 'will' be created. You should not take this upon yourself. What you need to do is pre-face the page with a 'populate' action. Expect it to be there James Turner: I can still point to cases where you need to manually pre-populate. For example, if you have multiple forms on a single JSP page, you either need to pre-populate the forms manually, or you'd have to daisy-chain a bunch of actions together, each one of which was responsible for pre-populating a single form. This seems clumsy to me. Maybe what we need is an authoritative way (i.e., an API) to instantiate DynaForms. What are others doing here? BTW, if manually pre-populating an action form is acceptable, does it make sense to create a method in the RequestUtils package making this easy to do for a DynaForm (Struts 1.1). For example (code provided by James Turner): ApplicationConfig appConfig = (ApplicationConfig)request.getAttribute(Action.APPLICATION_KEY); FormBeanConfig formBeanConfig = appConfig.findFormBeanConfig(myDynaActionForm); String beanType = formBeanConfig.getType(); DynaActionForm bean; DynaActionFormClass formClass = DynaActionFormClass.createDynaActionFormClass(formBeanConfig); return (DynaActionForm) formClass.newInstance(); Thanks! JOHN -- 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]
How do I forward/redirect to a dynamic url with parameters
How do I redirect to a dynamic url with parameters? I need to forward to some url with a query string that is dynamically created. The url I forward to can change and I also need to create that dynamically. Also, the url I need to forward to is external to our system. I have tried dynamically creating an ActionForward and setting its parameters, but it just blows up with an exception. I have also tried forwarding to a redirector servlet on our system, but have had no success with that either. Is there a proper struts way to do this. Thanks, Doug -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: SURVEY: Proper Way To Pre-populate ActionForms
The struts-example app (which uses a separate action for the setup) is the method that I recommend for manually setting up an ActionForm instance, plus any other beans that need to be looked up and placed in request scope. To remind you of the relationships, the actions and the JSP page are named similarly: * editRegistration.do -- Set up the registration.jsp form bean * registration.do -- The input page for registration information * saveRegistration.do -- Save the new or updated registration information to the database It's fine to rely on the auto-creation of the form bean if you don't need to look up any database information (i.e. you're going to be doing a create type transaction), where you just make your reset() method set up all the defaults. However, if you're going to do an edit transaction against existing data from the database, I prefer to look that up in a setup action rather than make the reset() method have to go to the database itself. Craig McClanahan On Mon, 30 Sep 2002, Hohlen, John wrote: Date: Mon, 30 Sep 2002 08:22:29 -0500 From: Hohlen, John [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: Struts-Help (E-mail) [EMAIL PROTECTED] Cc: '[EMAIL PROTECTED]' [EMAIL PROTECTED] Subject: SURVEY: Proper Way To Pre-populate ActionForms I was wondering what the overall philosophy is in the Struts Users community in regards to pre-populating action forms? I sent a message out late last week asking for help on how to manually instantiate and pre-populate an action form (prior to forwarding to a JS) in Struts 1.1. That's when I realized this may be considered bad practice. Here are some comments I received: Eddie Bush: No, no. Actions/Forms have a contract -- the form 'will' be created. You should not take this upon yourself. What you need to do is pre-face the page with a 'populate' action. Expect it to be there James Turner: I can still point to cases where you need to manually pre-populate. For example, if you have multiple forms on a single JSP page, you either need to pre-populate the forms manually, or you'd have to daisy-chain a bunch of actions together, each one of which was responsible for pre-populating a single form. This seems clumsy to me. Maybe what we need is an authoritative way (i.e., an API) to instantiate DynaForms. What are others doing here? BTW, if manually pre-populating an action form is acceptable, does it make sense to create a method in the RequestUtils package making this easy to do for a DynaForm (Struts 1.1). For example (code provided by James Turner): ApplicationConfig appConfig = (ApplicationConfig)request.getAttribute(Action.APPLICATION_KEY); FormBeanConfig formBeanConfig = appConfig.findFormBeanConfig(myDynaActionForm); String beanType = formBeanConfig.getType(); DynaActionForm bean; DynaActionFormClass formClass = DynaActionFormClass.createDynaActionFormClass(formBeanConfig); return (DynaActionForm) formClass.newInstance(); Thanks! JOHN -- 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: Access JSP in the WEB-INF
I was told I could do this; action name=aPage .. [put the jsp file here] /action action forward name=aPage path=aPage.do / /action Billy Ng From: Andrew Hill [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED] To: Struts [EMAIL PROTECTED] Subject: RE: Access JSP in the WEB-INF Date: Mon, 30 Sep 2002 23:43:12 +0800 Im in a bit of a rush right now to try and get a taxi home before the midnight charge kicks in, but Im sure there are many others out there who can give you a good example (right guys???) -Original Message- From: Smith, Johnathan M. [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 23:34 To: '[EMAIL PROTECTED]' Subject: RE: Access JSP in the WEB-INF Can you send me a sample on how to do this in my action -Original Message- From: Andrew Hill [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 11:14 AM To: Struts Users Mailing List Subject: RE: Access JSP in the WEB-INF Once they are under web-inf a direct access from the client will not be allowed by the container, however forwards on the server side are allowed, thus to get to the JSP you can forward to it from an Action. The benefit of this is that users will not be able to hit your JSP without first going through an Action, and thus through the struts front-controller thinghy. You can thus ensure that everything is set up that that JSP needs (ie: beans in the request etc...) or could redirect them to another jsp or action if business logic demanded it... -Original Message- From: Smith, Johnathan M. [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 23:08 To: '[EMAIL PROTECTED]' Subject: Access JSP in the WEB-INF I was reading that I should put all my JSP inside the WEB-INF dir so clients cant access them without going to the controller. My issues is that How do I access them?? can someone please tell me how to setup my Action so I can display the JSP files?? -- 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] _ MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Access JSP in the WEB-INF
I have a modified version of the struts-example that demostrates how to do this. Would you care for a copy? James Mitchell Software Engineer\Struts Evangelist Struts-Atlanta, the Open Minded Developer Network http://www.open-tools.org/struts-atlanta -Original Message- From: Andrew Hill [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 11:43 AM To: Struts Subject: RE: Access JSP in the WEB-INF Im in a bit of a rush right now to try and get a taxi home before the midnight charge kicks in, but Im sure there are many others out there who can give you a good example (right guys???) -Original Message- From: Smith, Johnathan M. [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 23:34 To: '[EMAIL PROTECTED]' Subject: RE: Access JSP in the WEB-INF Can you send me a sample on how to do this in my action -Original Message- From: Andrew Hill [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 11:14 AM To: Struts Users Mailing List Subject: RE: Access JSP in the WEB-INF Once they are under web-inf a direct access from the client will not be allowed by the container, however forwards on the server side are allowed, thus to get to the JSP you can forward to it from an Action. The benefit of this is that users will not be able to hit your JSP without first going through an Action, and thus through the struts front-controller thinghy. You can thus ensure that everything is set up that that JSP needs (ie: beans in the request etc...) or could redirect them to another jsp or action if business logic demanded it... -Original Message- From: Smith, Johnathan M. [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 23:08 To: '[EMAIL PROTECTED]' Subject: Access JSP in the WEB-INF I was reading that I should put all my JSP inside the WEB-INF dir so clients cant access them without going to the controller. My issues is that How do I access them?? can someone please tell me how to setup my Action so I can display the JSP files?? -- 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]
reset-method with multipage DynaValidatorForm
Hello, first of all, I did search the user-archive and I had a look at the struts-simple workflow example by Ted Husted. Nevertheless I wasn't able to solve this problem o my own. I have one action class (InsertPersonAction) and one DynaValidatorForm class (InsertPersonBean) that should do the work of build up the form, that is, add three collections to it, validate the input of the 2 input pages and then make the insert to the db. For the input to the form I use the following configuration : action path=/secureZone/insertPerson/Input type=de.subsist.zeiterfassung.controller.actions.InsertPersonAction name=insertPersonForm scope=session parameter=input validate=false forward name=Success path=ZuKS.insertPerson1Definition redirect=true/ /action In the action class I check for the parameter and then add the collections to the form. fine For the actual insert of the data I configured this : action path=/secureZone/insertPerson/Insert type=de.subsist.zeiterfassung.controller.actions.InsertPersonAction name=insertPersonForm scope=session parameter=insert validate=true input=/secureZone/insertPerson/Insert.do forward name=Page1 path=ZuKS.insertPerson1Definition redirect=false/ forward name=Page2 path=ZuKS.insertPerson2Definition redirect=false/ forward name=Success path=ZuKS.mainLayoutDefinition redirect=true/ /action The reset-method of the Form is changed so that only the collections are not reseted. Anything else gets set to the initial value as in the source code of the DynaValidatorForm class. The navigation (next, previous, insert) are done with several submit buttons as explained somewhere in this archive, e.g. html:reset bean:message key=button.reset/ /html:reset nbsp; html:cancel onclick=bCancel=true; bean:message key=button.cancel/ /html:cancel nbsp; html:submit property=next onclick=bCancel=false; bean:message key=button.next/ /html:submit The problem now is that all the time I want to go back with the 'previous' button I get into a loop because the values from the form get reset, the validation therefore fails and the validator sends me back to the same action it came from and so on. When I read Ted's example I turned off client-side validation without any effect. One solution could be to just do nothing in the reset method and implement some reset methods for every page displayed but in the form class in struts-simple (DemoBean) the reset method sets every member variable to and it's working so I don't know why it's not in my case. Can somebody advice me on this issue. Any help is appreciated. Ralf -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: SURVEY: Proper Way To Pre-populate ActionForms
On Mon, 30 Sep 2002, Taylor, Jason wrote: Date: Mon, 30 Sep 2002 08:54:46 -0700 From: Taylor, Jason [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: 'Struts Users Mailing List' [EMAIL PROTECTED] Subject: RE: SURVEY: Proper Way To Pre-populate ActionForms My problem with doing database lookups in ActionForm.reset() is that an exception may occur and it's not as easy to handle as it when doing things within the Action class (where you can just forward things to an error.jsp). I find that if I trap the exception, the populate method may have problems because reset() didn't complete and the controller will throw an exception to the container's handler, and if I don't trap it, the controller again handles the exception. Is this the reason you recommend not doing DB lookups in ActionForm.reset(), or are there other considerations that make it undesirable? That's a valid reason to be concerned (although the method signature of reset() isn't going to let you throw a SQLException anyway). My primary concern, however, is a more fundamental architectural principle. An ActionForm class is part of the view tier in the MVC architecture that Struts supports. As such, it should have no knowledge of where the data for the fields came from (for a pre-populate), or where it goes to (for the usual form processing after a submit). Putting any SQL logic into a form bean violates the layer separation, as well as increasing your maintenance burden when your DBMS table structure changs. -JT Craig McClanahan -Original Message- From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 8:43 AM To: Struts Users Mailing List Cc: '[EMAIL PROTECTED]' Subject: Re: SURVEY: Proper Way To Pre-populate ActionForms The struts-example app (which uses a separate action for the setup) is the method that I recommend for manually setting up an ActionForm instance, plus any other beans that need to be looked up and placed in request scope. To remind you of the relationships, the actions and the JSP page are named similarly: * editRegistration.do -- Set up the registration.jsp form bean * registration.do -- The input page for registration information * saveRegistration.do -- Save the new or updated registration information to the database It's fine to rely on the auto-creation of the form bean if you don't need to look up any database information (i.e. you're going to be doing a create type transaction), where you just make your reset() method set up all the defaults. However, if you're going to do an edit transaction against existing data from the database, I prefer to look that up in a setup action rather than make the reset() method have to go to the database itself. Craig McClanahan On Mon, 30 Sep 2002, Hohlen, John wrote: Date: Mon, 30 Sep 2002 08:22:29 -0500 From: Hohlen, John [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: Struts-Help (E-mail) [EMAIL PROTECTED] Cc: '[EMAIL PROTECTED]' [EMAIL PROTECTED] Subject: SURVEY: Proper Way To Pre-populate ActionForms I was wondering what the overall philosophy is in the Struts Users community in regards to pre-populating action forms? I sent a message out late last week asking for help on how to manually instantiate and pre-populate an action form (prior to forwarding to a JS) in Struts 1.1. That's when I realized this may be considered bad practice. Here are some comments I received: Eddie Bush: No, no. Actions/Forms have a contract -- the form 'will' be created. You should not take this upon yourself. What you need to do is pre-face the page with a 'populate' action. Expect it to be there James Turner: I can still point to cases where you need to manually pre-populate. For example, if you have multiple forms on a single JSP page, you either need to pre-populate the forms manually, or you'd have to daisy-chain a bunch of actions together, each one of which was responsible for pre-populating a single form. This seems clumsy to me. Maybe what we need is an authoritative way (i.e., an API) to instantiate DynaForms. What are others doing here? BTW, if manually pre-populating an action form is acceptable, does it make sense to create a method in the RequestUtils package making this easy to do for a DynaForm (Struts 1.1). For example (code provided by James Turner): ApplicationConfig appConfig = (ApplicationConfig)request.getAttribute(Action.APPLICATION_KEY); FormBeanConfig formBeanConfig = appConfig.findFormBeanConfig(myDynaActionForm); String beanType = formBeanConfig.getType(); DynaActionForm bean; DynaActionFormClass formClass = DynaActionFormClass.createDynaActionFormClass(formBeanConfig); return (DynaActionForm) formClass.newInstance(); Thanks! JOHN -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional
Re: [OT - Java] How can I do this in Java?
Make sure your code in a proper try and catch. Using reflection spits out nasty errors if anything is not right.:( ClassCastException IllegalAccessException NoSuchMethodException InvocationTargetException Daniel jaffa - Original Message - From: Jerry Jalenak [EMAIL PROTECTED] To: 'Struts Users Mailing List' [EMAIL PROTECTED] Sent: Monday, September 30, 2002 11:46 AM Subject: RE: [OT - Java] How can I do this in Java? Jason - Thanks for the code snippet - worked like a charm first time! I tend to get lost in JavaDoc sometimes, so this was a nice example to have on how to wind my way through to the answer! Thanks again! John - Thanks for the suggestion on using the HashMap. I'm going to file it away for now and use Jason's reflection method - but it never hurts to have a couple of different methods to use on something like this! Thanks guys! Jerry -Original Message- From: Taylor, Jason [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 10:28 AM To: 'Struts Users Mailing List' Subject: RE: [OT - Java] How can I do this in Java? I don't happen to have any sample code that does exactly what you're doing, but off the top of my head (with a little help from sun's javadoc) I'd say it's something like: import java.lang.reflect.Field; String stateCode = AK; Class constantClass = Class.forName(com.yourdomain.yourapp.Constants); Field stateField = constantClass.getDeclaredField(stateCode); String stateRegExp = (String) stateField.get(constantClass); System.err.println(regexp for +stateCode+: +stateRegExp); I don't really know any more about reflection than you, I just followed the trail from java.lang.Class to java.lang.reflect.Field. Once you've done it once, you see it's no mystery-- you're just doing runtime compiling. HTH-- This is just how I'd start, as I haven't tested or used this code. If I'm wrong, I'm sure you can figure out what I missed by studying the API docs. If, on the other hand, you don't like reading javadocs and generating your own test cases, LOL! -JT -Original Message- From: Jerry Jalenak [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 8:05 AM To: 'Struts Users Mailing List' Subject: RE: [OT - Java] How can I do this in Java? Jason, Thanks for the quick reply. I just took at look at the API's, but don't yet understand enough about reflection to know how to implement it. Just looking at the methods I don't see a way to do what I want - any chance that you'd have some sample code laying about? Jerry -Original Message- From: Taylor, Jason [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 9:59 AM To: 'Struts Users Mailing List' Subject: RE: [OT - Java] How can I do this in Java? sounds like a job for reflection (java.lang.reflect.*;) Have you looked at java.lang.Class and java.lang.reflect.Field? -Original Message- From: Jerry Jalenak [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 7:50 AM To: '[EMAIL PROTECTED]' Subject: [OT - Java] How can I do this in Java? OK - off topic, but Sun's java forum sucks, and there are an incredible number of Java guru's on this list, so I thought I'd throw this out here. (That and I am using this in a custom validation routine :-))Any help would be GREATLY appreciated! Here's the scenario - I've got a series of static constants that represent Java regular expressions. These RE's are used to validate driver license formats for the 50 states + DC. The strings look like this: public static final String AK = ^[0-9]{1,7}$; public static final String AL = ^[0-9]{7}$; public static final String AR = ^[0-9]{8,9}$; public static final String AZ = ^[0-9ABDY][0-9]{8}$|^[A-Z][0-9]{3,6}$|^[A-Z]{2}[0-9]{3,5}$; public static final String CA = ^[A-Z][0-9]{4,7}$; public static final String CO = ^[A-Z][0-9]{1,6}$|^[A-Z]{2}[0-9]{1,6}$|^[0-9]{9}$; etc. etc. etc. On my form I have a drop-down box of states, and a field for the license number. In my custom validator routine, I pick up the value of the state, and build a string to represent the constant - i.e. private static boolean validateDriversLicenseNumber(String licenseState, String licenseNumber) { String licenseConstant = Constants. + licenseState; I then want to use licenseConstant in a Pattern / Match: Pattern p = Pattern.compile(licenseConstant, Pattern.CASE_INSENSITIVE); Match m = p.matcher(licenseNumber); return (m.find()); } Obviously the line String licenseConstant = Constants. + licenseState; does not give me the value of Constant.state name; the question I have is, is there a method (or something) that will allow me to build such a string, and return the value (i.e. the regular expression)? Or is
RE: [OT - Java] How can I do this in Java?
good point-- you'd also want to printStackTrace() (if possible) before rethrowing InvocationTargetException, since it can be difficult to debug an ITE otherwise... -Original Message- From: Daniel Jaffa [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 9:49 AM To: Struts Users Mailing List Subject: Re: [OT - Java] How can I do this in Java? Make sure your code in a proper try and catch. Using reflection spits out nasty errors if anything is not right.:( ClassCastException IllegalAccessException NoSuchMethodException InvocationTargetException Daniel jaffa - Original Message - From: Jerry Jalenak [EMAIL PROTECTED] To: 'Struts Users Mailing List' [EMAIL PROTECTED] Sent: Monday, September 30, 2002 11:46 AM Subject: RE: [OT - Java] How can I do this in Java? Jason - Thanks for the code snippet - worked like a charm first time! I tend to get lost in JavaDoc sometimes, so this was a nice example to have on how to wind my way through to the answer! Thanks again! John - Thanks for the suggestion on using the HashMap. I'm going to file it away for now and use Jason's reflection method - but it never hurts to have a couple of different methods to use on something like this! Thanks guys! Jerry -Original Message- From: Taylor, Jason [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 10:28 AM To: 'Struts Users Mailing List' Subject: RE: [OT - Java] How can I do this in Java? I don't happen to have any sample code that does exactly what you're doing, but off the top of my head (with a little help from sun's javadoc) I'd say it's something like: import java.lang.reflect.Field; String stateCode = AK; Class constantClass = Class.forName(com.yourdomain.yourapp.Constants); Field stateField = constantClass.getDeclaredField(stateCode); String stateRegExp = (String) stateField.get(constantClass); System.err.println(regexp for +stateCode+: +stateRegExp); I don't really know any more about reflection than you, I just followed the trail from java.lang.Class to java.lang.reflect.Field. Once you've done it once, you see it's no mystery-- you're just doing runtime compiling. HTH-- This is just how I'd start, as I haven't tested or used this code. If I'm wrong, I'm sure you can figure out what I missed by studying the API docs. If, on the other hand, you don't like reading javadocs and generating your own test cases, LOL! -JT -Original Message- From: Jerry Jalenak [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 8:05 AM To: 'Struts Users Mailing List' Subject: RE: [OT - Java] How can I do this in Java? Jason, Thanks for the quick reply. I just took at look at the API's, but don't yet understand enough about reflection to know how to implement it. Just looking at the methods I don't see a way to do what I want - any chance that you'd have some sample code laying about? Jerry -Original Message- From: Taylor, Jason [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 9:59 AM To: 'Struts Users Mailing List' Subject: RE: [OT - Java] How can I do this in Java? sounds like a job for reflection (java.lang.reflect.*;) Have you looked at java.lang.Class and java.lang.reflect.Field? -Original Message- From: Jerry Jalenak [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 7:50 AM To: '[EMAIL PROTECTED]' Subject: [OT - Java] How can I do this in Java? OK - off topic, but Sun's java forum sucks, and there are an incredible number of Java guru's on this list, so I thought I'd throw this out here. (That and I am using this in a custom validation routine :-))Any help would be GREATLY appreciated! Here's the scenario - I've got a series of static constants that represent Java regular expressions. These RE's are used to validate driver license formats for the 50 states + DC. The strings look like this: public static final String AK = ^[0-9]{1,7}$; public static final String AL = ^[0-9]{7}$; public static final String AR = ^[0-9]{8,9}$; public static final String AZ = ^[0-9ABDY][0-9]{8}$|^[A-Z][0-9]{3,6}$|^[A-Z]{2}[0-9]{3,5}$; public static final String CA = ^[A-Z][0-9]{4,7}$; public static final String CO = ^[A-Z][0-9]{1,6}$|^[A-Z]{2}[0-9]{1,6}$|^[0-9]{9}$; etc. etc. etc. On my form I have a drop-down box of states, and a field for the license number. In my custom validator routine, I pick up the value of the state, and build a string to represent the constant - i.e. private static boolean validateDriversLicenseNumber(String licenseState, String licenseNumber) { String licenseConstant = Constants. + licenseState; I then want to use licenseConstant in a Pattern / Match: Pattern p = Pattern.compile(licenseConstant, Pattern.CASE_INSENSITIVE);
RE: [OT - Java] How can I do this in Java?
Yeah, already ran across the exceptions. Right now I'm trying to decide how to handle them since all of this code is actually in a custom Validator routine. Jerry -Original Message- From: Taylor, Jason [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 11:57 AM To: 'Struts Users Mailing List' Subject: RE: [OT - Java] How can I do this in Java? good point-- you'd also want to printStackTrace() (if possible) before rethrowing InvocationTargetException, since it can be difficult to debug an ITE otherwise... -Original Message- From: Daniel Jaffa [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 9:49 AM To: Struts Users Mailing List Subject: Re: [OT - Java] How can I do this in Java? Make sure your code in a proper try and catch. Using reflection spits out nasty errors if anything is not right.:( ClassCastException IllegalAccessException NoSuchMethodException InvocationTargetException Daniel jaffa - Original Message - From: Jerry Jalenak [EMAIL PROTECTED] To: 'Struts Users Mailing List' [EMAIL PROTECTED] Sent: Monday, September 30, 2002 11:46 AM Subject: RE: [OT - Java] How can I do this in Java? Jason - Thanks for the code snippet - worked like a charm first time! I tend to get lost in JavaDoc sometimes, so this was a nice example to have on how to wind my way through to the answer! Thanks again! John - Thanks for the suggestion on using the HashMap. I'm going to file it away for now and use Jason's reflection method - but it never hurts to have a couple of different methods to use on something like this! Thanks guys! Jerry -Original Message- From: Taylor, Jason [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 10:28 AM To: 'Struts Users Mailing List' Subject: RE: [OT - Java] How can I do this in Java? I don't happen to have any sample code that does exactly what you're doing, but off the top of my head (with a little help from sun's javadoc) I'd say it's something like: import java.lang.reflect.Field; String stateCode = AK; Class constantClass = Class.forName(com.yourdomain.yourapp.Constants); Field stateField = constantClass.getDeclaredField(stateCode); String stateRegExp = (String) stateField.get(constantClass); System.err.println(regexp for +stateCode+: +stateRegExp); I don't really know any more about reflection than you, I just followed the trail from java.lang.Class to java.lang.reflect.Field. Once you've done it once, you see it's no mystery-- you're just doing runtime compiling. HTH-- This is just how I'd start, as I haven't tested or used this code. If I'm wrong, I'm sure you can figure out what I missed by studying the API docs. If, on the other hand, you don't like reading javadocs and generating your own test cases, LOL! -JT -Original Message- From: Jerry Jalenak [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 8:05 AM To: 'Struts Users Mailing List' Subject: RE: [OT - Java] How can I do this in Java? Jason, Thanks for the quick reply. I just took at look at the API's, but don't yet understand enough about reflection to know how to implement it. Just looking at the methods I don't see a way to do what I want - any chance that you'd have some sample code laying about? Jerry -Original Message- From: Taylor, Jason [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 9:59 AM To: 'Struts Users Mailing List' Subject: RE: [OT - Java] How can I do this in Java? sounds like a job for reflection (java.lang.reflect.*;) Have you looked at java.lang.Class and java.lang.reflect.Field? -Original Message- From: Jerry Jalenak [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 7:50 AM To: '[EMAIL PROTECTED]' Subject: [OT - Java] How can I do this in Java? OK - off topic, but Sun's java forum sucks, and there are an incredible number of Java guru's on this list, so I thought I'd throw this out here. (That and I am using this in a custom validation routine :-))Any help would be GREATLY appreciated! Here's the scenario - I've got a series of static constants that represent Java regular expressions. These RE's are used to validate driver license formats for the 50 states + DC. The strings look like this: public static final String AK = ^[0-9]{1,7}$; public static final String AL = ^[0-9]{7}$; public static final String AR = ^[0-9]{8,9}$; public static final String AZ = ^[0-9ABDY][0-9]{8}$|^[A-Z][0-9]{3,6}$|^[A-Z]{2}[0-9]{3,5}$; public static final String CA = ^[A-Z][0-9]{4,7}$; public static final String CO = ^[A-Z][0-9]{1,6}$|^[A-Z]{2}[0-9]{1,6}$|^[0-9]{9}$; etc. etc. etc.
[SELL STRUTS] How do you sell the ActionForm idea?
I'm trying to sell a colleague on using Struts, and I'm pretty close, but he can't understand the value of using ActionForm classes instead of just HashMaps. Has anyone else had to make this case? The validate() method is one advantage, but it seems obsolete now that we have the validator framework (correct me if I'm wrong). Maybe it's the reset() method. Would it be possible to achieve the reset() functionality (maybe by adding something to the config file) if Struts used HashMaps instead of ActionForms? Thanks, Dan -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
TilesRequestProcessor and I18n!!!!
Hi all, I'm having a problem with the Tiles request processor and I18n. The problem is that the request processor doesn't load the Locale of the client in the session. What could be the solution, to implement a request processor class extending TilesRequestProcessor? Which methods of that class should be overriden? Another issue is that the request processor is not Serializable, and sometimes, when the machine has low memory appear an error java.io.NotSerializableException: org.apache.struts.tiles.TilesRequestProcessor. Can be this solved making the extending class implements Serializable? Thanks a lot. Cristian.
RE: SURVEY: Proper Way To Pre-populate ActionForms
I'm actually not throwing SQLExceptions-- instead a generic application exception bubbles up from the DB interaction within an object repository that populates the form. The problem for me is that if I have an array of items within the form, I may not need to know the state of the individual items in the reset() method, but I at least need to know how many there are and how to identify them, so that I can match up the user's entries with those in the model to validate and determine what if any model objects need to be updated. I'm not sure this violates Model2 principles or not: it seems to me in order to edit the model, you need to render it first in some form, and that form could have dynamic *structure*. For example, if you have an arbitrary number of checkboxes to reset that correspond states of objects in your model, you may need to consult the model to determine how many to put out there. Any thoughts anyone? BTW, thanks for input, Craig-- I think the fact that you are active on your user lists is a big reason your software is so successful. -JT -Original Message- From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 9:38 AM To: Struts Users Mailing List Subject: RE: SURVEY: Proper Way To Pre-populate ActionForms On Mon, 30 Sep 2002, Taylor, Jason wrote: Date: Mon, 30 Sep 2002 08:54:46 -0700 From: Taylor, Jason [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: 'Struts Users Mailing List' [EMAIL PROTECTED] Subject: RE: SURVEY: Proper Way To Pre-populate ActionForms My problem with doing database lookups in ActionForm.reset() is that an exception may occur and it's not as easy to handle as it when doing things within the Action class (where you can just forward things to an error.jsp). I find that if I trap the exception, the populate method may have problems because reset() didn't complete and the controller will throw an exception to the container's handler, and if I don't trap it, the controller again handles the exception. Is this the reason you recommend not doing DB lookups in ActionForm.reset(), or are there other considerations that make it undesirable? That's a valid reason to be concerned (although the method signature of reset() isn't going to let you throw a SQLException anyway). My primary concern, however, is a more fundamental architectural principle. An ActionForm class is part of the view tier in the MVC architecture that Struts supports. As such, it should have no knowledge of where the data for the fields came from (for a pre-populate), or where it goes to (for the usual form processing after a submit). Putting any SQL logic into a form bean violates the layer separation, as well as increasing your maintenance burden when your DBMS table structure changs. -JT Craig McClanahan -Original Message- From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 8:43 AM To: Struts Users Mailing List Cc: '[EMAIL PROTECTED]' Subject: Re: SURVEY: Proper Way To Pre-populate ActionForms The struts-example app (which uses a separate action for the setup) is the method that I recommend for manually setting up an ActionForm instance, plus any other beans that need to be looked up and placed in request scope. To remind you of the relationships, the actions and the JSP page are named similarly: * editRegistration.do -- Set up the registration.jsp form bean * registration.do -- The input page for registration information * saveRegistration.do -- Save the new or updated registration information to the database It's fine to rely on the auto-creation of the form bean if you don't need to look up any database information (i.e. you're going to be doing a create type transaction), where you just make your reset() method set up all the defaults. However, if you're going to do an edit transaction against existing data from the database, I prefer to look that up in a setup action rather than make the reset() method have to go to the database itself. Craig McClanahan On Mon, 30 Sep 2002, Hohlen, John wrote: Date: Mon, 30 Sep 2002 08:22:29 -0500 From: Hohlen, John [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: Struts-Help (E-mail) [EMAIL PROTECTED] Cc: '[EMAIL PROTECTED]' [EMAIL PROTECTED] Subject: SURVEY: Proper Way To Pre-populate ActionForms I was wondering what the overall philosophy is in the Struts Users community in regards to pre-populating action forms? I sent a message out late last week asking for help on how to manually instantiate and pre-populate an action form (prior to forwarding to a JS) in Struts 1.1. That's when I realized this may be considered bad practice. Here are some comments I received: Eddie Bush: No, no. Actions/Forms have a contract -- the form 'will' be created. You should not take this upon yourself. What you need to do is pre-face
RE: [SELL STRUTS] How do you sell the ActionForm idea?
Have you used DynaActionForm? They're like little gold nuggets of magic ;) James Mitchell Software Engineer\Struts Evangelist Struts-Atlanta, the Open Minded Developer Network http://www.open-tools.org/struts-atlanta -Original Message- From: Dan Cancro [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 1:12 PM To: '[EMAIL PROTECTED]' Subject: [SELL STRUTS] How do you sell the ActionForm idea? I'm trying to sell a colleague on using Struts, and I'm pretty close, but he can't understand the value of using ActionForm classes instead of just HashMaps. Has anyone else had to make this case? The validate() method is one advantage, but it seems obsolete now that we have the validator framework (correct me if I'm wrong). Maybe it's the reset() method. Would it be possible to achieve the reset() functionality (maybe by adding something to the config file) if Struts used HashMaps instead of ActionForms? Thanks, Dan -- 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: Access JSP in the WEB-INF
Yes. please send it to me -Original Message- From: James Mitchell [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 12:25 PM To: Struts Users Mailing List Subject: RE: Access JSP in the WEB-INF I have a modified version of the struts-example that demostrates how to do this. Would you care for a copy? James Mitchell Software Engineer\Struts Evangelist Struts-Atlanta, the Open Minded Developer Network http://www.open-tools.org/struts-atlanta -Original Message- From: Andrew Hill [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 11:43 AM To: Struts Subject: RE: Access JSP in the WEB-INF Im in a bit of a rush right now to try and get a taxi home before the midnight charge kicks in, but Im sure there are many others out there who can give you a good example (right guys???) -Original Message- From: Smith, Johnathan M. [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 23:34 To: '[EMAIL PROTECTED]' Subject: RE: Access JSP in the WEB-INF Can you send me a sample on how to do this in my action -Original Message- From: Andrew Hill [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 11:14 AM To: Struts Users Mailing List Subject: RE: Access JSP in the WEB-INF Once they are under web-inf a direct access from the client will not be allowed by the container, however forwards on the server side are allowed, thus to get to the JSP you can forward to it from an Action. The benefit of this is that users will not be able to hit your JSP without first going through an Action, and thus through the struts front-controller thinghy. You can thus ensure that everything is set up that that JSP needs (ie: beans in the request etc...) or could redirect them to another jsp or action if business logic demanded it... -Original Message- From: Smith, Johnathan M. [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 23:08 To: '[EMAIL PROTECTED]' Subject: Access JSP in the WEB-INF I was reading that I should put all my JSP inside the WEB-INF dir so clients cant access them without going to the controller. My issues is that How do I access them?? can someone please tell me how to setup my Action so I can display the JSP files?? -- 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]
RE: [SELL STRUTS] How do you sell the ActionForm idea?
+1 and DynaValidatorActionForms have frosting :) robert -Original Message- From: James Mitchell [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 2:03 PM To: Struts Users Mailing List Subject: RE: [SELL STRUTS] How do you sell the ActionForm idea? Have you used DynaActionForm? They're like little gold nuggets of magic ;) James Mitchell Software Engineer\Struts Evangelist Struts-Atlanta, the Open Minded Developer Network http://www.open-tools.org/struts-atlanta -Original Message- From: Dan Cancro [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 1:12 PM To: '[EMAIL PROTECTED]' Subject: [SELL STRUTS] How do you sell the ActionForm idea? I'm trying to sell a colleague on using Struts, and I'm pretty close, but he can't understand the value of using ActionForm classes instead of just HashMaps. Has anyone else had to make this case? The validate() method is one advantage, but it seems obsolete now that we have the validator framework (correct me if I'm wrong). Maybe it's the reset() method. Would it be possible to achieve the reset() functionality (maybe by adding something to the config file) if Struts used HashMaps instead of ActionForms? Thanks, Dan -- 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]
Tiles and tabbed display
All: Okay, I successfully integrated Struts Tiles with my app, and it's working very nicely, thank you. Then I got the bright idea that I wanted a tabbed display, and since the Tiles documentation shows a couple of examples of tabbed displays, I thought, Why not?. Now that it's brought me to my knees, I know why not. I got a play tabbed display working -- basically copying and editing the tiles-def.xml files from the tiles-documentation example -- fairly easily, and I can throw up all of the simple JSPs I want to in a tabbed display. HOWEVER, in actual practice, of course, my app only has one or two simple JSP pages; most of what I want to display flows through Actions, ActionMappings, etc., and contains some sort of data display. I had no trouble, when I first integrated Tiles, linking the mappings in my struts-config.xml to tiles definitions instead of to the JSPs they originally referenced. Indeed, the tiles-documentation example contained instances of this, which I dutifully cribbed. However, the tabbed-display part of the example contains tiles definitions only directly to JSP pages; for example: item value=Doc Home link=/index.jsp / item value=Quick overview link=/doc/quickOverview.jsp / item value=Tutorial link=/doc/tutorial.jsp / item value=Examples Home link=/examples/index.jsp / Each of these item definitions represents a page I can tab to. However, what if I want to link to the path /payment/edit, find its ActionMapping, invoke its Action, and display a JSP populated by its ActionForm? Can I put a link to an ActionMapping as the link value in this element? I've tried, but keep getting NullPointerExceptions without much else to guide me. And I haven't found anything in the documentation to guide me, either. Sorry if my question isn't very coherent; I'm confused enough that I'm having trouble formulating the question properly. Anyway, any help or guidance will be greatly appreciated. Thanks in advance, Charles McClain Phone: 603.659.2046 email:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
[BUG]Action Servlet not initialized load-on-startup in Resin
Hi All, My application is intermittently being initialized improperly. I am deploying multiple struts based app's into resin and am experiencing errors with several Struts tags being used. The application deploys fine 9/10 times and then blows up. When I inspect the logs I follow the initialization sequence and see the error. Basically resin receives a request for a new deployed web app and begins initializing it after all the load-on-startup servlets have been initialized, then resin initializes a some of its servlets for handling JSP requests and then processes the requested JSP resource. When my bug appears and I follow the initialization sequence I can see the problem. Resin initializes its servlet for handling JSP request and then processes the requested JSP resource, then it initializes my load sequence. So the requested JSP using Struts fails because Struts has not been initialized yet. If I wasn't using struts it would just fail in another class. I am sure this is a problem with resin and have read many! archives in there database regarding initialization issues and some with Struts but no resolution other than using the ServletContextlistener witch will not work form my Struts components. I have not seen any related Struts archives and am wondering if anyone else has had this problem and how it can be rectified? I am running Resin 2.12 and have configured a struts app to be initialized as follows in the web.xml. !-- Database Initialization Servlet Configuration -- servlet servlet-nameinitializer/servlet-name servlet-classcom.wrappedapps.boutique.business.AppInitServlet/servlet-cla ss init-param param-namedebug/param-name param-value1/param-value /init-param load-on-startup1/load-on-startup /servlet !-- Standard Action Servlet Configuration -- servlet servlet-nameaction/servlet-name servlet-classorg.apache.struts.tiles.ActionComponentServlet/servlet-class !-- Tiles definitions -- init-param param-namedefinitions-config/param-name param-value/WEB-INF/tiles/tiles-defs.xml/param-value /init-param !-- Default struts application -- init-param param-nameconfig/param-name param-value/WEB-INF/struts-config.xml/param-value /init-param !-- Struts sub-application -- init-param param-nameconfig/ownersguide/param-name param-value/WEB-INF/struts-config-og.xml/param-value /init-param init-param param-namedebug/param-name param-value0/param-value /init-param init-param param-namedetail/param-name param-value0/param-value /init-param load-on-startup3/load-on-startup /servlet Many thanks, Greg
Re: [SELL STRUTS] How do you sell the ActionForm idea?
I suppose selling him with look, so many other people are being productive with this tool, let's just use it is out? :) From my own experience: 1) Sell him on the fact that you can create (either via DynaForm or through the magic of Mapped Properties) a generic ActionForm that behaves just like a hashmap. 2) Point out that, even though #1 is true, there are occasions when you want more intelligence in your ActionForms. And Struts give you that flexibility. The two most common times that we've used custom ActionForms: 1) Date entry - it's much nicer to have an object that knows how to translate the fields into a single date, rather than putting the date-transformation logic into some other class (usually your action class.) Technically, we created a bean that was stored in the ActionForm, so maybe this doesn't count. 2) Intelligent Search forms - we've extended ActionForm to represent a SearchForm, with tables, search terms, etc. The form knows how to take the data entered and return (essentially) a SQL statement containing that information. We felt it was better than building the same logic into the Action class (particularly because there's no business logic, it's actually just a syntatical exercise.) HTH -Peter On Mon, 2002-09-30 at 13:11, Dan Cancro wrote: I'm trying to sell a colleague on using Struts, and I'm pretty close, but he can't understand the value of using ActionForm classes instead of just HashMaps. Has anyone else had to make this case? The validate() method is one advantage, but it seems obsolete now that we have the validator framework (correct me if I'm wrong). Maybe it's the reset() method. Would it be possible to achieve the reset() functionality (maybe by adding something to the config file) if Struts used HashMaps instead of ActionForms? Thanks, Dan -- 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: [OT - Java] How can I do this in Java?
On Mon, Sep 30, 2002 at 12:02:41PM -0500, Jerry Jalenak wrote: Yeah, already ran across the exceptions. Right now I'm trying to decide how to handle them since all of this code is actually in a custom Validator routine. Good Lord, people, why is reflection anything but the option of last resort here? You really do not want to be calling Class.forname(String) unless there is some class that cannot be loaded by the compiler. First, calling Class.forname is slow, and second, it perversely gets rid of the compile-time type-safety that you would have is you simply used MyClass.class. Reflection is a tool that's useful when you do not know at build time the classes with which you will be dealing. It's useful for discovery of APIs. Using reflection instead of a lookup table is needlessly obtuse and will cause your VM to do all sorts of work on which any programmer should not want to be wasting CPU cycles. 1. Using reflection here is fragile, especially if it's not wrapped within the class that defines your constants. Java is a strongly typed language so letting the compiler help you is encouraged. 2. Using reflection is slow. If you still think it's the way you want to go, I would strongly recommend limiting the times you call Class.forname, etc., such that you do not call it every time you validate the zip code. 3. Using reflection makes you check all sorts of exceptions for things that you as the programmer know should not occur, but only can be you are circumventing the type checking provided by the language. This is a clue that what should be a simple task is being made more complex than it needs to be. 4. I'm not sure what your application is, but using regexp strings to validate ZIP codes per state seems like a bad idea. The US post office makes new ZIP codes all the time, and unless you are getting a list from them every week, the most you may want your application to do is warn the user that the application doesn't recognize the ZIP code. 5. Tell your product managers that validating ZIP codes is not something you can do reliably without an often-updated list of ZIP codes that you would need to download from the Post Office on a regular schedule since your list of regexp string will become outdated. 6. Lookup tables implemented by arrays or HashMaps are orders of magnitude faster than the sequence of function calls and system calls that you have to do with reflection. I'm sorry I had to write this, but I am befuddled by the lack of outcry over using reflection instead of a simple lookup table. Cheers, John -Original Message- From: Taylor, Jason [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 11:57 AM To: 'Struts Users Mailing List' Subject: RE: [OT - Java] How can I do this in Java? good point-- you'd also want to printStackTrace() (if possible) before rethrowing InvocationTargetException, since it can be difficult to debug an ITE otherwise... -Original Message- From: Daniel Jaffa [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 9:49 AM To: Struts Users Mailing List Subject: Re: [OT - Java] How can I do this in Java? Make sure your code in a proper try and catch. Using reflection spits out nasty errors if anything is not right.:( ClassCastException IllegalAccessException NoSuchMethodException InvocationTargetException Daniel jaffa - Original Message - From: Jerry Jalenak [EMAIL PROTECTED] To: 'Struts Users Mailing List' [EMAIL PROTECTED] Sent: Monday, September 30, 2002 11:46 AM Subject: RE: [OT - Java] How can I do this in Java? Jason - Thanks for the code snippet - worked like a charm first time! I tend to get lost in JavaDoc sometimes, so this was a nice example to have on how to wind my way through to the answer! Thanks again! John - Thanks for the suggestion on using the HashMap. I'm going to file it away for now and use Jason's reflection method - but it never hurts to have a couple of different methods to use on something like this! Thanks guys! Jerry -Original Message- From: Taylor, Jason [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 10:28 AM To: 'Struts Users Mailing List' Subject: RE: [OT - Java] How can I do this in Java? I don't happen to have any sample code that does exactly what you're doing, but off the top of my head (with a little help from sun's javadoc) I'd say it's something like: import java.lang.reflect.Field; String stateCode = AK; Class constantClass = Class.forName(com.yourdomain.yourapp.Constants); Field stateField = constantClass.getDeclaredField(stateCode); String stateRegExp = (String) stateField.get(constantClass); System.err.println(regexp for +stateCode+: +stateRegExp); I don't really know any more about reflection than you, I just followed the
RE: [SELL STRUTS] How do you sell the ActionForm idea?
DynaActionForms are more maintainable than HashMaps because their properties are configured in the standard struts config file, rather than in code or some home-grown configurator. If your colleague doesn't like lifting decisions out of code and into configuration files, he probably isn't interest in a general-purpose webapp framework... -Original Message- From: Peter S. Hamlen [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 11:33 AM To: Struts Users Mailing List Subject: Re: [SELL STRUTS] How do you sell the ActionForm idea? I suppose selling him with look, so many other people are being productive with this tool, let's just use it is out? :) From my own experience: 1) Sell him on the fact that you can create (either via DynaForm or through the magic of Mapped Properties) a generic ActionForm that behaves just like a hashmap. 2) Point out that, even though #1 is true, there are occasions when you want more intelligence in your ActionForms. And Struts give you that flexibility. The two most common times that we've used custom ActionForms: 1) Date entry - it's much nicer to have an object that knows how to translate the fields into a single date, rather than putting the date-transformation logic into some other class (usually your action class.) Technically, we created a bean that was stored in the ActionForm, so maybe this doesn't count. 2) Intelligent Search forms - we've extended ActionForm to represent a SearchForm, with tables, search terms, etc. The form knows how to take the data entered and return (essentially) a SQL statement containing that information. We felt it was better than building the same logic into the Action class (particularly because there's no business logic, it's actually just a syntatical exercise.) HTH -Peter On Mon, 2002-09-30 at 13:11, Dan Cancro wrote: I'm trying to sell a colleague on using Struts, and I'm pretty close, but he can't understand the value of using ActionForm classes instead of just HashMaps. Has anyone else had to make this case? The validate() method is one advantage, but it seems obsolete now that we have the validator framework (correct me if I'm wrong). Maybe it's the reset() method. Would it be possible to achieve the reset() functionality (maybe by adding something to the config file) if Struts used HashMaps instead of ActionForms? Thanks, Dan -- 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: all this traffic
The most significant way to reduce traffic is to answer peoples questions. Eddie Bush is a heavy user of this list, but probably cuts the total amount of traffic. Sorry, Eddie, did not mean to give you a compliment, but had to anyway. ///;-) The list is for using. The traffic attests to the significance of struts, which while not perfect, sure provides a lot of functionality to people. User traffic is good, I think. At 10:41 AM 9/30/2002 -0500, you wrote: Since March of 2001, there has been almost 27K emails sent to the list. Why the continuous pouring of emails? Maybe another technique has to be developed for people to research problems. By the way - the separate folder technique works until you take a trip for week and things get back logged. - Malcolm -Original Message- From: Assenza, Chris [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 8:43 AM To: 'Struts Users Mailing List' Subject: RE: all this traffic Setting up your mail reader to automatically forward STRUTS-USER messages to a separate folder, and then sorting by thread, is a trivially easy approach to dealing with volume issues. Your inbox is no longer clogged, you can go read Struts mail when you have time, and can ignore entire irrelevant threads with a single command to advance to the next thread. Indeed, that is in fact my method of choice for using this list. All one has to do is look at subject headers to asses interest and move on. I usually read everything I want to read and then delete the contents of the folder. There are some drawbacks to this approach [or any client-based solution] though, most notably if you have low size limits on your mail account or if you access your mail remotely on a regular basis (ie. a traveller). Sitting in a hotel room waiting to communicate with Exchange (or worse POP3) becomes rather burdensome when there are 1k+ unread messages in the Struts folder. Overall, still the best approach, but I can definitely see why some people might want to reduce volume. However, I'm not big on the struts-newbie list idea myself. -Chris -- 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]
RE: [OT - Java] How can I do this in Java?
Easy, John ... step away from the keyboard ... carefully now ... :-) Seriously, I wasn't sure what the best way of doing this was, or even if it could be done. I'm still looking at the code (still undecided about the exceptions) and may yet end up recoding it as a static HashMap. I'm still learning about the in's and out's of reflection, and thought I'd try it this way first (always looking to learn something new!). Thanks for your comments though - and by the way, it's not zip codes, it's Drivers License numbers (the format of 'em, anyway!). Jerry -Original Message- From: John Bindel [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 1:49 PM To: Struts Users Mailing List Subject: Re: [OT - Java] How can I do this in Java? On Mon, Sep 30, 2002 at 12:02:41PM -0500, Jerry Jalenak wrote: Yeah, already ran across the exceptions. Right now I'm trying to decide how to handle them since all of this code is actually in a custom Validator routine. Good Lord, people, why is reflection anything but the option of last resort here? You really do not want to be calling Class.forname(String) unless there is some class that cannot be loaded by the compiler. First, calling Class.forname is slow, and second, it perversely gets rid of the compile-time type-safety that you would have is you simply used MyClass.class. Reflection is a tool that's useful when you do not know at build time the classes with which you will be dealing. It's useful for discovery of APIs. Using reflection instead of a lookup table is needlessly obtuse and will cause your VM to do all sorts of work on which any programmer should not want to be wasting CPU cycles. 1. Using reflection here is fragile, especially if it's not wrapped within the class that defines your constants. Java is a strongly typed language so letting the compiler help you is encouraged. 2. Using reflection is slow. If you still think it's the way you want to go, I would strongly recommend limiting the times you call Class.forname, etc., such that you do not call it every time you validate the zip code. 3. Using reflection makes you check all sorts of exceptions for things that you as the programmer know should not occur, but only can be you are circumventing the type checking provided by the language. This is a clue that what should be a simple task is being made more complex than it needs to be. 4. I'm not sure what your application is, but using regexp strings to validate ZIP codes per state seems like a bad idea. The US post office makes new ZIP codes all the time, and unless you are getting a list from them every week, the most you may want your application to do is warn the user that the application doesn't recognize the ZIP code. 5. Tell your product managers that validating ZIP codes is not something you can do reliably without an often-updated list of ZIP codes that you would need to download from the Post Office on a regular schedule since your list of regexp string will become outdated. 6. Lookup tables implemented by arrays or HashMaps are orders of magnitude faster than the sequence of function calls and system calls that you have to do with reflection. I'm sorry I had to write this, but I am befuddled by the lack of outcry over using reflection instead of a simple lookup table. Cheers, John -Original Message- From: Taylor, Jason [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 11:57 AM To: 'Struts Users Mailing List' Subject: RE: [OT - Java] How can I do this in Java? good point-- you'd also want to printStackTrace() (if possible) before rethrowing InvocationTargetException, since it can be difficult to debug an ITE otherwise... -Original Message- From: Daniel Jaffa [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 9:49 AM To: Struts Users Mailing List Subject: Re: [OT - Java] How can I do this in Java? Make sure your code in a proper try and catch. Using reflection spits out nasty errors if anything is not right.:( ClassCastException IllegalAccessException NoSuchMethodException InvocationTargetException Daniel jaffa - Original Message - From: Jerry Jalenak [EMAIL PROTECTED] To: 'Struts Users Mailing List' [EMAIL PROTECTED] Sent: Monday, September 30, 2002 11:46 AM Subject: RE: [OT - Java] How can I do this in Java? Jason - Thanks for the code snippet - worked like a charm first time! I tend to get lost in JavaDoc sometimes, so this was a nice example to have on how to wind my way through to the answer! Thanks again! John - Thanks for the suggestion on using the HashMap. I'm going to file it away for now and use Jason's reflection method - but it never hurts to have a couple of different methods to use on something like this!
Re: [OT - Java] How can I do this in Java?
Comments intermixed. On Mon, 30 Sep 2002, John Bindel wrote: Date: Mon, 30 Sep 2002 13:49:22 -0500 From: John Bindel [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Subject: Re: [OT - Java] How can I do this in Java? On Mon, Sep 30, 2002 at 12:02:41PM -0500, Jerry Jalenak wrote: Yeah, already ran across the exceptions. Right now I'm trying to decide how to handle them since all of this code is actually in a custom Validator routine. Good Lord, people, why is reflection anything but the option of last resort here? While I agree with you that using reflection was a poor design choice for the problem stated here (the patterns should really be loaded from a data file instead of introspecting from the class), your condemnation of reflection in general is based on an incorrect definition of the term, and also outdated behavior related to performance. See below for more. You really do not want to be calling Class.forname(String) unless there is some class that cannot be loaded by the compiler. First, calling Class.forname is slow, and second, it perversely gets rid of the compile-time type-safety that you would have is you simply used MyClass.class. The Class.forName() method is not really reflection -- it is dynamic class loading. Struts itself uses this to good effect, because it's not possible to know (at the time ActionServlet is compiled) the names of all the Action and ActionForm subclasses that *your* application will be using. Further, there is no loss of type safety when using dynamic class loading in the usual fashion, because you normally cast to the base class you are looking for. For example, module error checking, this is how Struts actually loads an Action class instance: ClassLoader loader = Thread.currentThread().getContextClassLoader(); if (classLoader == null) { loader = this.getClass().getClassLoader(); } Action action = (Action) loader.loadClass(actionClassName); Note the cast to an Action, which protects you from type safety problems. Of course, using dynamic class loading in the use case being discussed in this mail thread was totally unnecesary. But please stop casting aspersions on a very useful feature of the Java language that makes dynamically extensible applications like Struts possible in the first place. Reflection is a tool that's useful when you do not know at build time the classes with which you will be dealing. It's useful for discovery of APIs. Using reflection instead of a lookup table is needlessly obtuse and will cause your VM to do all sorts of work on which any programmer should not want to be wasting CPU cycles. 1. Using reflection here is fragile, especially if it's not wrapped within the class that defines your constants. Java is a strongly typed language so letting the compiler help you is encouraged. Since the problem at hand was to access *data*, the best approach would be to store the patterns externally in a properties file. Then, the data could be used by multiple classes when it is needed (including the class in which the format strings are currently embedded). 2. Using reflection is slow. If you still think it's the way you want to go, I would strongly recommend limiting the times you call Class.forname, etc., such that you do not call it every time you validate the zip code. Firstly, as above, Class.forName() is not reflection. Secondly, a subsequent call to Class.forName() for the same class name is *not* going to load the class bytecodes again; the class loader will remember that the requested class name has already been loaded, and just returns you the same instance. Thirdly, there is *zero* performance difference (at runtime) between loading a class via Class.forName() and loading one (for the first time) with a new operator. Why? Because they both end up calling the exact same loadClass() method -- it's just a question of whether the developer calls the method explicitly or the bytecodes generated by the compiler call it for you. As for the performance of real life uses of reflection, have you ever noticed how Struts actually implements the population of your form bean properties from the request parameters? Yep ... that's right ... every single call to a property setter is done via reflection. Seems fast enough to me, especially on a 1.4 JDK where the performance difference between direct calls and reflected calls is very very small. 3. Using reflection makes you check all sorts of exceptions for things that you as the programmer know should not occur, but only can be you are circumventing the type checking provided by the language. This is a clue that what should be a simple task is being made more complex than it needs to be. In the particular use case at hand, reflection is the wrong technology to use. However, it makes possible some things that would otherwise be impossible, or
Re: [OT - Java] How can I do this in Java?
On Mon, Sep 30, 2002 at 01:55:20PM -0500, Jerry Jalenak wrote: Easy, John ... step away from the keyboard ... carefully now ... :-) I'm sorry about that, I don't know why I converted DL to ZIP. The lookup table works nicely when you know you will start by knowing the state abbreviation. I would further recommend loading the strings from a data file, such as a Properties file. By making the map static, you would only do this once when the class loads. /** * This class gets the regular expression validators for drivers * licenses for each state. */ public class MyClass { private static final String PROPFILE_NAME = MyClass.properties; private static final Properties s_stateToDLRegExp = new Properties(); static { InputStream inProps = null; try { inProps = MyClass.class.getResourceAsStream(/ + PROPFILE_NAME); s_stateToDLRegExp.load(inProps); } catch (IOException excp) { throw new IllegalStateException(Could not init DL regexp); excp.printStackTracke(); // log the error } finally { if (inProps != null) { try { inProps.close(); } catch (IOException excp) { System.err.println(Could not cleanup properties file + PROPFILE_NAME); excp.printStackTrace(); } } } } public static String getDLRegExpForState(String state) { // Handle nulls however you want here. return s_stateToDLRegExp.getProperty(state); } } Seriously, I wasn't sure what the best way of doing this was, or even if it could be done. I'm still looking at the code (still undecided about the exceptions) and may yet end up recoding it as a static HashMap. I'm still learning about the in's and out's of reflection, and thought I'd try it this way first (always looking to learn something new!). Thanks for your comments though - and by the way, it's not zip codes, it's Drivers License numbers (the format of 'em, anyway!). Cheers, John -- end of line -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Access JSP in the WEB-INF - PART2
I moved all my JSP files under WEB-INF JSP. Now my new issue Lets take the following example. I need my user to enter vendor information and then cofirm it, then save it. Below is how my struts-config.xml file is setup action path=/PaymentVendor_AddVendor type=com.ubspw.cdd.formaction.paymentvendor.AddVendorFormAction name=VendorFormBean scope=request input=/WEB-INF/JSP/PaymentVendor_AddVendor.jsp validate=false forward name=success path=/WEB-INF/JSP/PaymentVendor_AddVendor.jsp/ /action action path=/PaymentVendor_AddReview type=com.ubspw.cdd.formaction.paymentvendor.AddReviewFormAction name=VendorFormBean scope=request input=/WEB-INF/JSP/PaymentVendor_AddVendor.jsp parameter=test forward name=success path=/WEB-INF/JSP/PaymentVendor_AddReview.jsp/ forward name=cancel path=/WEB-INF/JSP/PaymentVendor_AddVendor.jsp/ /action So my user enters the url http://servername/off/PaymentVendor_addVendor.do which has validate turned off just to display the form Payment_AddVendor.jsp. In the Payment_AddVendor.jsp my form action has /PaymentVendor_AddReview.do. So the form shows up and then user enters the information and clicks submit. my confirm pages shows up right. I am now going to have my form action in the PaymentVendor_AddReview.jsp page point to /PaymentVendor_save Is this the right way to design a struts app? -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: [OT - Java] How can I do this in Java?
On Mon, Sep 30, 2002 at 12:22:25PM -0700, Craig R. McClanahan wrote: Comments intermixed. Same. On Mon, 30 Sep 2002, John Bindel wrote: Date: Mon, 30 Sep 2002 13:49:22 -0500 From: John Bindel [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Subject: Re: [OT - Java] How can I do this in Java? On Mon, Sep 30, 2002 at 12:02:41PM -0500, Jerry Jalenak wrote: Yeah, already ran across the exceptions. Right now I'm trying to decide how to handle them since all of this code is actually in a custom Validator routine. Good Lord, people, why is reflection anything but the option of last resort here? While I agree with you that using reflection was a poor design choice for the problem stated here (the patterns should really be loaded from a data file instead of introspecting from the class), your condemnation of reflection in general is based on an incorrect definition of the term, and also outdated behavior related to performance. See below for more. Let me know how jdk 1.4 does on the test below. It seems like it would have been simple for a class loader to do the same caching of classes, but such was not the case when I have looked at it. You really do not want to be calling Class.forname(String) unless there is some class that cannot be loaded by the compiler. First, calling Class.forname is slow, and second, it perversely gets rid of the compile-time type-safety that you would have is you simply used MyClass.class. The Class.forName() method is not really reflection -- it is dynamic class loading. IMO, the Class class itself is a part of reflection as stated below. Struts itself uses this to good effect, because it's not possible to know (at the time ActionServlet is compiled) the names of all the Action and ActionForm subclasses that *your* application will be using. Agreed, but it wouldn't load class for name every time the action is called. It is needed only the first time the action is instantiated. This is exactly the type of case in which I stated reflection is useful. Further, there is no loss of type safety when using dynamic class loading in the usual fashion, because you normally cast to the base class you are looking for. For example, module error checking, this is how Struts actually loads an Action class instance: ClassLoader loader = Thread.currentThread().getContextClassLoader(); if (classLoader == null) { loader = this.getClass().getClassLoader(); } Action action = (Action) loader.loadClass(actionClassName); Note the cast to an Action, which protects you from type safety problems. Which in general may lead to a runtime ClassCastException, which is not desirable when you can avoid it. Using reflection in cases that do not require dynamic behavior is generally not the right approach. Of course, using dynamic class loading in the use case being discussed in this mail thread was totally unnecesary. But please stop casting aspersions on a very useful feature of the Java language that makes dynamically extensible applications like Struts possible in the first place. Did I? My next statement shows exactly when I think reflection is a useful tool, specifically when you are loading classes that cannot be known until runtime as in Struts and other useful places. Reflection is a tool that's useful when you do not know at build time the classes with which you will be dealing. It's useful for discovery of APIs. Using reflection instead of a lookup table is needlessly obtuse and will cause your VM to do all sorts of work on which any programmer should not want to be wasting CPU cycles. 1. Using reflection here is fragile, especially if it's not wrapped within the class that defines your constants. Java is a strongly typed language so letting the compiler help you is encouraged. Since the problem at hand was to access *data*, the best approach would be to store the patterns externally in a properties file. Then, the data could be used by multiple classes when it is needed (including the class in which the format strings are currently embedded). 2. Using reflection is slow. If you still think it's the way you want to go, I would strongly recommend limiting the times you call Class.forname, etc., such that you do not call it every time you validate the zip code. Firstly, as above, Class.forName() is not reflection. Sure it is. These are the first two sentences of Sun's javadoc for java.lang.Class: Instances of the class Class represent classes and interfaces in a running Java application. Every array also belongs to a class that is reflected as a Class object that is shared by all arrays with the same element type and number of dimensions. They say reflected as a Class object, which you can take to mean what you will. Maybe it's only a true reflection API when it's
Re: Access JSP in the WEB-INF - PART2
Does it do the right thing? Does it do the thing right? Ok - there you go :-) Seriously though - it sounds like you're right on-track to me ... -- Eddie Bush -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: [OT - Java] How can I do this in Java?
Sorry I didn't think a little more before posting my 'help'. Seems it spurred a good discussion, though. I don't use reflection terribly often (just to select service factory classes at initialization usually), but then again I don't often attempt to dynamically select static final constants. -Original Message- From: John Bindel [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 12:48 PM To: Struts Users Mailing List Subject: Re: [OT - Java] How can I do this in Java? On Mon, Sep 30, 2002 at 12:22:25PM -0700, Craig R. McClanahan wrote: Comments intermixed. Same. On Mon, 30 Sep 2002, John Bindel wrote: Date: Mon, 30 Sep 2002 13:49:22 -0500 From: John Bindel [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Subject: Re: [OT - Java] How can I do this in Java? On Mon, Sep 30, 2002 at 12:02:41PM -0500, Jerry Jalenak wrote: Yeah, already ran across the exceptions. Right now I'm trying to decide how to handle them since all of this code is actually in a custom Validator routine. Good Lord, people, why is reflection anything but the option of last resort here? While I agree with you that using reflection was a poor design choice for the problem stated here (the patterns should really be loaded from a data file instead of introspecting from the class), your condemnation of reflection in general is based on an incorrect definition of the term, and also outdated behavior related to performance. See below for more. Let me know how jdk 1.4 does on the test below. It seems like it would have been simple for a class loader to do the same caching of classes, but such was not the case when I have looked at it. You really do not want to be calling Class.forname(String) unless there is some class that cannot be loaded by the compiler. First, calling Class.forname is slow, and second, it perversely gets rid of the compile-time type-safety that you would have is you simply used MyClass.class. The Class.forName() method is not really reflection -- it is dynamic class loading. IMO, the Class class itself is a part of reflection as stated below. Struts itself uses this to good effect, because it's not possible to know (at the time ActionServlet is compiled) the names of all the Action and ActionForm subclasses that *your* application will be using. Agreed, but it wouldn't load class for name every time the action is called. It is needed only the first time the action is instantiated. This is exactly the type of case in which I stated reflection is useful. Further, there is no loss of type safety when using dynamic class loading in the usual fashion, because you normally cast to the base class you are looking for. For example, module error checking, this is how Struts actually loads an Action class instance: ClassLoader loader = Thread.currentThread().getContextClassLoader(); if (classLoader == null) { loader = this.getClass().getClassLoader(); } Action action = (Action) loader.loadClass(actionClassName); Note the cast to an Action, which protects you from type safety problems. Which in general may lead to a runtime ClassCastException, which is not desirable when you can avoid it. Using reflection in cases that do not require dynamic behavior is generally not the right approach. Of course, using dynamic class loading in the use case being discussed in this mail thread was totally unnecesary. But please stop casting aspersions on a very useful feature of the Java language that makes dynamically extensible applications like Struts possible in the first place. Did I? My next statement shows exactly when I think reflection is a useful tool, specifically when you are loading classes that cannot be known until runtime as in Struts and other useful places. Reflection is a tool that's useful when you do not know at build time the classes with which you will be dealing. It's useful for discovery of APIs. Using reflection instead of a lookup table is needlessly obtuse and will cause your VM to do all sorts of work on which any programmer should not want to be wasting CPU cycles. 1. Using reflection here is fragile, especially if it's not wrapped within the class that defines your constants. Java is a strongly typed language so letting the compiler help you is encouraged. Since the problem at hand was to access *data*, the best approach would be to store the patterns externally in a properties file. Then, the data could be used by multiple classes when it is needed (including the class in which the format strings are currently embedded). 2. Using reflection is slow. If you still think it's the way you want to go, I would strongly recommend limiting the times you call Class.forname, etc., such that you do not call it every time you validate the zip code. Firstly, as above,
Re: [OT - Java] How can I do this in Java?
I could not agree more on reflection. The management potential of reflection is huge. I really like Stuart Dabbs Halloway's book Component Development for the Java Platform, which is really reflection based in essence, and love the JMX API. Still, the present problem is not a very good example of the proper use of reflection. Just tossing my three cents in. I wish I had a job where I could work on the development of Java management tools with JMX. Man! That would be a kick! The possibilities are staggering. At 12:22 PM 9/30/2002 -0700, you wrote: Comments intermixed. On Mon, 30 Sep 2002, John Bindel wrote: Date: Mon, 30 Sep 2002 13:49:22 -0500 From: John Bindel [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Subject: Re: [OT - Java] How can I do this in Java? On Mon, Sep 30, 2002 at 12:02:41PM -0500, Jerry Jalenak wrote: Yeah, already ran across the exceptions. Right now I'm trying to decide how to handle them since all of this code is actually in a custom Validator routine. Good Lord, people, why is reflection anything but the option of last resort here? While I agree with you that using reflection was a poor design choice for the problem stated here (the patterns should really be loaded from a data file instead of introspecting from the class), your condemnation of reflection in general is based on an incorrect definition of the term, and also outdated behavior related to performance. See below for more. You really do not want to be calling Class.forname(String) unless there is some class that cannot be loaded by the compiler. First, calling Class.forname is slow, and second, it perversely gets rid of the compile-time type-safety that you would have is you simply used MyClass.class. The Class.forName() method is not really reflection -- it is dynamic class loading. Struts itself uses this to good effect, because it's not possible to know (at the time ActionServlet is compiled) the names of all the Action and ActionForm subclasses that *your* application will be using. Further, there is no loss of type safety when using dynamic class loading in the usual fashion, because you normally cast to the base class you are looking for. For example, module error checking, this is how Struts actually loads an Action class instance: ClassLoader loader = Thread.currentThread().getContextClassLoader(); if (classLoader == null) { loader = this.getClass().getClassLoader(); } Action action = (Action) loader.loadClass(actionClassName); Note the cast to an Action, which protects you from type safety problems. Of course, using dynamic class loading in the use case being discussed in this mail thread was totally unnecesary. But please stop casting aspersions on a very useful feature of the Java language that makes dynamically extensible applications like Struts possible in the first place. Reflection is a tool that's useful when you do not know at build time the classes with which you will be dealing. It's useful for discovery of APIs. Using reflection instead of a lookup table is needlessly obtuse and will cause your VM to do all sorts of work on which any programmer should not want to be wasting CPU cycles. 1. Using reflection here is fragile, especially if it's not wrapped within the class that defines your constants. Java is a strongly typed language so letting the compiler help you is encouraged. Since the problem at hand was to access *data*, the best approach would be to store the patterns externally in a properties file. Then, the data could be used by multiple classes when it is needed (including the class in which the format strings are currently embedded). 2. Using reflection is slow. If you still think it's the way you want to go, I would strongly recommend limiting the times you call Class.forname, etc., such that you do not call it every time you validate the zip code. Firstly, as above, Class.forName() is not reflection. Secondly, a subsequent call to Class.forName() for the same class name is *not* going to load the class bytecodes again; the class loader will remember that the requested class name has already been loaded, and just returns you the same instance. Thirdly, there is *zero* performance difference (at runtime) between loading a class via Class.forName() and loading one (for the first time) with a new operator. Why? Because they both end up calling the exact same loadClass() method -- it's just a question of whether the developer calls the method explicitly or the bytecodes generated by the compiler call it for you. As for the performance of real life uses of reflection, have you ever noticed how Struts actually implements the population of your form bean properties from the request parameters? Yep ... that's right ... every single call to a property setter is done via reflection.
Problem with Forward
Hi, my name is Rodrigo, I'm using struts with Velocity, my problems is that when I use the code return (mapping.findForward(HomeMenuShow)); in the edit form for employer (for example) to return to the main menu, if the action was save, the app save the new employer, then show the main menu, but if you refresh the menu page, the app try to store again the employer, if you see the URL, it still has the same save URL, not the menu URL, ok, but if I change the param FORWARD in web.xml for the action servlet to use a redirect in true with: init-param param-nameforward/param-name param-valueorg.apache.struts.action.RedirectingActionForward /param-value /init-param this work fine with URL's, and the retry to save not happens again, but all Velocity tags like $myClass.cod_employer doesn't work anytime. Thanks, Rodrigo Arias -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: [OT - Java] How can I do this in Java?
-Original Message- From: John Bindel [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 12:48 PM To: Struts Users Mailing List Subject: Re: [OT - Java] How can I do this in Java? On Mon, Sep 30, 2002 at 12:22:25PM -0700, Craig R. McClanahan wrote: Comments intermixed. Same. On Mon, 30 Sep 2002, John Bindel wrote: Date: Mon, 30 Sep 2002 13:49:22 -0500 From: John Bindel [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Subject: Re: [OT - Java] How can I do this in Java? On Mon, Sep 30, 2002 at 12:02:41PM -0500, Jerry Jalenak wrote: Yeah, already ran across the exceptions. Right now I'm trying to decide how to handle them since all of this code is actually in a custom Validator routine. Good Lord, people, why is reflection anything but the option of last resort here? While I agree with you that using reflection was a poor design choice for the problem stated here (the patterns should really be loaded from a data file instead of introspecting from the class), your condemnation of reflection in general is based on an incorrect definition of the term, and also outdated behavior related to performance. See below for more. Let me know how jdk 1.4 does on the test below. It seems like it would have been simple for a class loader to do the same caching of classes, but such was not the case when I have looked at it. Once I edited the code so that it would compile ;-} I got the following output: time: 140ms time: 16ms While the second is certainly way faster than the first (not surprisingly), what struck me most was that the average cost of Class.forName() was only 14 microseconds. Admittedly, you wouldn't want to be doing this gratuitously, but still, it seems plenty fast to me. (This is using Sun JDK 1.4.1-b21 on a dual Intel 800MHz under Win2K.) -- Martin Cooper You really do not want to be calling Class.forname(String) unless there is some class that cannot be loaded by the compiler. First, calling Class.forname is slow, and second, it perversely gets rid of the compile-time type-safety that you would have is you simply used MyClass.class. The Class.forName() method is not really reflection -- it is dynamic class loading. IMO, the Class class itself is a part of reflection as stated below. Struts itself uses this to good effect, because it's not possible to know (at the time ActionServlet is compiled) the names of all the Action and ActionForm subclasses that *your* application will be using. Agreed, but it wouldn't load class for name every time the action is called. It is needed only the first time the action is instantiated. This is exactly the type of case in which I stated reflection is useful. Further, there is no loss of type safety when using dynamic class loading in the usual fashion, because you normally cast to the base class you are looking for. For example, module error checking, this is how Struts actually loads an Action class instance: ClassLoader loader = Thread.currentThread().getContextClassLoader(); if (classLoader == null) { loader = this.getClass().getClassLoader(); } Action action = (Action) loader.loadClass(actionClassName); Note the cast to an Action, which protects you from type safety problems. Which in general may lead to a runtime ClassCastException, which is not desirable when you can avoid it. Using reflection in cases that do not require dynamic behavior is generally not the right approach. Of course, using dynamic class loading in the use case being discussed in this mail thread was totally unnecesary. But please stop casting aspersions on a very useful feature of the Java language that makes dynamically extensible applications like Struts possible in the first place. Did I? My next statement shows exactly when I think reflection is a useful tool, specifically when you are loading classes that cannot be known until runtime as in Struts and other useful places. Reflection is a tool that's useful when you do not know at build time the classes with which you will be dealing. It's useful for discovery of APIs. Using reflection instead of a lookup table is needlessly obtuse and will cause your VM to do all sorts of work on which any programmer should not want to be wasting CPU cycles. 1. Using reflection here is fragile, especially if it's not wrapped within the class that defines your constants. Java is a strongly typed language so letting the compiler help you is encouraged. Since the problem at hand was to access *data*, the best approach would be to store the patterns externally in a properties file. Then, the data could be used by multiple classes when it is needed (including the class in
Re: [OT - Java] How can I do this in Java?
John Bindel wrote: On Mon, Sep 30, 2002 at 12:02:41PM -0500, Jerry Jalenak wrote: Yeah, already ran across the exceptions. Right now I'm trying to decide how to handle them since all of this code is actually in a custom Validator routine. Good Lord, people, why is reflection anything but the option of last resort here? Favour `Interfaces' to reflection if you can help it. -- Peter Pilgrim +-\ +-+++++ Java Technologist | | | ||||| 'n' Shine | O | | || --+| ---+ /\| ._ / | | \ \ || / \ | | \ \ | |+-- || ---+ A new day /_ _\ Up| | | | | ||||| is coming ||+-+ +-+ +-+++++ home page=http://www.xenonsoft.demon.co.uk/; / -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Struts Validator doesn't seem to be working
I'm wondering what I'm doing wrong. I tried dropping last nights build (20020930) of struts-validator.war into Tomcat 4.1.12, and it does not work at all. Is this a known problem? The index.jsp page contains the following message in red: ERROR: Validator resources not loaded -- check Commons Logging logs for error messages. So I looked into it a little and noticed in Tomcat's log that a FastHashMap is throwing a ConcurrentModificationException: java.util.ConcurrentModificationException at org.apache.commons.collections.FastHashMap$CollectionView$CollectionViewIter ator.hasNext(Unknown Source) at org.apache.commons.validator.Field.processMessageComponents(Field.java:524) at org.apache.commons.validator.Field.process(Field.java:474) at org.apache.commons.validator.Form.process(Form.java:152) at org.apache.commons.validator.FormSet.process(FormSet.java:221) at org.apache.commons.validator.ValidatorResources.processForms(ValidatorResour ces.java:359) at org.apache.commons.validator.ValidatorResources.process(ValidatorResources.j ava:304) at org.apache.struts.validator.ValidatorPlugIn.initResources(ValidatorPlugIn.ja va:234) at org.apache.struts.validator.ValidatorPlugIn.init(ValidatorPlugIn.java:167) at org.apache.struts.action.ActionServlet.initApplicationPlugIns(ActionServlet. java:991) at org.apache.struts.action.ActionServlet.init(ActionServlet.java:458) at javax.servlet.GenericServlet.init(GenericServlet.java:256) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:92 4) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:813) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java: 3341) at org.apache.catalina.core.StandardContext.start(StandardContext.java:3534) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:8 21) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:807) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:579) at org.apache.catalina.core.StandardHostDeployer.install(StandardHostDeployer.j ava:257) at org.apache.catalina.core.StandardHost.install(StandardHost.java:772) at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:569 ) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:411) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:879) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:368) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSuppor t.java:166) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1196) at org.apache.catalina.core.StandardHost.start(StandardHost.java:738) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1188) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:347) at org.apache.catalina.core.StandardService.start(StandardService.java:497) at org.apache.catalina.core.StandardServer.start(StandardServer.java:2189) at org.apache.catalina.startup.Catalina.start(Catalina.java:510) at org.apache.catalina.startup.Catalina.execute(Catalina.java:400) at org.apache.catalina.startup.Catalina.process(Catalina.java:180) at java.lang.reflect.Method.invoke(Native Method) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:203) [ERROR] ValidatorPlugIn - -null java.util.ConcurrentModificationException 2002-09-30 17:03:35 StandardContext[/struts-validator]: Servlet /struts-validator threw load() exception javax.servlet.UnavailableException: Cannot load a validator resource from '/WEB-INF/validator-rules.xml, /WEB-INF/validation.xml' at org.apache.struts.validator.ValidatorPlugIn.init(ValidatorPlugIn.java:171) at org.apache.struts.action.ActionServlet.initApplicationPlugIns(ActionServlet. java:991) at org.apache.struts.action.ActionServlet.init(ActionServlet.java:458) at javax.servlet.GenericServlet.init(GenericServlet.java:256) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:92 4) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:813) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java: 3341) at org.apache.catalina.core.StandardContext.start(StandardContext.java:3534) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:8 21) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:807) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:579) at org.apache.catalina.core.StandardHostDeployer.install(StandardHostDeployer.j ava:257
RE: [OT - Java] How can I do this in Java?
I'd like to go ahead and point out that the little classloading test given here may not always give the same results, even on the same machine with the same VM; it is largely dependent on what classloader loads the class you are doing the forName() on. This is because the ClassLoader which loaded the class you are in, and consequently the one that will be used by the forName() method, may be several levels of ancestry removed from the bootstrap classloader (or its ultimate parent, if it isn't the bootstrap classloader). This means that each hop of delegation results in a method call, introducing some overhead to the time necessary to locate the class you are attempting to load. If you are running these tests in an app. server environment, I guarantee you a forName() will take longer than if run in a minimal test class. Incidentally, these extra method calls may explain the discrepancy you (the royal 'you':) observed between executing forName each time and using the HashMap reference after the first time. 'Course, this all begs the question: Who cares? ;) a little JavaDoc reference for ya (java.lang.ClassLoader): The ClassLoader class uses a delegation model to search for classes and resources. Each instance of ClassLoader has an associated parent class loader. When called upon to find a class or resource, a ClassLoader instance will delegate the search for the class or resource to its parent class loader before attempting to find the class or resource itself. The virtual machine's built-in class loader, called the bootstrap class loader, does not itself have a parent but may serve as the parent of a ClassLoader instance. -Original Message- From: Martin Cooper [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 2:53 PM To: 'Struts Users Mailing List' Subject: RE: [OT - Java] How can I do this in Java? -Original Message- From: John Bindel [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 12:48 PM To: Struts Users Mailing List Subject: Re: [OT - Java] How can I do this in Java? On Mon, Sep 30, 2002 at 12:22:25PM -0700, Craig R. McClanahan wrote: Comments intermixed. Same. On Mon, 30 Sep 2002, John Bindel wrote: Date: Mon, 30 Sep 2002 13:49:22 -0500 From: John Bindel [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Subject: Re: [OT - Java] How can I do this in Java? On Mon, Sep 30, 2002 at 12:02:41PM -0500, Jerry Jalenak wrote: Yeah, already ran across the exceptions. Right now I'm trying to decide how to handle them since all of this code is actually in a custom Validator routine. Good Lord, people, why is reflection anything but the option of last resort here? While I agree with you that using reflection was a poor design choice for the problem stated here (the patterns should really be loaded from a data file instead of introspecting from the class), your condemnation of reflection in general is based on an incorrect definition of the term, and also outdated behavior related to performance. See below for more. Let me know how jdk 1.4 does on the test below. It seems like it would have been simple for a class loader to do the same caching of classes, but such was not the case when I have looked at it. Once I edited the code so that it would compile ;-} I got the following output: time: 140ms time: 16ms While the second is certainly way faster than the first (not surprisingly), what struck me most was that the average cost of Class.forName() was only 14 microseconds. Admittedly, you wouldn't want to be doing this gratuitously, but still, it seems plenty fast to me. (This is using Sun JDK 1.4.1-b21 on a dual Intel 800MHz under Win2K.) -- Martin Cooper You really do not want to be calling Class.forname(String) unless there is some class that cannot be loaded by the compiler. First, calling Class.forname is slow, and second, it perversely gets rid of the compile-time type-safety that you would have is you simply used MyClass.class. The Class.forName() method is not really reflection -- it is dynamic class loading. IMO, the Class class itself is a part of reflection as stated below. Struts itself uses this to good effect, because it's not possible to know (at the time ActionServlet is compiled) the names of all the Action and ActionForm subclasses that *your* application will be using. Agreed, but it wouldn't load class for name every time the action is called. It is needed only the first time the action is instantiated. This is exactly the type of case in which I stated reflection is useful. Further, there is no loss of type safety when using dynamic class loading in the usual
Re: [OT - Java] How can I do this in Java?
I agree that reflection is not a good solution here, but does have useful application in general (but it isn't needed here, so don't use it). Use a singleton or a statically-initialized Map to look up the patterns based on the state. Save yourself some time by putting Patterns in the map, identified by the state represented as a String. patternMap.add(AK, Pattern.compile(^[0-9]{1,7}$)); Put the map in its own class (perhaps a singleton), so you would get patterns from it with a call like one of these: Pattern pattern = LicensePatterns.getInstance().getPattern(licenseState); -or- Pattern pattern = LicensePatterns.getPattern(licenseState); Putting the patterns is a Properties file seems like a good idea, too. How often do the patterns change? Perhaps you could add a refresh() method to the singleton class to reload the patterns from the properties file if you anticipate that they will change while the app is supposed to be running. This is usually the case, but it is often overlooked when setting such constants. -Max - Original Message - From: Jerry Jalenak [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, September 30, 2002 7:49 AM Subject: [OT - Java] How can I do this in Java? OK - off topic, but Sun's java forum sucks, and there are an incredible number of Java guru's on this list, so I thought I'd throw this out here. (That and I am using this in a custom validation routine :-))Any help would be GREATLY appreciated! Here's the scenario - I've got a series of static constants that represent Java regular expressions. These RE's are used to validate driver license formats for the 50 states + DC. The strings look like this: public static final String AK = ^[0-9]{1,7}$; public static final String AL = ^[0-9]{7}$; public static final String AR = ^[0-9]{8,9}$; public static final String AZ = ^[0-9ABDY][0-9]{8}$|^[A-Z][0-9]{3,6}$|^[A-Z]{2}[0-9]{3,5}$; public static final String CA = ^[A-Z][0-9]{4,7}$; public static final String CO = ^[A-Z][0-9]{1,6}$|^[A-Z]{2}[0-9]{1,6}$|^[0-9]{9}$; etc. etc. etc. On my form I have a drop-down box of states, and a field for the license number. In my custom validator routine, I pick up the value of the state, and build a string to represent the constant - i.e. private static boolean validateDriversLicenseNumber(String licenseState, String licenseNumber) { String licenseConstant = Constants. + licenseState; I then want to use licenseConstant in a Pattern / Match: Pattern p = Pattern.compile(licenseConstant, Pattern.CASE_INSENSITIVE); Match m = p.matcher(licenseNumber); return (m.find()); } Obviously the line String licenseConstant = Constants. + licenseState; does not give me the value of Constant.state name; the question I have is, is there a method (or something) that will allow me to build such a string, and return the value (i.e. the regular expression)? Or is there a better way of doing this? TIA! Jerry Jalenak Web Publishing LabOne, Inc. 10101 Renner Blvd. Lenexa, KS 66219 (913) 577-1496 [EMAIL PROTECTED] This transmission (and any information attached to it) may be confidential and is intended solely for the use of the individual or entity to which it is addressed. If you are not the intended recipient or the person responsible for delivering the transmission to the intended recipient, be advised that you have received this transmission in error and that any use, dissemination, forwarding, printing, or copying of this information is strictly prohibited. If you have received this transmission in error, please immediately notify LabOne at (800)388-4675. -- 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]
okay, one more time for the slow people...
How do you use the DyanActionForm in the action classes. I saw 2 different examples in the archive, neither of which worked for me. DynaActionFormClass dafc = DynaActionFormClass.getDynaActionFormClass(AddUserForm); DynaActionForm myForm = dafc.newInstance(); gives me this compile error: AddUserAction.java [48:1] incompatible types found : org.apache.commons.beanutils.DynaBean required: org.apache.struts.action.DynaActionForm line 48 : DynaActionForm myForm = dafc.newInstance(); What is the official way? Thanks. Thanks -- Vincent Stoessel Linux Systems Developer vincent xaymaca.com -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: [OT - Java] How can I do this in Java?
Let's take it one step further and make the Map a 1st-class object. After all, shouldn't all knowledge of how to recognize a driver's license be localized to a single class? Then the external interface can be a simple as isValidLicense( state, licenseString ); Max Cooper wrote: I agree that reflection is not a good solution here, but does have useful application in general (but it isn't needed here, so don't use it). Use a singleton or a statically-initialized Map to look up the patterns based on the state. Save yourself some time by putting Patterns in the map, identified by the state represented as a String. patternMap.add(AK, Pattern.compile(^[0-9]{1,7}$)); Put the map in its own class (perhaps a singleton), so you would get patterns from it with a call like one of these: Pattern pattern = LicensePatterns.getInstance().getPattern(licenseState); -or- Pattern pattern = LicensePatterns.getPattern(licenseState); Putting the patterns is a Properties file seems like a good idea, too. How often do the patterns change? Perhaps you could add a refresh() method to the singleton class to reload the patterns from the properties file if you anticipate that they will change while the app is supposed to be running. This is usually the case, but it is often overlooked when setting such constants. -Max - Original Message - From: Jerry Jalenak [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, September 30, 2002 7:49 AM Subject: [OT - Java] How can I do this in Java? OK - off topic, but Sun's java forum sucks, and there are an incredible number of Java guru's on this list, so I thought I'd throw this out here. (That and I am using this in a custom validation routine :-))Any help would be GREATLY appreciated! Here's the scenario - I've got a series of static constants that represent Java regular expressions. These RE's are used to validate driver license formats for the 50 states + DC. The strings look like this: public static final String AK = ^[0-9]{1,7}$; public static final String AL = ^[0-9]{7}$; public static final String AR = ^[0-9]{8,9}$; public static final String AZ = ^[0-9ABDY][0-9]{8}$|^[A-Z][0-9]{3,6}$|^[A-Z]{2}[0-9]{3,5}$; public static final String CA = ^[A-Z][0-9]{4,7}$; public static final String CO = ^[A-Z][0-9]{1,6}$|^[A-Z]{2}[0-9]{1,6}$|^[0-9]{9}$; etc. etc. etc. On my form I have a drop-down box of states, and a field for the license number. In my custom validator routine, I pick up the value of the state, and build a string to represent the constant - i.e. private static boolean validateDriversLicenseNumber(String licenseState, String licenseNumber) { String licenseConstant = Constants. + licenseState; I then want to use licenseConstant in a Pattern / Match: Pattern p = Pattern.compile(licenseConstant, Pattern.CASE_INSENSITIVE); Match m = p.matcher(licenseNumber); return (m.find()); } Obviously the line String licenseConstant = Constants. + licenseState; does not give me the value of Constant.state name; the question I have is, is there a method (or something) that will allow me to build such a string, and return the value (i.e. the regular expression)? Or is there a better way of doing this? TIA! Jerry Jalenak Web Publishing LabOne, Inc. 10101 Renner Blvd. Lenexa, KS 66219 (913) 577-1496 [EMAIL PROTECTED] This transmission (and any information attached to it) may be confidential and is intended solely for the use of the individual or entity to which it is addressed. If you are not the intended recipient or the person responsible for delivering the transmission to the intended recipient, be advised that you have received this transmission in error and that any use, dissemination, forwarding, printing, or copying of this information is strictly prohibited. If you have received this transmission in error, please immediately notify LabOne at (800)388-4675. -- 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]
Re: okay, one more time for the slow people...
- Declare your form to be of type DynaActionForm in struts-config - Declare your properties to be of whatever type they need to be - Preface the page call with an action which will cast the form argument to be a DynaActionForm - call form.set(property, value) as needed - forward to the page that will use the form Chapter 5 pg 20 of Chuck's book covers this quite well. (That may not be exact, but it's close) I'm not going to claim it's the official way - but it's often done this way, for sure. Follow Chuck's example. Remember that (unless you have extenuating circumstances - most of the time pre-population does not qualify) you should never have to create a form yourself. Expect it to be there. If it's not, double-check your config to ensure you told Struts to make sure it was there. If you have done that and it didn't let it NPE and then file a bug report. Vincent Stoessel wrote: How do you use the DyanActionForm in the action classes. I saw 2 different examples in the archive, neither of which worked for me. DynaActionFormClass dafc = DynaActionFormClass.getDynaActionFormClass(AddUserForm); DynaActionForm myForm = dafc.newInstance(); gives me this compile error: AddUserAction.java [48:1] incompatible types found : org.apache.commons.beanutils.DynaBean required: org.apache.struts.action.DynaActionForm line 48 : DynaActionForm myForm = dafc.newInstance(); What is the official way? Thanks. -- Eddie Bush -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
[OT] HttpSessionAttributeListener - multiplicity
How many of these puppies are there per application? One? One for each session? I've been digging - even consulted the spec (!) and I don't see where it says. Sound (?) reasoning tells me there would be one for each session. Am I correct? Thanks! -- Eddie Bush -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: [OT] HttpSessionAttributeListener - multiplicity
It would appear you ever only have one of them :-( (Yeah, I should have just tried it first instead of asking, but ...) Faced with log output showing me you only ever get one of these, I'm ... the question comes to mind: Why does this exist? What problem does it solve? Eddie Bush wrote: How many of these puppies are there per application? One? One for each session? I've been digging - even consulted the spec (!) and I don't see where it says. Sound (?) reasoning tells me there would be one for each session. Am I correct? Thanks! -- Eddie Bush -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: [OT] HttpSessionAttributeListener - multiplicity
On Mon, 30 Sep 2002, Eddie Bush wrote: Date: Mon, 30 Sep 2002 18:13:13 -0500 From: Eddie Bush [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: Struts Users List [EMAIL PROTECTED] Subject: [OT] HttpSessionAttributeListener - multiplicity How many of these puppies are there per application? One? One for each session? As many as you want. Same goes for all the other event listeners. I've been digging - even consulted the spec (!) and I don't see where it says. Sound (?) reasoning tells me there would be one for each session. Am I correct? In the DTD for web.xml files (Chapter 13 of the spec), you'll see that the listener item in the !ELEMENT web-app definition has an asterisk (*) after it. That means you can have zero or more instances of this element; and therefore you can have zero or more listeners (of any type -- note that a single class can also implement more than one of the listener interfaces). Thanks! -- Eddie Bush Craig -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: [OT] HttpSessionAttributeListener - multiplicity
On Mon, 30 Sep 2002, Eddie Bush wrote: Date: Mon, 30 Sep 2002 18:27:05 -0500 From: Eddie Bush [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: Struts Users List [EMAIL PROTECTED] Subject: Re: [OT] HttpSessionAttributeListener - multiplicity It would appear you ever only have one of them :-( (Yeah, I should have just tried it first instead of asking, but ...) It would appear that you've either got a problem with how you registered the listeners (in web.xml), or your container has a bug. You should have something like this in web.xml: listener listener-classcom.foo.MyFirstListener/listener-class /listener listener listener-classcom.foo.MySecondListener/listener-class /listener where both classes implement HttpSessionAttributeListener, and possibly one or more of the other listener interfaces as well. Faced with log output showing me you only ever get one of these, I'm ... the question comes to mind: Why does this exist? What problem does it solve? Consider that you've got two different SessionAttributeListener classes in your toolkit: * One logs add/change/delete occurrences for debugging. * One watches for deletes of a particular attribute and does some other associated cleanup of allocated resources. I would certainly want to be able to use both of these in one webapp, without having to artificially combine them. Eddie Bush wrote: How many of these puppies are there per application? One? One for each session? I've been digging - even consulted the spec (!) and I don't see where it says. Sound (?) reasoning tells me there would be one for each session. Am I correct? Thanks! -- Eddie Bush Craig -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: [OT] HttpSessionAttributeListener - multiplicity
Yes, my question was multiplicity of each declared listener wrt sessions themselves (I should have been more clear). It would appear, based off my quick experimentation, that only one instance of each is loaded declared listener (at least HttpSessionAttributeListener). That wasn't what I had anticipated at all ... :-( Glad you made it back to the good ol'e US of A :-) Nice seeing you around again ;-) Craig R. McClanahan wrote: On Mon, 30 Sep 2002, Eddie Bush wrote: Date: Mon, 30 Sep 2002 18:13:13 -0500 From: Eddie Bush [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: Struts Users List [EMAIL PROTECTED] Subject: [OT] HttpSessionAttributeListener - multiplicity How many of these puppies are there per application? One? One for each session? As many as you want. Same goes for all the other event listeners. I've been digging - even consulted the spec (!) and I don't see where it says. Sound (?) reasoning tells me there would be one for each session. Am I correct? In the DTD for web.xml files (Chapter 13 of the spec), you'll see that the listener item in the !ELEMENT web-app definition has an asterisk (*) after it. That means you can have zero or more instances of this element; and therefore you can have zero or more listeners (of any type -- note that a single class can also implement more than one of the listener interfaces). Thanks! -- Eddie Bush Craig -- Eddie Bush -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: okay, one more time for the slow people...
The other way is: public Object onDisplayZoomExec(ActionEvent ae) throws Exception { String id = ae.getReq().getParameter(ID); // the PK is? long ia = BUtil.longString(id); TasksBean frm = (TasksBean) ((TilesEvent)ae).getFormBean(); setBBean( frm ); getBBean().findSingle(ia); // hard code for now ae.getReq().setAttribute(FORMBEAN, getBBean()); return ((TilesEvent)ae).getMapping().findForward(Zoom); } KISS, the code does not need UML or even comments or design. Keep it simple, complex != good or fast This code is also more portable to another MVC framework, ex. JSF (one reason is that controlers is an interface, in this exmple at the tile level, so each tile has it's own events) Note use of event object, and auto dispatching of events. This gets consumed by the JSTL tags. Also the bean, which you can't see here calls DAO .retrieve() in its findX (). (code from the Struts basicPortal on sf.net) .V (Struts mentor http://www.mail-archive.com/mvc-programmers%40basebeans.com/msg00242.html ) Eddie Bush wrote: - Declare your form to be of type DynaActionForm in struts-config - Declare your properties to be of whatever type they need to be - Preface the page call with an action which will cast the form argument to be a DynaActionForm - call form.set(property, value) as needed - forward to the page that will use the form Chapter 5 pg 20 of Chuck's book covers this quite well. (That may not be exact, but it's close) I'm not going to claim it's the official way - but it's often done this way, for sure. Follow Chuck's example. Remember that (unless you have extenuating circumstances - most of the time pre-population does not qualify) you should never have to create a form yourself. Expect it to be there. If it's not, double-check your config to ensure you told Struts to make sure it was there. If you have done that and it didn't let it NPE and then file a bug report. Vincent Stoessel wrote: How do you use the DyanActionForm in the action classes. I saw 2 different examples in the archive, neither of which worked for me. DynaActionFormClass dafc = DynaActionFormClass.getDynaActionFormClass(AddUserForm); DynaActionForm myForm = dafc.newInstance(); gives me this compile error: AddUserAction.java [48:1] incompatible types found : org.apache.commons.beanutils.DynaBean required: org.apache.struts.action.DynaActionForm line 48 : DynaActionForm myForm = dafc.newInstance(); What is the official way? Thanks. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: okay, one more time for the slow people...
It seems to me that this code is already *relying* on another framework in order to be more portable to another MVC framework. ActionEvent, TilesEvent, TaskBean, BUtil, etc. are not Struts classes. Pulling in another framework just to be able to use DynaActionForm seems like the antithesis of KISS for the particular question posed... -- Martin Cooper -Original Message- From: V. Cekvenich [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 5:17 PM To: [EMAIL PROTECTED] Subject: Re: okay, one more time for the slow people... The other way is: public Object onDisplayZoomExec(ActionEvent ae) throws Exception { String id = ae.getReq().getParameter(ID); // the PK is? long ia = BUtil.longString(id); TasksBean frm = (TasksBean) ((TilesEvent)ae).getFormBean(); setBBean( frm ); getBBean().findSingle(ia); // hard code for now ae.getReq().setAttribute(FORMBEAN, getBBean()); return ((TilesEvent)ae).getMapping().findForward(Zoom); } KISS, the code does not need UML or even comments or design. Keep it simple, complex != good or fast This code is also more portable to another MVC framework, ex. JSF (one reason is that controlers is an interface, in this exmple at the tile level, so each tile has it's own events) Note use of event object, and auto dispatching of events. This gets consumed by the JSTL tags. Also the bean, which you can't see here calls DAO .retrieve() in its findX (). (code from the Struts basicPortal on sf.net) .V (Struts mentor http://www.mail-archive.com/mvc-programmers%40basebeans.com/ms g00242.html ) Eddie Bush wrote: - Declare your form to be of type DynaActionForm in struts-config - Declare your properties to be of whatever type they need to be - Preface the page call with an action which will cast the form argument to be a DynaActionForm - call form.set(property, value) as needed - forward to the page that will use the form Chapter 5 pg 20 of Chuck's book covers this quite well. (That may not be exact, but it's close) I'm not going to claim it's the official way - but it's often done this way, for sure. Follow Chuck's example. Remember that (unless you have extenuating circumstances - most of the time pre-population does not qualify) you should never have to create a form yourself. Expect it to be there. If it's not, double-check your config to ensure you told Struts to make sure it was there. If you have done that and it didn't let it NPE and then file a bug report. Vincent Stoessel wrote: How do you use the DyanActionForm in the action classes. I saw 2 different examples in the archive, neither of which worked for me. DynaActionFormClass dafc = DynaActionFormClass.getDynaActionFormClass(AddUserForm); DynaActionForm myForm = dafc.newInstance(); gives me this compile error: AddUserAction.java [48:1] incompatible types found : org.apache.commons.beanutils.DynaBean required: org.apache.struts.action.DynaActionForm line 48 : DynaActionForm myForm = dafc.newInstance(); What is the official way? Thanks. -- 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]