Re: FOP and strus (IE problem)
John Ng [EMAIL PROTECTED] wrote: Hi, The following is a piece of the code that I write in the perform method of an ActionForm to generate the PDF. However, it works fine in netscape, but NOT IE. Can someone help me with this? Thanks! John Try adding ?.pdf to the url. -- gR -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: comments
No! JSP Comments are not !-- -- but %-- --% -- gR - Original Message - From: Maris Orbidans [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Thursday, November 22, 2001 7:14 PM Subject: RE: comments Yes JSP have the same comment Maris -Original Message- From: Henrick Chua [mailto:[EMAIL PROTECTED]] Sent: Thursday, November 22, 2001 8:12 PM To: Struts Users Mailing List (E-mail) Subject: comments hi all! how can I comment out struts code? do i do it like any other html comments? !-- bean:write property=abc name=def / -- thanx h -- 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: comments
Sobkowski, Andrej [EMAIL PROTECTED] wrote: Careful: !-- jsptag / -- The JSP tag will be evaluated (though not shown on the browser since the results will be commented out. And yes, they'll be visible by the client. %-- jsptag / --% The JSP is not evaluated and the commented part will not be sent to the resulting HTML page At least I think.. :) Andrej !-- jsptag / -- will be sent to the client. Whether it will be visible depends on what are you sending to the client. If plain text, then it will be visible. If HTML, it will become a HTML comment. Unless your jsptag / generates something like this --Hi!!-- ;-) -- gR -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: redirection
Andrew Kirkland [EMAIL PROTECTED] wrote: Whenever I write a struts application and try to do anything involving an action mapping, my browser is simply redirected to the corresponding *.do file! Can someone tell me whats wrong? Im using tomcat 3.3. What is a *.do file? -- gR -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: redirection
Andrew Kirkland [EMAIL PROTECTED] wrote: I have this in my jsp : html:form action=lesson1/logon.do focus=user and then web.xml redirects it and it should then be processed by my java file etc. However I am simply redirected in my browser to logon.do which doesnt exist! Andy OK, so there actually is NO file logon.do (which is correct). I suppose the problem might be that in html:form the attribute action should contain only the name of the action and not the name of the mapping. So try action=lesson1/logon instead on lesson1/logon.do -- gR -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Feedback on Struts Pros and Cons
David Bueche [EMAIL PROTECTED] wrote: Struts Disadvantages: 1. Instead of direct dispatching by controller Servlet(s), dispatching is defined in an XML file, adding a layer of indirection overhead to the architecture. Do you really think, this is an disadvantage? 2. Requires behavior typically factored for commonality in controller Servlet methods to be duplicated in every Action subclass (some common behavior could possibly be delegated to additional classes or components and accessed by each Action subclass). There is still the possibility to subclass ActionServlet and so create own controller. 3. Struts internationalization is limited to static strings and does not include internationalization of data returned by a business component. A bit can be achieved with the placeholders in constant strings. 4. Struts internationalization requires an ApplicationResources.properties file, which conflicts with the current Enterprise Java Application Standard of definely properties directly in the web.xml file. Struts does not use ApplicationResources.properties as real properties. The file is used only as a handy tool for peristing string maps. In our projects we use database backed internationalization with struts. 5. Presentation of message collections is predefined in tag libraries (although these could be modified for more specialized presentation). 6. Requires understanding of custom tags and tag libraries, as well as their deployment. While this may not be a problem for more advanced developers, this will add another layer of complexity for less experienced development and support teams and requiring more intensive EAS involvement. 7. Delegating much of the presentation layer to custom tags can make the final HTML/presentation less clear than HTML placed directly in the JSPs/Servlets. 8. Delegating much of the presentation layer to custom tags can become a performance problem. -- gR -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Q about A tags with Struts!
O'Neill, John H JohnH.O'[EMAIL PROTECTED] asks: Hi all, hope someone can help me with this! I want to send a request to an action using the following code A href= /LaunchPad2Action.doBFiscal Analytic/B/A The problem is that I want to send up parameters aswell as you would do normally like : A href=/LaunchPad2Action?fundId=7legalName=canada_fund etc... Could someone point out the best way to do this with Struts - is there a tag to do this? Have a look at the html:link tag. -- gR
Re: Struts in Europe?
Bernhard J. Hirschmann [EMAIL PROTECTED] DaimlerChrysler does use it. You may search in the mail-archive about that thread, because this one has been discussed earlier as well. Regards, Bernhard We at Internet Technology use it too. Gregor Rayman www.i-technology.de
Re: Adding Xml Tag in Struts-Config.xml file
Is it a problem, if you hard code it into a final static memmber of a class? -- gR - Original Message - From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, October 04, 2001 3:55 PM Subject: RE: Adding Xml Tag in Struts-Config.xml file I have an application-config.xml. But how my application could know the name of the file without using a constants file ? -Message d'origine- De: Gregor Rayman [mailto:[EMAIL PROTECTED]] Date: jeudi 4 octobre 2001 15:41 À: [EMAIL PROTECTED] Objet: Re: Adding Xml Tag in Struts-Config.xml file [EMAIL PROTECTED] wrote: I need to configure my application by Xml. Is it possible to add personnal XmlTags in the Struts-Config.xml file and manipulate them in a Action class with the Digester ? Thxs. Bruno Why in strus-config.xml, why don't you create your own application-config.xml? -- gR
Re: dynamic forwards
lisa ward [EMAIL PROTECTED] Hi again, The values in your hash map have been hardcoded in, which works fine. But what do I if I do not know what the user's selection will be in advance. Take for instance, if I have a set of checkboxes on my page, I would like to be able to initialize the map with the values that the user has selected. Or am I just missing the point here? Hold on. You have to have all necessary information, when you are generating the link. It does not matter, whether the keys in the map are hardcoded or determined during the runtime. Important is that you are creating the link on the server side, before the user clicks on any checkboxes. If you want to use user's input, you can do it when serving the next page. You can then generate the map in an Action and generate the link for the next displayed page (so you will know all paramaters in advance, since the checkboxes have been submitted already) Or your Action can use the checkboxes to determine what to do or to determine where to forward to. You don't need to use constant strings in findForward. Another possibility would be using JavaScript on the client, but since many browsers have JavaScript disabled, you should not rely on it. -- gR Please explain further and thank you very much for your patience. Thanks Lisa From: Gregor Rayman [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED] To: [EMAIL PROTECTED] CC: lisa ward [EMAIL PROTECTED] Subject: Re: dynamic forwards Date: Wed, 26 Sep 2001 20:55:34 +0200 lisa ward [EMAIL PROTECTED] wrote: Another quick question. How would I be able to initialize the hashMap. the problem Im facing is that when I use a forward the submit is not called so the values are not initialized in my bean. Here an quick and dirty example. (Dirty beacuse it uses scriplte. Custom tag would be somehow more apprpriate.) % HashMap linkParams = new HashMap(); // create the map linkParams.put(areaId, a); // set the values linkParams.put(aspectId, b); pageContext.setAttribute(linkParams, linkParams); // make the map an attribute of page % html:link page=/deleteaspect.do name=linkParams bean:message key=button.delete/ /html:link The generated URL will be: .../deleteaspect.do?areaId=aaspectId=b The map does not have to be the attribute itself. It can be a property of an attribute. Then the html:link tag would look like this: html:link page=/deleteaspect.do name=linkAttribute property=propertyName -- gR _ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
Re: dynamic forwards
lisa ward [EMAIL PROTECTED] wrote: In your message you said: so you will know all paramaters in advance, since the checkboxes have been submitted already. But since Im using a html:link (forward) instead of a submit, at which point do I initialize the selected checkbox values in my hash map. You cannot. What are you talking about is dynamics which happens in the browser. There you can use JavaScript to create dynamic link. When you want to use standard HTML form way to send parameters to the server, you have to do it with submit. You can use a href=javascript:forms[0].submit(); to make link, which submits. (I am not sure, whether the syntax above is ok) -- gR
Re: dynamic forwards
Martin, Margaret [EMAIL PROTECTED] wrote: I have tried it. It works. (at least the CVS version) -- gR Lisa, I haven't tried it myself, but according to the doc for the html:link tag, you can specify a bean that returns a map which specifies all of the parameters... the contents of that bean clearly could change between invocations, thus giving you dynamic parameters... Hope this helps - Margaret -Original Message- From: lisa ward [mailto:[EMAIL PROTECTED]] Sent: Wednesday, September 26, 2001 12:52 PM To: [EMAIL PROTECTED] Subject: dynamic forwards Hi all, I am having the exact same problem as Chiji, so I have just copied and pasted a bulk of his email (Sorry Chiji) . Im literally pulling my hair out over this one. Chiji, if you have solved the problem let me know or point me in the right direction. Thanks Chiji's email reads: -- start of Chiji's email-- Hi, Im in a bit of dilema, I don't understand is what I should do if the parameters which are used by the html:link (forward) tag are generated on the fly. I can't hard code all the forwards in my config file because I don't know how may parameters there will be in advance. Since I don't know the amount parameters in advance I can't specify which form bean each of the actions with, appended parameter values, should use. This is what my problem looks like: in config file: forward name=search path=/do/search / action path=/search name=searchForm input=/seach.jsp scope=request / in jsp file: logic:iterate id=pageNumber name=pageList offset=0 html:link forward=search paramName=pageNumber paramId=pageNumber bean:write name=pageNumber / /html:link /logic:iterate html:hidden property=pageNumber / when I use: html:link forward=search it works fine and think this is because of the mapping in the config file. I would want the forward to 'search' (/do/search) as well as the forward to 'search' and it parameters (/do/search?pageNumber=1) to use the same form bean. I hope this makes sense. -- end of Chiji's email-- Thanks Lisa _ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
Re: dynamic forwards
lisa ward [EMAIL PROTECTED] wrote: Another quick question. How would I be able to initialize the hashMap. the problem Im facing is that when I use a forward the submit is not called so the values are not initialized in my bean. Here an quick and dirty example. (Dirty beacuse it uses scriplte. Custom tag would be somehow more apprpriate.) % HashMap linkParams = new HashMap(); // create the map linkParams.put(areaId, a); // set the values linkParams.put(aspectId, b); pageContext.setAttribute(linkParams, linkParams); // make the map an attribute of page % html:link page=/deleteaspect.do name=linkParams bean:message key=button.delete/ /html:link The generated URL will be: .../deleteaspect.do?areaId=aaspectId=b The map does not have to be the attribute itself. It can be a property of an attribute. Then the html:link tag would look like this: html:link page=/deleteaspect.do name=linkAttribute property=propertyName -- gR
Re: how to capture html
Brian K. Buckley [EMAIL PROTECTED] wrote: Is there a good way to capture the output from a snippet of jsp into a String variable that can be reused multiple times in a page? - Brian As a simple example, if one needed to have the line: trth align='left' Name/thtd align='right' html:text property='name'//td/tr appear in several places, how can one set a String namerow so that the line can be redisplayed by saying %=namerow% instead of repeating the whole snippet? Note that the snippet includes a custom tag. Not really. The only way I know, is to enclose the snippet into a method with a variable called out. HTML in JSP will be translated into out.print(); -- gR
Re: Struts JBoss / Tomcat and From
Title: Struts JBoss / Tomcat and From Why do you use ActionForm as value object in EJB? I thnik, this is not a clean design, since you make your EJB code dependent on Struts. Struts beloongs to the web layer, EJB to the businness layer. Your EJB do not need things like HttpRequest, so'd try to make them independet from the servlet.* package. I'd suggest a simple redesign. Use simple beans as value object and nest them in your action forms. Struts supports nested properties, so will not need to create delegating propertry setters and getters in your action form. (unless you want to do some conversions - ActionForms' properties should be string based, value objects should use the "real" type of the property) -- gR P.S.: Of course it would be nice, if struts.jar could be installed in server scope instead of application scope. I suppose, it would need some changes in the class loading in ActionServlet. - Original Message - From: Nortje, Andrew To: '[EMAIL PROTECTED]' Sent: Thursday, September 20, 2001 10:50 PM Subject: Struts JBoss / Tomcat and From I have deployed my app using JBoss/Tomcat. I recently started using the ActionForm as value objects in my EJB's. JBoss now needs struts.jar in the class path, so it can find ActionForm, so I put sturts.jar in JBOSS_HOME/lib/ext. This works fine put it kills struts. Struts now throws a ClassNotFoundException for my ActionForm's. If I remove the stuts.jar from the JBoss class path JBoss dies and struts works again. Anyone got some advice for me here? Thanks in advance. Andrew This is the exception that get thrown by Tomcat Error: 500 Location: /jazzman/contact/details/address.jsp Internal Servlet Error: javax.servlet.ServletException: Exception creating bean of class com.jazzman.contact.details.view.AddressValue: java.lang.ClassNotFoundException: com.jazzman.contact.details.view.AddressValue at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:459) at contact.details._0002fcontact_0002fdetails_0002faddress_0002ejspaddress_jsp_0._jspService(_0002fcontact_0002fdetails_0002faddress_0002ejspaddress_jsp_0.java:409) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.jasper.servlet.JspServlet$JspCountedServlet.service(JspServlet.java:130) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:282) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:429) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:500) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405) at org.apache.tomcat.core.Handler.service(Handler.java:287) at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372) at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797) at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743) at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:213) at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416) at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501) at java.lang.Thread.run(Unknown Source) Root cause: javax.servlet.jsp.JspException: Exception creating bean of class com.jazzman.contact.details.view.AddressValue: java.lang.ClassNotFoundException: com.jazzman.contact.details.view.AddressValue at org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:527) at contact.details._0002fcontact_0002fdetails_0002faddress_0002ejspaddress_jsp_0._jspService(_0002fcontact_0002fdetails_0002faddress_0002ejspaddress_jsp_0.java:95) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.jasper.servlet.JspServlet$JspCountedServlet.service(JspServlet.java:130) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:282) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:429) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:500) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405) at org.apache.tomcat.core.Handler.service(Handler.java:287) at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372) at
Re: How to test only for the language-code but not for the country?
Title: How to test only for the language-code but not for the country? Use bean:message for this purpose. Not logic:equal. - Original Message - From: Friedli Beat [UFA AG Her] To: '[EMAIL PROTECTED]' Sent: Wednesday, September 12, 2001 11:22 AM Subject: How to test only for the language-code but not for the country? I want to test the Accept-Language and show a french message if the user speaks french. But the following code doesn't take care of the Accept-Language fr-ch. logic:equal value="fr" header="Accept-Language" Welcome french /logic:equal And this code doesn't take care of the Accept-Language fr-ch. logic:equal value="fr-ch" header="Accept-Language" Welcome french /logic:equal Do I have to write my own tag? Has anybody allready an apropriate tag? thanks Beat Friedli
Re: POST and session-timeout (Extra Information)
[EMAIL PROTECTED] wrote: Hi All, I have a secured area in with FORM authentication, when I -POST- a Form after the session has timed out and re-login, the information on the Form isn\'t submitted anymore. The parameters are lost. Is there a possibility to have the parameters still in the request? Getting the form isn\'t an option because there is too much information in the request. It also isn\'t possible to post an multipart form. Greetings Ralph Forgot to mention: I use Tomcat 3.2.1 and Jboss 2.2.1 This is more a question for Tomcat, but you are right, the POST data are not stored in Tomcat during the form based login. As far as I know, only the URL is stored (but better have a look into the sources). It is a limitation, but it also protects your server. The submitted data have to be stored in a session and POSTed data can be huge. Storing them could overload your server, even from people, who were not yet authentified. -- gR
Re: Personalisation Best Practice
Peter Pilgrim [EMAIL PROTECTED] How do I get a *.css file recognised as valid Java Server Page? -- Peter Pilgrim | |++44 (0)207-545-9923 \ \ ___ / / ... . - ( * ) --- -- _Cafe_Savannah,_San Antonio,Ibiza__ You do not need that. You can do something like this: in your html.jsp: LINK REL=stylesheet TYPE=text/css HREF='%= response.encodeURL(stylesheet.jsp) %' and stylesheet.jsp would produce the generated stylesheet, something like this: stylesheet.jsp: % response.setContentType(text/css); % h1 { % if (likeItRed) { % color: red; % } else { % color: blue; % } % } (better use the logic:* tags) -- gR
Re: re-Logon after session timeout
Ralph vd Houdt [EMAIL PROTECTED] wrote: Hi Jon, This is not just what I want. I want to do a login based on 3 fields company/user/password and evaluate then to an EJB. The login should put an object in the session. Greetings Ralph You can do this with form based login as well. Your form would not have the action j_security_check, it would point to another action which would map the three field to the two (user/password) and forward to j_security_check. -- gR
Re: re-Logon after session timeout
Ralph vd Houdt [EMAIL PROTECTED] wrote: Hi Gregor, This sound OK, Can you point me to documentation on this or give me additional information? It is quite simple. The normal login.jsp looks like this: form method=POST action=j_security_check Username: input type=text name=j_usernamebr Password: input type=password name=j_passwordbr br input type=submit value=login name=j_security_check /form You would use something like this (for simplicity here pure JSP, it can be done with Struts as well: form action='%= respose.encodeUrl(/checklogin.jsp) %' User: input name=userbr Company: input name=companybr Password: input name=password type=password /form And checklogin.jsp would do something like this: % String j_username = request.getParameter(company) + / + request.getParameter(user); String j_password = request.getParameter(password); % jsp:forward page='%= j_security_check?j_username= + URLEncoder.encode(j_username) + j_password= + URLEncoder.encode(j_password) %' / Of course, the mapping logic from company+user to web-user can be more complex than simple concatenation with a / as separator. Actually, I've never used it for such mapping. I've used it for auto-login directly in the first login.jsp. It checks to see, whether the user can be identified by a cookie and tries to retrieve the username/password from a database. Then, instead of displaying the login form, it directly forwards to j_security_check. groetjes -- gR - Original Message - From: Gregor Rayman [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, September 06, 2001 4:43 PM Subject: Re: re-Logon after session timeout Ralph vd Houdt [EMAIL PROTECTED] wrote: Hi Jon, This is not just what I want. I want to do a login based on 3 fields company/user/password and evaluate then to an EJB. The login should put an object in the session. Greetings Ralph You can do this with form based login as well. Your form would not have the action j_security_check, it would point to another action which would map the three field to the two (user/password) and forward to j_security_check. -- gR
Re: CachedRowSet or SQL, what is the best way?
Ryan Cornia [EMAIL PROTECTED] asks: Is anyone using the early access of CachedRowSet for data access, or are people just using straight JDBC calls? I've been using straight JDBC calls, but it looks like CachedRowSet would be easier. Anyone know when it will be officially released? Is it currently stable? I use cached RowSets beacuse they hide the connections, SQL and the whole persistence stuff from the JSP which uses them. I only had problems with some Oracle specialities (nested ResultSets will not be serialized by the EarlyAccess version). Other option would be to use the Rowset which opens a life connection to the datasource. The Action would set up its properties and the RowSet would fetsch the data when needed in the JSP. The JSP has then to be responsible for closing teh RowSet (I always call rs.close() in the JSP, even though for the cached ones it is not necessary and it means I have to have scriplet in my JSP) I'd prefer the second option if the caching becomes too heavy burden for the memory. (Like a JSP which returns a table with one million rows) -- gR
Re: Including Actions via jsp:include
hi Guys, I bet this has come up before... I need to include the output of an action in a jsp, using the jsp:include tag lie this: jsp:include page=/myAction.do flush=true jsp:param name=USERID value=CARLOSUS / /jsp:include but I get an illegalstate exception, as the ActionServlet forwards instead of includes... is there anyway to do this??? thanks I've found one workaround which can help in some situations: make the Action.perform return null. include the view (JSP) then. So it could look like this: jsp:include page=/myAction.do flush=true jsp:param name=USERID value=CARLOSUS / /jsp:include jsp:include page=/myAction.jsp flush=true / But it is ugly indeed. -- gR
Re: Including Actions via jsp:include
:-) The question is not, whether it works on different servers, the question is, whether the original including of forwarding Action works on some servers. If the Action.perform returns null, then there is no forward and no reason for such an exception. The real problem with this solution is that it breaks the MVC pattern. In order to make it work, your VIEW (your JSP) which includes the action, decides how to display the action's results. It does so by incluing the second *.jsp. But this decision should be made by the action itself in cooperation with the ActionServlet. (The action decides what is the logical result e.g. success and the action servlet maps it to the physical *.jsp or whatever is defined in struts-config.xml) -- gR - Original Message - From: Mikkel Bruun [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, September 03, 2001 12:19 PM Subject: SV: Including Actions via jsp:include whoa! thanks alot... does this hack work on all servers??? I have just tested it on tomcat 3.2, will try on Iplanet later... :: Mikkel Bruun Senior IT Developer [EMAIL PROTECTED] Direct: +45 32 88 22 73 Valtech A/S Kanonbaadsvej 10 DK-1437 Copenhagen Tel +45 32 88 20 00 Fax +45 32 88 20 20 -Oprindelig meddelelse- Fra: Gregor Rayman [mailto:[EMAIL PROTECTED]] Sendt: 03 September 2001 11:50 Til: [EMAIL PROTECTED] Emne: Re: Including Actions via jsp:include hi Guys, I bet this has come up before... I need to include the output of an action in a jsp, using the jsp:include tag lie this: jsp:include page=/myAction.do flush=true jsp:param name=USERID value=CARLOSUS / /jsp:include but I get an illegalstate exception, as the ActionServlet forwards instead of includes... is there anyway to do this??? thanks I've found one workaround which can help in some situations: make the Action.perform return null. include the view (JSP) then. So it could look like this: jsp:include page=/myAction.do flush=true jsp:param name=USERID value=CARLOSUS / /jsp:include jsp:include page=/myAction.jsp flush=true / But it is ugly indeed. -- gR
Re: Class PropertyUtils is deprecated
Title: SV: Including Actions via jsp:include The class has been repackaged. It is now under the apache commons. -- gR - Original Message - From: Inés Pederiva To: [EMAIL PROTECTED] Sent: Monday, September 03, 2001 2:06 PM Subject: Class PropertyUtils is deprecated Class PropertyUtils is deprecated... what should I use instead of this class?? What sould I use instead of the deprecated method: copyProperties(java.lang.Objectdest, java.lang.Objectorig) ?? Regards.
How to include an .do from a jsp
Hi all, some time ago I've written about my problem including *.do in jsps. E.g. in the template tags. The problem is caused be the way, how Action/ActionServlet controls the invocation of its view. The request is either forwarded or redirected to the view and neither forwarding nor redirecting work, when the action is included. My workaround is, to let the Action's perform() method to return null and then in my composite view include the sub-view. So something like: jsp:include page=thing.do / jsp:inlcude page=thing-success.jsp / This definitely breaks the MVC pattern, since the composite view controls the view of the sub-action. My proposal: Now I can specify in struts-config.xml that a forward should be redirected with redirect=true. What about allowing include as well? Even better would be, it ActionServlet recognised, the action is beeing included and it would include the view instead of forwarding/redirecting to it. I'll try to have a look at it in September and submit a patch. -- gR
Re: Re: template tags
[EMAIL PROTECTED] wrote: You can put the list in an request scoped bean with defined name. The template can then access it, e.g. with ligic:iterate That's what I'm doing at the moment with the old jsp:setProperty and jsp:include tags. I guess what I'm asking is can I do this cleaner somehow with the template tags? Devon You mean something like this? logic:iterate id=x template:get name=%= x % / /logic:iterate I am not sure, whether this is possible in the soon-to-be-deprecated template tags or in the tiles tags, but the idea is good. -- gR
Re: Managing struts-config.xml
O'Reilly John [EMAIL PROTECTED] Is there any way of splitting up struts-config.xml, possibly by being able to include xml fragements into the main file. We are working on a project involving approx. 12 developers. We are using cvs for source control. What we are finding is that we are getting frequent conficts when trying to merge changes that different members of the team are making. Thanks in advance, John John O'Reilly Traventec I see two possibilities: 1) Define some means, how struts-config.xml will be compiled from various files during deployment. or 2) Split struts-config.xml into external entities within the doc-type. I admit, I've not tried to do it :-( -- gR
Re: STRUTS and EJB
Juha Paananen [EMAIL PROTECTED] wrote: I want to fill in a form JavaBean using a struts form, and after validating it in my Action class, store it into the db using a session EJB component. The proble here is that I have to extend ActionForm class to make the bean work with Struts. You can use containment instead of inheritance. You should avoid using Struts ActionForm on the business logic level. -- gR
Re: Dates and Struts
Matt Raible [EMAIL PROTECTED] wrote: Is it true that Struts cannot handle a java.sql.Date or java.util.Date datatype? I seem to get errors everytime I try to have one in my form. Thanks, Matt No it cannot. Date is not so easy to parse since it is locale dependent. Also the displaying a date is not easy. This brings me to one general architecture question: Where do you (I mean all struts users) put the formatting/parsing´of values? For display only data, I try to put it into the JSP (with custom tags). But what about the editable data? Is the ActionForm the right place? I store the data in non-string form (like Date) and the get/set methods operate with strings. The language dependent formats use an addiotional property locale which I set either in the reset() method (from request and session). It could be done simpler, I used only string aware ActionForms and the whole formatting were done in Action.perform, but this wouldn't be conform with the MVC pattern, woul'd it? -- gR
Re: Population of form in case of errors
Ralph vd Houdt [EMAIL PROTECTED] wrote: Hi All, I have a form wich get default values from a bean. with the name and property tags of the html:text tag. When the form has errors using the validate(ActionMapping mapping,HttpServletRequest request) method the field don't get repopulated with the text I it changed to. But it gets the calues from the bean again. Is there a workaround? If it is a request scoped form, then the form bean you use to display values in JSP differs from the one which is populated from the request. Each request gets its own fresh and empty form bean and this bean is then populated from the request. No action is activated to pre-populate the form. One possible sulution for this problem would be to insert a html:hidden for each bean:write. This assures, the form properties to be filled. Groetjes -- gR
Re: How to keep ActionForm in session from being reset?
Wilhelm Fitzpatrick [EMAIL PROTECTED] wrote: It seems to me that struts *shouldn't* reset form beans that are stored with session scope. Or am I misunderstanding something? -wilhelm No, the reset has to be done, otherwise the checkboxes would not work. -- gR
Re: form validation
Mike Dewhirst [EMAIL PROTECTED] How is it possible to validate input in struts for formatting? What I mean is, is it possible to check when a string is entered into an input field that populates an int? It seems that the Controller populates the int with a 0, which makes it difficult to detect if this was an invalid input, or a real 0. Would we need to extend the framework if we want to be able to detect this? Thanks for any advice!! You can either use String (in this way you can accept inputs like 2.001), or you can use Integer. It will be null, if no correct integer is has been entered. -- gR
Re: Internationalization of codetables.
"Juraj Kazda" [EMAIL PROTECTED] wrote: Because code tables are almost (or long-time lasting) static data, I was thinking about putting a Vector of beans with attributes corresponding/matching the structure of code table. That means to make one start-up servlet which will fill all the Vectors of code tables and puts them in application scope context when the application starts. But there is a problem: how to access connection pool defined by struts-config.xml to obtain connection to database? Or dou you know how to solve the whole problem better? You can either use JNDI connection pool. Or you can read the data in an action and cache them then. I'd use the double checked singleton pattern: Thing getThing() { if (null == this.thing) { synchronized(this) { if (null == this.thing) { // read the thing form the database } } } return thing; }
Re: How do you format a date using struts/iterate?
Bob Byron [EMAIL PROTECTED] wrote: In your example below, the variable orders does not contain the iterator, but the single element of the iterator. You can use the attribute type of html:iterate to set the concrete class type to the variable orders. Any you should perhaps use the singular order for it. -- gR Any takers? Still looking for the answer to this one. I need to format a date. I have an array of beans I am iterating through, and the bean's method getDeliveryDate() returns a Date. Basically, how do I get the current object according to the iterator? If I had that object, I could perform the following formatting myself. DateFormat.getDateInstance(DateFormat.SHORT).format(orders [interator].getDeliveryDate()); Thank You, Bob Byron --- Bob Byron [EMAIL PROTECTED] wrote: How do you format a date using struts? I have a list of orders that I am logic:iterate'ing through. At one point I write out a date, but it is not in the format I want. I am using the following code: logic:iterate id=orders name=myOrders bean:write name=orders property=deliveryDate/ /logic:iterate How do I reformat the deliveryDate? I want to use something similar to the following, but I am not sure how to implement it in struts. %= DateFormat.getDateInstance(DateFormat.SHORT).format(orders[interator].getDeliv eryDate()); % Thank You, Bob Byron __ Do You Yahoo!? Make international calls for as low as $.04/minute with Yahoo! Messenger http://phonecard.yahoo.com/ __ Do You Yahoo!? Make international calls for as low as $.04/minute with Yahoo! Messenger http://phonecard.yahoo.com/
Re: How to get a locale object in the constructor of a ActionForm class?
Hartmut Bernecker [EMAIL PROTECTED] wrote: Hi, how can I get a locale object in the construtcor of a ActionForm class? In a login-form I want to set a selectbox containing language descriptions to the right value (de or en or fr etc). I think the best way to do that would be an initialisation with the current locale in the constructor of the ActionForm bean: public LoginForm() { setLanguage(de); } BTW: The locale is set by html:html locale=true in the JSP page. I don't think it shoudl be done in the constructor. if you really want to do it in an ActionForm and not Action, you should think about the method reset which gets the request as parameter. -- gR
Re: Getting locale attribute from session.
"Juraj Kazda" [EMAIL PROTECTED] wrote: Hello, I'm new user of struts framework and I have a problem. I would like to make an internationalized application with _everything_ internationalized. This means that I have a nice graphics (menu too) on my pages in several language versions. I would like to obtain a LOCALE key (object) from session (inserted there by html:html locale="true" tag). And here is the problem: to be perfect, I would like to get this key by the name which is stored in org.apache.struts.action.Action.LOCALE_KEY constant. How to access the key? The key is just a constant, have a look in the sources. But I do not think this is the right way to do it. You could use bean:message inside the href attributes of the images instead. If you want to hse the tag html:img, which I'd reccomend to you, have a look at the attributes pageKey or srcKey, they use message resources. In this way you can create message resources files with names of the pictures in different languages: html:img pageKey="picture.save" / and in the files specify the names of those pictures: ApplicationResources_en.properties: picture.save=/images/save.gif ApplicationResources_de.properties: picture.save=/images/speichern.gif ApplicationResources_sk.properties: picture.save=/images/ulozit.gif ... I've made my entering (index.jsp) file as a template file and I check the locale via logic:present and logic:match tags. But inside these tags I have to use directly the org.apache.struts.action.LOCALE keyword - it's not possible to ask for key name (by asking I mean getting the value of org.apache.struts.action.Action.LOCALE_KEY). Or is it possible? If someone knows, please help me. Here a scriplet, how to get the locale if you need it for something, where you cannot use taglibs (like getting Format etc.) % Locale locale = (Locale) pageContext.getAttribute(Action.LOCALE_KEY, PageContext.SESSION_SCOPE); if (null == locale) { locale = request.getLocale(); } DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT, locale); % -- gR
Re: ActionForm not being updated. Please advice.
Alex Colic [EMAIL PROTECTED] wrote: I am interating through a vector a displaying the results. I have one field that I want the user to update hence I have made it a text box. When the page displays, the data is correct but when the user enters something into the text box and hits submit, the form in the actionservlet has the old data not what the user has entered. This is because the generated HTML does not contain the index. Try the indexed attribute of html:text (it is not in the release version 1.0) Or try this: html:text property='%= attribute[ + i + ].value %' / Note: your ActionForm has to be able to handle setAttribute(i, ...) even when the underlaying vector is empty. -- gR
Re: ActionForm.reset() method
Mike Dewhirst [EMAIL PROTECTED] is automatically called when? When the form is first created by the Controller? No, it is called always before the controller populates it from the request. -- gR
Re: wrong behavior of checkboxes in forms?
Hartmut Bernecker [EMAIL PROTECTED] wrote: Hello, I have a checkbox in a form. If I check it and then submit the form, then I receive the value true in the action when calling the method form.getMyCheckbox(); But if I uncheck the checkbox and submit the form again, then I receive **again** the value true in the action when calling the method form.getMyCheckbox(); Who can help??? Hartmut Hi, there are two possible solutions: 1) use request scope forms 2) implement the reset() method. (Which you should do anyway always, when you use checkboxes) -- gR
Re: LDAP Authentication To Active Directory
I am. - Original Message - From: SUPRIYA MISRA [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, August 13, 2001 1:39 PM Subject: LDAP Authentication To Active Directory I have successfully implemented LDAP authentication to Microsoft Active Directory at Wayne State University school of Medicine. If anyone is interested in having LDAP Authentication To Microsoft Active Directory , please email me. Supriya Misra System Integrator II MSIS,WSUSOM Detroit, MI _ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
Re: Get request and the Action servlet
[EMAIL PROTECTED] wrote: I would like to use Struts with an action that is initiated by following a link, rather the form-based approach that I can see in the documentation. I would also like the ActionServlet to parse the URI and instantiate my bean with the information from the URI. Is this possible? Sorry if this is a FAQ - I've had a trawl thru the docs, honest. Cheers, Roger A link is for the server the same thing as a form with GET method. It works with struts without problems. (Of course, you cannot submit as much data as with POST. But this is a limitation of HTTP) -- gR
Re: infinite loop
What does forward name="success" path="/adduser.cm"/ mean? Shouldn't it be path="/adduser.jsp" ? -- gR - Original Message - From: Rama Krishna To: [EMAIL PROTECTED] Sent: Saturday, August 04, 2001 8:55 PM Subject: infinite loop hi all, In continuation to my post yesterday, The following is my code. The flow is fine till Forwarding to Success and then instead of displaying, it starts again from the begining. If i remove the if condition in validate method then it displays the form with errors which is fine. am i doing something wrong thanks, rama. Mappings: !-- FIP User Profile Page bean -- form-bean name="addUser" type="com.niku.cm.action.AddUser"/ !-- FIP User Profile Page -- action path="/adduser" name="addUser" validate="true" input="/adduser.jsp" type="com.niku.cm.action.AddUserAction"forward name="success" path="/adduser.cm"//action adduser.jsp: html:errors / html:form action="/adduser?action=save" focus="fullname"table width="55%" border="0" cellspacing="1" tr td class="fieldname" width="16%"Full Name*/tdtd class="field" width="16%"html:text styleClass="noborder" property="fullname" //td/tr trtd class="fieldname" width="19%"Phone*/tdtd class="field" width="16%"html:text styleClass="noborder" property="phone"/ /td/tr trtd class="fieldname" width="19%"Email*/tdtd class="field" width="16%"html:text styleClass="noborder" property="email"/ /td/tr /table p align=centerhtml:submit /nbsp;nbsp;html:reset //p/html:form AddUser.java (FormBean) private String action="create";private Stringfullname=null;private Stringphone=null;private Stringemail="";privateStringresult="false"; public String getAction() {return (this.action); } public void setAction(String action) { this.action = action; } public String getFullname() {return (this.fullname); } public void setFullname(String _fullname) {this.fullname = _fullname;} public String getPhone() {return (this.phone);} public void setPhone(String _phone) {this.phone=_phone;} public String getEmail() {return (this.email);} public void setEmail(String _email) {this.email=_email;} public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { if((action.equals("create")) ||(action.equals("get"))) return null; ActionErrors errors = new ActionErrors(); if ((fullname == null) || (fullname.length() 1)) errors.add("fullname", new ActionError("error.fullname.required")); if ((phone == null) || (phone.length() 1)) errors.add("phone", new ActionError("error.phone.required")); if ((email == null) || (email.length() 1)) errors.add("email", new ActionError("error.email.required")); return errors; }AddUserAction.java (action class) public final class AddUserAction extends Action { public ActionForward perform(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)throws IOException, ServletException { file://get the application resourcesMessageResources messages= getResources();file://get the sessionHttpSession session= request.getSession();file://get the actionString action = request.getParameter("action");System.out.println("AddUserAction : Action is "+action);file://if action is null set it to defaultif (action == null) action = "create"; if (servlet.getDebug() = 1) servlet.log("AddUserAction: Processing " + action +" action");file://if form is null then create new instanceif (form == null) { if (servlet.getDebug() = 1) servlet.log(" Creating new AddUserForm bean under key "+ mapping.getAttribute()); form = new AddUser(); if ("request".equals(mapping.getScope())) request.setAttribute(mapping.getAttribute(), form); else session.setAttribute(mapping.getAttribute(), form);} AddUser addform= (AddUser) form;if(action.equals("create")) { /* do nothing */} // Forward control to the server page if (servlet.getDebug() = 1) servlet.log(" Forwarding to success");return (mapping.findForward("success")); } }
Re: String as Index
Rey Francois [EMAIL PROTECTED] If you only need the string keyed properties, then don't worry about the mapper, just use the class com.capco.util.PropertyUtils. Fr. I still don't get it. Do I have to change RequestUtils.java and BeanUtils.java? -- gR
Re: String as Index
Hi Fracois, so I've hacked a bit in the beanutils package and now struts does work perfectly with your string based properties. No need to change struts, it is enough to change beanutils. What I dit was: - I've renamed the original BeanUtils class to OriginalPropertyUtils. - I replaced PropertyUtils with your BeanUtils and all delegation to PropertyUtils with the delegation to OriginalPropertyUtils (better approch would be to merge the two calsses. I'll do it later if necessary) - I've changed the StringKeyedPropertyDestrciptor to inherit from PropertyDescriptor - made PropertyUtils getPropertyDescriptor to return it. - changed the method BeanProperties.populate Now I can use string keyed properties in Struts. The source code however is quite messy now. -- gR
String as Index
Hi, as far as I can remember, there was a topic about String as index in property getters/setters here some time ago. I'd like somethigh like this: html:text property=aaa{bbb} / and aaa{bbb} should be converted to getAaa(bbb) and setAaa(bbb, value). Is there something implemented in this direction already? Can I use the results? Can I help? -- gR
Re: String as Index
Oleg V Alexeev [EMAIL PROTECTED] wrote: Now indexed properties can be used only. All properties are processed by utilites from beanutils package at jakarta-commons. It can parse indexed properties only. Named properties is great addition, of course. And of course, you can refactor beanutils package to implement named properties. It will be great help. 8) -- Best regards, Olegmailto:[EMAIL PROTECTED] And Rey Francois [EMAIL PROTECTED] wrote: You can use the PropertyUtils that I have created (reusing the Struts one) within the Mapper framework (http://www.husted.com/about/struts/resources.htm#extensions). It supports string keyed properties, using the notation 'simple.nested.indexed[1].stringKeyed(key)'. See this posting about this topic. http://www.mail-archive.com/struts-user@jakarta.apache.org/msg10858.html Fr. I will evaluate it. It seems, Francois has already implemented exactly what I need. Anyway, if there is something to be done (like bringing this to beanutils) I'd help if there is need. -- gR
Re: String as Index
Rey Francois [EMAIL PROTECTED] wrote: You can use the PropertyUtils that I have created (reusing the Struts one) within the Mapper framework (http://www.husted.com/about/struts/resources.htm#extensions). It supports string keyed properties, using the notation 'simple.nested.indexed[1].stringKeyed(key)'. See this posting about this topic. http://www.mail-archive.com/struts-user@jakarta.apache.org/msg10858.html Fr. Sorry to bother you again, before I have to read the whole documentation to the Mapper, could you please write, what do I have to do, to be able to use this notation in struts? Thanks in advance -- gR
Included Actions
Hi all, is it somehow possible to include the output of an action in one JSP? Now, when I try to include a *.do page, the server complains, it cannot forward to the action's jsp (of course, since I don't want to forward, I want to inlcude). The only solution I've found, is to len the Action's perform method return null and include the action (*.do) as well as the jsp. (Which I really do not like, since then the including page plays the role of the controller) Where should I start if I wanted to change the Action servlet, to include instead of forward? (I include actions' output in my templates. Where one part is the content and another part is the in an action generated menu) -- gR
Re: localization ugliness
[EMAIL PROTECTED] wrote: [...] What I'd like to do is something like: bean:message key=term.type%=bean.getType()%/ Of course, this doesn't work. So what I am actually doing is adding a new method to the bean which duplicates the code in bean:message so that the bean can do the mapping for me. I then display the string with: %= line.getTypeMessage(pageContext) % You can try this: bean:message key = '%= term.type + bean.getType() %' / or, better (does not work with struts 1.0 but with CVS 1.1) bean:message name=yourBean property=typeKey / if your bean is named yourBean and has a property String getTypeKey() { return term.type + getType(); } -- gR
Re: Struts + JBoss
ecn11 [EMAIL PROTECTED] wrote: Ok, I tried this but the result was the same... javax.servlet.jsp.JspException: Exception creating bean of class foo.bar.myclass: java.lang.ClassNotFoundException: foo.bar.myclass at org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:568) I copied the .war-file into the jboss/deploy folder. After that my classes have been copied to jboss/tmp/deploy/Default/war-ic.war/web1004/WEB-INF/classes - but Struts doesn't find them anyway... Is your struts.jar in your war's WEB-INF/lib? And nowhere else in your classpath? -- gR
Re: Cutom Tag request
Aapo Laakkonen [EMAIL PROTECTED] wrote: html:label/ tag would be nice. What others think? Here is some uses: html:form action=someAction html:label property=someProperty/ /html:form html:form action=someAction html:label key=someKey/ /html:form It just prints string values like bean:write tag but does not require name attribute and cannot be used and associated with form. It also could have bean:message functionality. I know that this isn't a big issue, but sometimes you want to display something in form that is not editable (e.g. Primary Key). I know that I can use html:text readonly=true for most cases, but html:label tag could give you more flexibility. I'd like something like html:shown. It should work like html:hidden but it should also display the text. Sometimes I use html:hidden and bean:write together to display some property. When the user then submits the form (in request scope) and the validate() method refuses the input, there is no other way to get the data for the properties used in bean:write since no action is performed. So I use html:hidden to get the values along with user's input. -- gR
Re: newbie: initial values
ecn11 [EMAIL PROTECTED] writes: Hi. I apologize for this probably really stupid question, but I was not able to find a suitable answer anywhere, yet... In my user management I want to provide a way that the users can change their address (they are already stored in a database). Thus I need a form with the old address as initial values. In other words: There is a session variable UserId. How can the form bean that is used by edituser.jsp access this userid to adjust it's initial values. Dont do it this way. Implement an Action which fills the form with values. What I usually (I use struts one month :-) do in such edit something situations: I create I an EditTgingActionForm with properties a) the key properties b) the dependent properties c) optional - a boolean indicator isEditing I create an EditThingAction which: d) checks to see, whether the form has been filled from HTTP (which means: b) properties are filled and c) is true) if so, then it performs the updates. If not, no updates. e) fills the properties b) from the database using the key properties a). In my JSP which leads to that action, i use parametrized link: a href=editthing.do?id=BLA (generated with html:link) As you see, properties b) or c) are not supplied, so the Action knows, there is nothing to be updated, it just retrieves the data. editthing.do then forward to a JSP, which displays the retrieved data and when submitted (again to editthing.do) EditThingAction know, it has to update the data. -- gR
Initializing Application Scope Attributes *.do in template:put
Hi, perhaps these are FAQ: 1) My application has menu structure configurable in the database. I want to read the structure from the database when the app starts and store it in an application scoped bean. To be able to read the data, I need a DataSource so I need access to actionServlet. What is the best way to do this? I know, I can use my own servlet inherited form ActionServlet - but is there any ohter, perhaps more configurable way? 2) When I need initiazed data in my application, I usually put the initialization into setServlet of the action which needs the data and I thought never to need to access such data from a JSP directly. But now I've found this problem when creating menus. I've created a MenuForm which holds the information about the current location id and a collection of menu's children. MenuAction reads the id and fills the children collection, checking whether the current user should see the menu items. menu.jsp then displays the menu structure from MenuForm. It works perfectly, till I try to put this menu into another JSP via jsp:include ... or template:put content=/menu.do?id=100 The problem is that my MenuAction does not produce the HTML, it *forwards* it to the menu.jsp. And forwardning seems to be forbidden inside an include. (Err: Cannot forward as OutputStream or Writer has already been obtained) Is there a way, how to include a *.do generated page which internally uses forward? (Actually, this could be probable solved with the workflows. The action actually does not have to forward to the jsp. I just need to let it perform and include the jsp then) -- gR
Re: Struts + JBoss
Hi. Has anyone of you managed to make Struts and JBoss working together? This is my current situation: I use JBoss-2.2.2 + Tomcat-3.2.2 (by run_with_tomcat.bat - so they are running in one VM) and Struts 1.0. Hi, I use struts in jboss+tomcat. I use 2 configurations: 1st) Separate ejb and war. There are no problems, since I have no EAR file. 2nd) An EAR file. This is a bit tricky: a) you have to let struts.jar in the root of the EAR. Do not place it under war/WEB-INF/lib. Do the same with all jars which would go into WEB-INF/lib b) in war's META-INF/manifest.mf you need following lines for needed libraries: Class-Path: ./struts.jar Class-Path: ./somethingelse.jar So far so good. ActionServlet will be found, your Actions as well But I've had problems with Jasper. It was not able to compile my JSP pages, since it was not loading the jars from manifest.mf The solution was to use jasper at deployment time and let it to compile all jsp pages into java, compile those java sources into classes, jar them and put the jsp.jar into my EAR along with the modified web.xml Even with ant it is not so easy and the deployment takes a lot of time. So I use the 1st approach during development. -- gR
html:form scripting variable
Hi, why does html:form generate no scripting variable? Would be nice, if it did. -- gR
Re: html:form scripting variable
Perhaps. But sometimes I just want to use the form in a scriplet. Now I have to either covert the attribute to local variable or use bean:define. Why not just create the variable like bean:define does? -- gR - Original Message - From: Erik Hatcher [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, July 24, 2001 7:25 PM Subject: Re: html:form scripting variable It does set a page scoped attribute (keyed by the form name from the mapping) that contains the form object. Erik - Original Message - From: Gregor Rayman [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, July 24, 2001 9:50 AM Subject: html:form scripting variable Hi, why does html:form generate no scripting variable? Would be nice, if it did. -- gR
Re: Problem with bean:message tag?
Matthias Brahm [EMAIL PROTECTED] wrote: This must be an error in the Tag Library Reference (in the source-code of the bean:message tag there are no name and property attributes)! Read the Tag Library Guides for the usage of the bean:message tag. In this documentation name and property are not mentioned. Matthias They are: From: struts-bean.html to attribute key: The message key of the requested message, which must have a corresponding value in the message resources. If not specified, the key is obtained from the name and property attributes. -- gR
Re: Web app init
Fabien Le Floc'h [EMAIL PROTECTED] wrote: Hi, I would like to know if it is possible to have some code called at the web application initialization (something like the init() method of the first servlet called by the web app - which here is ActionServlet). Should I just extend ActionServlet? You could wriet your own servlet, which would do all the important stuff in init(). -- gR
Re: URL mapping
Chris Callaghan [EMAIL PROTECTED] asks: Hey all, I want to be able to map a URL to certain JSPs which may or may not have an action involved with them e.g map /logon to logon.jsp which also has as action also called logon also /tour to tour.jsp which has no associated action. How can I do this with struts? Cheers Chris You can do it with your http server, not with struts. -- gR
Re: URL mapping
Of course. But with this action-forward approach, you can forward only *.do URLs. Please correct me, if I am wrong. -- gR - Original Message - From: Rey Francois [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, July 17, 2001 12:25 PM Subject: RE: URL mapping You could, but I would favor the use of the 'forward' attribute in the 'action' element in the struts-config.xml. Here is an extract of the documentation in the DTD: forward Context-relative path of the servlet or JSP resource that will process this request, instead of instantiating and calling the Action class specified by type. Exactly one of forward, include, or type must be specified. Doing it this way makes it very easy to map to an action at a later stage if the requirements have changed. Fr. -Original Message- From: Gregor Rayman [mailto:[EMAIL PROTECTED]] Sent: 17 July 2001 12:25 To: [EMAIL PROTECTED] Subject: Re: URL mapping Chris Callaghan [EMAIL PROTECTED] asks: Hey all, I want to be able to map a URL to certain JSPs which may or may not have an action involved with them e.g map /logon to logon.jsp which also has as action also called logon also /tour to tour.jsp which has no associated action. How can I do this with struts? Cheers Chris You can do it with your http server, not with struts. -- gR The information in this email is confidential and is intended solely for the addressee(s). Access to this email by anyone else is unauthorised. If you are not an intended recipient, you must not read, use or disseminate the information contained in the email. Any views expressed in this message are those of the individual sender, except where the sender specifically states them to be the views of Capco. http://www.capco.com ***
Re: validation problem
Yuriy Zubarev [EMAIL PROTECTED] wrote: David, Yes it is. I think that userForm exists after the validation process (otherwise I would have gotten an error earlier), but something is wrong with countriesList. The form is quite big so I'll post part of it. The problem might be that your form is in the request scope and your countries list does not get populated from the submitted data. I've similar problems when I used the ActionForm for displaying read only properties which did not have an html:hidden on the jsp page. In request scope it works something like this: The ActionForm instace (A1) is used to fill jour JSP. A1 has been probably prepared by some Action. After delivering the response (JSP) the instace A1 is forgotten and eventually garbage collected. The teh user sumbits your JSP. New instace (A2) of your ActionForm is created and filled with the sumbitted values. If the countries list is neither filled in the reset() method, nor the constructor, nor the sumbitted HTTP parameters, than it might be empty or null. Because the instace A1 and A2 are different. If the form is in session scope, than A1 is preserved. -- gR
Nested classes
Hi all, I am using an ActionForm with a collection of Rows which should be editable. My ActionForm contains a property getRow(int i) which returns a bean with the row's properties. Everything work perfectly, when the class returned from getRow(int) is a standalone class. But as soon as I make this class a nested class of my ActionForm, struts complains, if cannot find property setters: This works: public class MyForm ... { public MyRow getRow(int i) { ...; } } public class MyRow { public setProperty(String value) { ...; } } This does not: (cannot find property setter for row[0].property) public class MyForm ... { public MyRow getRow(int i) { ...; } public static class MyRow { public setProperty(String value) { ...; } } I'd really like to use nested classes. Is there a way? -- gR
Re: Updation using iterate tag
[EMAIL PROTECTED] wrote: Hi All, I have one form bean namely MyFormBean. This bean contain vector (pricesVector) of class type Price. The class Price has two attribute oldPrice and newPrice I want to display prices vector in such fashion - oldprice1 (as label) newPrice1 (in text box) oldprice2 (as label) newPrice2 (in text box) oldprice2 (as label) newPrice2 (in text box) - How do I do this using iterate tag, so that any updation in text box should get updated in the vector (prices)? I tried using iterate tag but could not get through? Anybody having solution for this. 1) You have to have two properties in your ActionForm: public Collection getPrices(); and public Price getPrice(int i); Note: getPrice() should return valid Price even if the Vector does not contain it. it could look something like this: public Price getPrice(int i) { while (pricesVector.size() = i) { pricesVector.add(new Price()); } return pricesVector.get(i); } 2) your iterate tag could look something like this: logic:iterate name=editPricesForm property=prices id=element indexId=i type=Price tr tdbean:write name=element property=oldPrice //td tdhtml:text property='%= price[ + i + ].newPrice %' / html:hidden property='%= price[ + i + ].productID %' / /td /tr /logic:iterate You have to know, that the Vector will be FILLED (not just updated) when the form is submitted. -- gR
Re: Updation using iterate tag
[EMAIL PROTECTED] wrote: Hi Sandeep, Try this: logic:iterate id=price name=MyFormBean property=pricesVector TR TD bean:write name=price property=oldPrice/ /TD TD html:text name=price property=newPrice / /TD /TR /logic:iterate and have getter/setter for pricesVector in your MyFormBean and getter/setters for oldPrice and newPrice in Price object. Hope that helps, Dave This cannot work. The displayed prices will be OK, but the update cannot work. The generated paramter will ba called newPrice and the form does not have such property. -- gR
Re: Updation using iterate tag
[EMAIL PROTECTED] wrote: Whoops - my bad (thanks, Gregor!). Had some old code which I hadn't fully tested and copied in... Was using the indexed names for referencing, and hadn't thought through the saving stuff!! Apologies. Sandeep, you have two options here: use scriptlets, or my changed tags which are available on Ted's site (http://husted.com/about/struts/indexed-tags.htm) and should soon (hopefully) be added to the nightly build. Let me know if you have any problems with it. Dave I will certainly test your tags as well :-) Seems much nicer that %= scriplets % -- gR
Re: Diagram of ActionServlet - open for comments
Point 4 could be described in more detail: methods: reset and validate -- gR
Re: Diagram of ActionServlet - open for comments
Ted Husted [EMAIL PROTECTED] wrote: 2.1) Before populating the ActionForm bean, the servlet calls the bean's reset() method. After filling the bean from the reqeust, the servlet calls the bean's validate() method. If validate returns false, the servlet forwards the ActionForm bean to the destination given by the mapping's input property. I mean, validate now returns ActionErrors and does not have to be called at all, if set in web.xml -- gR
Re: Iterate tag update
The problem is, the generated names of the HTML form elements do not correspond to the names of properties of your ActionForm. Here a sample, how this can be done: logic:iterate name=myForm property=elements id=element indexId=i type=de.grayman.test.struts.MyElement tr td html:checkbox property='%= element[ + i + ].member %' / html:hidden property='%= element[ + i + ].elementName %' / /td tdbean:write name=element property=elementName //td tdbean:write name=element property=elementDescription //td /tr /logic:iterate In the MyForm class, there have to be two properties (getter methods): 1) the collection elements 2) indexed property element private Vector elements; public Collection getElements() { return this.elements; } public MyElement getElement(int i) { while (getGroups().size() = i) { this.element.add(new MyElement()); } return (MyElement) this.elements.get(i); } Note: Class MyElement has read/write properties member, elementName, elementDescription, ... Note: The getElement(int i) fills the Vector with empty elements, if they do not exist. In this way, the form will be filled correcly from the submitted HTML-Form. Of course, you could use another approach, e.h. HashTable or an Array instead of Vector. -- gR - Original Message - From: Vaibhav Patil [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, July 09, 2001 2:02 PM Subject: Iterate tag update Hi, I am using logic:iterate tag as follows to print a table with text boxes. logic:iterate id=product name=productSearchForm property=productList tr td align=left bean:write name=product property=productNumber filter=true/ /td td align=center html:text name=product property=quantity size=3/ /td /tr /logic:iterate I have a array of objets(Product) in productList. When I update the quantity and submit the page, it does not update the information into the productList. What might be the problem??? Vaibhav
Re: Setting default value to html:file
Eda Srinivasareddy writes: Hi Is there a way to set a default value to the html:file tags text field? Thanks Eda No way! This is not allowed in plain HTML, so Struts cannot do anything about it. If it was allowed, it would be quite HUGE security hole in the browser. -- gR
Re: [JBoss-user] RE: Struts Jboss?
Assenza, Chris [EMAIL PROTECTED] writes: Okay...I'll rephrase that last one I sent. :) You won't be able to deploy the EAR the way you want without properly using the Application Deployment Descriptor (application.xml). Have you tried doing this? Here's a sample one I use for JBoss 2.0 w/ Tomcat 3.2b7, goes in META-INF of the EAR's contents. ?xml version=1.0? !DOCTYPE application PUBLIC -//Sun Microsystems, Inc.//DTD J2EE Application 1.2//EN http://java.sun.com/j2ee/dtds/application_1_2.dtd; application display-nameApp Name/display-name module web web-uriWarfile.war/web-uri context-root/usermanager/context-root /web /module module ejbEJBJar.jar/ejb !-- Could be multiple -- /module /application Yes, my application.xml should be ok. It looks like this: ?xml version=1.0 encoding=ISO-8859-1? application display-nameusermanager/display-name module web web-uriusermanager.war/web-uri context-root/usermanager/context-root /web /module module ejbusermanager.jar/ejb /module /application And with the duplicated jars (usermanager-client.jar - interfaces) and (struts.jar) (in ear's root and war/WEB-INF/lib) it works. But I don't like duplicating those jars, only to support jasper's jsp compiling. (I will haev to look for jasper's docu, perhaps I can write the ant task) -- gR
Re: jsp vs do
Anthony Martin [EMAIL PROTECTED] wrote: This is how I understand it. A .do maps to an action then to a .jsp. If you link directly to a .jsp, the action never executes. Actions are mapped to a .jsp in the struts-config.xml file. I'm sure there are more clear explanations to follow. Anthony DO takes you to an action which needs some input from your currently displayed from. If you don't have yet the data necessary for the action, you cannot go to the action. In such case you can go to HTML or JSP, which contains the input fields you can fill out and submit to a DO action. In the example application, the link goes to login.jsp, since it is the place where you can enter the credentials. They are then validated in a action (DO). You cannot go to the action directly, since you do not have the username/password yet. -- gR
Re: jsp vs do
Anthony Martin [EMAIL PROTECTED] wrote: In general, however, you can go to actions directly as long as you supply the required fields in the url (if any). In the case of the struts-example, going to logon.do gives a validation error because it was expecting the correct query string. For example: http://localhost/struts-example/logon.do?username=foopassword=bar Anthony Yes, you can always go directly to the action, as long as you provide the necessary data. Some actions do not need any input at all. (e. g. /admin/restart.do) It wouldn't be very bad to go directly to login.do without any data, since this would simply report an error and forward to its input (login.jsp) itself. -- gR -Original Message- From: Gregor Rayman [mailto:[EMAIL PROTECTED]] Sent: Monday, July 02, 2001 10:28 AM To: [EMAIL PROTECTED] Subject: Re: jsp vs do Anthony Martin [EMAIL PROTECTED] wrote: This is how I understand it. A .do maps to an action then to a .jsp. If you link directly to a .jsp, the action never executes. Actions are mapped to a .jsp in the struts-config.xml file. I'm sure there are more clear explanations to follow. Anthony DO takes you to an action which needs some input from your currently displayed from. If you don't have yet the data necessary for the action, you cannot go to the action. In such case you can go to HTML or JSP, which contains the input fields you can fill out and submit to a DO action. In the example application, the link goes to login.jsp, since it is the place where you can enter the credentials. They are then validated in a action (DO). You cannot go to the action directly, since you do not have the username/password yet. -- gR
I18n was: jsp vs do
Thanks, this can be the source of some problems I've had with the i18n. I am using Struts only about one month, I has some problems with figuring out, how bean:message determines the locale it should use. So I peeked in the sources and found out, it uses a session sttribute. I haven't look in the sources deep enough, so I did not find, who actually sets the session attribute. So I used a tiny scriplet which checks to see whether the attribute is set, and if it is not, the scriplet sets it according to the request's preferences. I mean, this could/should be done by the bean:message tag as well. -- gR - Original Message - Timothy Shadel [EMAIL PROTECTED] wrote: One thing to note, however, is that the internationalization (bean:message tags) won't go to non-default mappings unless you use a *.do extension. I can't remember if our tests showed that going first to a *.do and then to a *.jsp worked or not...I don't think so. If you need to make your login screen available (to continue the example) in several languages, you need to link to the *.do version, and write your Action class in a way that either won't auto-validate the ActionForm, or won't require info up front. Tim Shadel Gregor Rayman [EMAIL PROTECTED] 07/02/01 11:52AM Anthony Martin [EMAIL PROTECTED] wrote: In general, however, you can go to actions directly as long as you supply the required fields in the url (if any). In the case of the struts-example, going to logon.do gives a validation error because it was expecting the correct query string. For example: http://localhost/struts-example/logon.do?username=foopassword=bar Anthony Yes, you can always go directly to the action, as long as you provide the necessary data. Some actions do not need any input at all. (e. g. /admin/restart.do) It wouldn't be very bad to go directly to login.do without any data, since this would simply report an error and forward to its input (login.jsp) itself. -- gR -Original Message- From: Gregor Rayman [mailto:[EMAIL PROTECTED]] Sent: Monday, July 02, 2001 10:28 AM To: [EMAIL PROTECTED] Subject: Re: jsp vs do Anthony Martin [EMAIL PROTECTED] wrote: This is how I understand it. A .do maps to an action then to a .jsp. If you link directly to a .jsp, the action never executes. Actions are mapped to a .jsp in the struts-config.xml file. I'm sure there are more clear explanations to follow. Anthony DO takes you to an action which needs some input from your currently displayed from. If you don't have yet the data necessary for the action, you cannot go to the action. In such case you can go to HTML or JSP, which contains the input fields you can fill out and submit to a DO action. In the example application, the link goes to login.jsp, since it is the place where you can enter the credentials. They are then validated in a action (DO). You cannot go to the action directly, since you do not have the username/password yet. -- gR
Re: template and I18N
Niall Pemberton [EMAIL PROTECTED] wrote: 1. This was answered before. See following message: http://www.mail-archive.com/struts-user@jakarta.apache.org/msg05207.html Thanks. 2. IMHO avoid scriptlets. As well IMHO :-) -- gR
template and I18N
Hi all, I've just started to use Struts and I have some questions: 1. How can I use the I18N features in the template tags? In my template.jsp I've got the following tag: titletemplate:get name='title'//title In the page using this teplate the following: template:put name='title' content='Kalkulation' direct='true'/ I'd like to replace the German text 'Kalkulation' with its key e.g. 'app.title.calculation' Is there a nice way to do this? 2. How can I use use the I18N features in Struts directly in Java Scriplets? Sometimes I need the translated texts in scriplets. What is the best way to access them? Now I am using this aproach: % MessageResources resources = (MessageResources) pageContext.getAttribute( Action.MESSAGES_KEY, PageContext.APPLICATION_SCOPE); Locale locale = (Locale) pageContext.getAttribute( Action.LOCALE_KEY, PageContext.SESSION_SCOPE); if (null == locale) { locale = request.getLocale(); } String myText = resources.getMessage(locale, app.the.text,key); % Thanks for an answer -- gR
Re: template and I18N
Johan Compagner [EMAIL PROTECTED] writes: look at the bean:message tag: bean:message key=title/ johan Hi Johan, this does not help me. bean:message key=title / prints the internationalized word Title. But I want to use it in the template to print various titles. Example (without the headers): ApplicationResources.properties === app.login=Login app.logout=Logout ApplicationResources_de.properties == app.login=Anmelden app.logout=Abmelden now the template files: template.jsp ... headtitletemplate:get name=title //title/head ... login.jsp = template:insert template='/template.jsp' template:put name='title' content='Login' direct='true'/ ... /template:insert logout.jsp == template:insert template='/template.jsp' template:put name='title' content='Logout' direct='true'/ ... /template:insert As you can see, I have to insert the words Login and Logout into the files login.jsp and logout.jsp literally, instead of inserting the keys app.login and app.logout Of course I could use the scripplet approach and use template:put name='title' content='%= resources.getMessage(locale, app.login) %' direct='true' / instead. But is there a nicer way? Something like: template:put name='title' direct='true' bean:message key='app.login' / /template:put Groetjes -- gR
Re: Where's the best place to do authentication
Jon.Ridgway [EMAIL PROTECTED] writes: Hi Shogo, Have a look at the 'example' webapp provided with struts, this uses a taglib to check the user is logged on, I'm sure you could use/amend it to fit your purpose. Jon. I am not very happy with taglibs checking for logged in user. Taglibs can be used only in JSP and JSP should implement the View part of the MVC pattern. Authenticating users is bussiness logic and so it shoud be done somewhere in the actions. -- gR
Re: Oracle Driver
Geoffrey Van Nuffelen [EMAIL PROTECTED] has problems with Oracle driver. Hi Geoffrey, try to a) rename the classes12.zip to classes12.jar if it does not help b) move the file unter jakarta-tomcat/lib directory and restart tomcat if this does not help c) move the file under $JAVA_HOME/lib (and restart tomcat) -- gR