Re: How to modify Struts2 start up process.
See if ur web.XML has the spring configuration configured twice. We faced the same issue before Sent from my iPhone On Jul 13, 2010, at 11:42 AM, hisameer cool_sameer_fo...@yahoo.com wrote: - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Datasource object in any class
Hi friends, I have an application in which there is a Cart object which i need to save in session, as it is to be saved in session, i cannt store a reference of datasource in the Cart. (as i believe it is not serializable). I need to know is there a way by which the datasource is available globally and i dont need to pass that explicitly in every method i use it. I am using struts 1.x and tomcat. Pl advice. -- Thanks and kind Regards, Abhishek jain
Re: Created a struts2 application but getting odd results
Hi John, i would say that there is some kind of cache problem, it looks like You are asking for a url and get an answear, then You ask again about exactly same url and get exactly same answear. Maybe some Websphere configuration issue? Best greetings, Paweł Wielgus. 2010/7/12 John L. Longo johnlo...@apptecinc.com: Here is the situation: I'm using two separate browsers (IE8 FF3.6) to test the application at the same time. I have a form that takes contact information (name, address, email, etc.) I access the form (http://localhost:9084/demosite/contactus.action) from IE8 and type the first name and hit the submit button. The validation fails and the page is displayed with the first Name still filled in and the correct error messages displayed (Last Name Required, etc.). BTW, That's is what I expected. But here is the odd problem that I'm seeing: I then open up FF3.6 and enter the URL http://localhost:9084/demosite/contactus.action I see the page displayed with the same info (First Name filled in and error messages displayed) that I have in the IE8 browser. I'm using struts2-core-2.1.8.1 and running it under Websphere 7.0.0.9. I'm sure I have a setup issue, but really don't know what it could be, other than that the application is working fine no error messages in the logs. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Struts 2 custom JSP-tags encoding
Hi, Have an encoding problem when writing custom struts 2 (jsp) tags. We have all our source file UTF-8 encoded and get strange outputs from our tags when using ie. ÅÄÖ. Traced it down to JspTemplateEngine which is using org.apache.struts2.components.Include.include(..). The include(..) methods looks after a defaultEncoding which is supposed to be injected with struts.i18n.encoding. The thing is that JspTemplateEngine is using Include.include(..) statically and thus struts.i18n.encoding is never injected. Is this a bug? Anyone had similar problems? Regards, Carljohan - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
RE: Currency Formatting
Ooo, didn't know I could use an iterator like that, I have always defined the var. Thanks for the tip, however do you not find that other way easier for readability? Just thinking an outsider might be left wondering where price came from.. Maybe I am missing the point. -Original Message- From: Chris Pratt [mailto:thechrispr...@gmail.com] Sent: 13 July 2010 23:28 To: Struts Users Mailing List Subject: Re: Currency Formatting I've never used the iterator tag like that, the standard way to use the Struts 2 Iterator would be: s:iterator value=products span class=product-names:property value=name http://product.name/ //span span class=product-pricepound;s:text name=format.currencys:param value=price//s:text/span /s:iterator Since the iterator tag puts the current value on the top of the stack, there's no reason to define a variable to hold it. It's much simpler to just use the value stack to pull the values from. Don't know if this might help or not. (*Chris*) On Tue, Jul 13, 2010 at 3:23 PM, Chris Miles ch...@chrismiles.org wrote: Chris, I have a list of products which contain a double price. I now have. s:iterator value=products var=product span class=product-names:property value=#product.name//span span class=product-pricepound;s:text name=format.currencys:param value=#product.price//s:text/span /s:iterator Chris - Original Message - From: Chris Pratt thechrispr...@gmail.com To: Struts Users Mailing List user@struts.apache.org Sent: Tuesday, July 13, 2010 11:04 PM Subject: Re: Currency Formatting s:iterator puts the value on the top of the stack, so if you have a list of doubles, we'll call it amounts, it would look something like this: s:iterator value=%{amounts} s:text name=format.currencys:param value=%{top}//s:text /s:iterator (*Chris*) On Tue, Jul 13, 2010 at 2:43 PM, Chris Miles ch...@chrismiles.org wrote: Chris, Hi that works perfectly for s:text name=format.currencys:param value=total//s:text where total is public Double getTotal but causes all rendering to stop at the following within an iterator. s:text name=format.currencys:param value=#product.price/ where ListProduct getProducts (for the iterator), public Product getProduct and public Double getPrice and also fails just on s:text name=format.currencys:param value=product.price//s:text where public Product getProduct Is there places where different mechanisms need to be used here? I dont understand the inconstistant result I now get. Nothing in the log files on TRACE Thanks Chris - Original Message - From: Chris Pratt thechrispr...@gmail.com To: Struts Users Mailing List user@struts.apache.org Sent: Tuesday, July 13, 2010 8:16 PM Subject: Re: Currency Formatting try s:param instead of s:property. (*Chris*) On Tue, Jul 13, 2010 at 12:11 PM, Chris Miles ch...@chrismiles.org wrote: At the moment I have in my struts.xml constant name=struts.custom.i18n.resources value=ApplicationResources / ApplicationResources.properties is being packaged within WEB-INF\classes within a WAR within an EAR. The file contains: format.currency={0,number,currency} In my JSP I have s:text name=format.currencys:property value=product.price//s:text Without the s:text the price is displayed (a Double). When the s:text is included all I get is: {0} thanks Chris - Original Message - From: Chris Pratt thechrispr...@gmail.com To: Struts Users Mailing List user@struts.apache.org Sent: Sunday, July 11, 2010 1:25 AM Subject: Re: Currency Formatting Define something like: format.currency={0,number,currency} In your applications.properties file, then use: s:text name=format.currencys:param value=%{amount}//s:text HTH (*Chris*) On Sat, Jul 10, 2010 at 5:53 AM, Chris Miles ch...@chrismiles.org wrote: Hi If I am displaying a Double to a JSP page what is the recommended way to format this is as a currency to two decimal points? Thanks Chris - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Struts2 validation
Thanks for the answer. I'm trying this, but it is not working properly field name=telefonos field-validator type=fieldexpression ![CDATA[#paciente.telefonoMobil = 0 || #paciente.telefonoFixo = 0 ]] messagi/message /field-validator /field I have two numeric textfields any idea?? jake-65 wrote: You can use the fieldexpression validator. See http://struts.apache.org/2.1.8.1/docs/fieldexpression-validator.html for details. On Tue, Jul 13, 2010 at 05:39:52AM -0700, kisja wrote: I have two textfield and I would like to validate that at least one of both have data. How I can do? (I apologize for my bad English) Thanks -- View this message in context: http://old.nabble.com/Struts2-validation-tp29149892p29149892.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org -- View this message in context: http://old.nabble.com/Struts2-validation-tp29149892p29159311.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Help Struts2 + interceptor
Hi all, You can try this way: http://poulwiel.blogspot.com/2009/01/intercepting-all-actions-inside-my-app.html Best greetings, Paweł Wielgus. 2010/7/13 Fabio Alves de Araujo Ebner - DnaSolution fabio.eb...@dnasolution.com.br: The problem is: When he pass through interceptor and go to action cadastrarOrdemServico my var cdProjetoOS are set with null :( thanks, follow my all code: CLASS LoginClienteInterceptor .java --- package br.com.dnasolution.site.interceptor; import com.opensymphony.xwork2.ActionInvocation; import com.opensymphony.xwork2.interceptor.Interceptor; public class LoginClienteInterceptor implements Interceptor { @Override public void destroy() { } @Override public void init() { } @Override public String intercept(ActionInvocation invocation) throws Exception { if(invocation.getInvocationContext().getSession().get(clienteLogado) != null){ return invocation.invoke(); }else{ return clienteNaoLogado; } } } Class LoginUsuarioInterceptor package br.com.dnasolution.site.interceptor; import com.opensymphony.xwork2.ActionInvocation; import com.opensymphony.xwork2.interceptor.Interceptor; public class LoginUsuarioInterceptor implements Interceptor { @Override public void destroy() {} @Override public void init() { } @Override public String intercept(ActionInvocation invocation) throws Exception { if(invocation.getInvocationContext().getSession().get(usuarioLogado) != null){ return invocation.invoke(); }else{ return usuarioNaoLogado; } } } My STruts.xml !DOCTYPE struts PUBLIC -//Apache Software Foundation//DTD Struts Configuration 2.0//EN http://struts.apache.org/dtds/struts-2.0.dtd;struts package name=my-secure extends=convention-default interceptors interceptor name=loginUsuarioInterceptor class=br.com.dnasolution.site.interceptor.LoginUsuarioInterceptor /interceptor interceptor name=loginClienteInterceptor class=br.com.dnasolution.site.interceptor.LoginClienteInterceptor /interceptor interceptor-stack name=secureStack interceptor-ref name=defaultStack/ interceptor-ref name=loginClienteInterceptor/ interceptor-ref name=loginUsuarioInterceptor/ /interceptor-stack /interceptors default-interceptor-ref name=secureStack/ global-results result name=clienteNaoLogado/jsp/usuario/loginUsuario.jsp /result result name=clienteNaoLogado/jsp/cliente/loginCliente.jsp /result /global-results /package /struts My OrdemServicoAction.java package br.com.dnasolution.site.action; import java.util.Date; import java.util.List; import org.apache.struts2.convention.annotation.Action; import org.apache.struts2.convention.annotation.InterceptorRef; import org.apache.struts2.convention.annotation.ParentPackage; import org.apache.struts2.convention.annotation.Result; import com.opensymphony.xwork2.ActionContext; @ParentPackage(my-secure) public class OrdemServicoAction { @Action(value = cadastrarOrdemServico, results = { �...@result(name = valido, location = /jsp/ordemservico/cadastro_sucesso.jsp), �...@result(name = invalido, location = /jsp/ordemservico/cadastro_falha.jsp) }, interceptorRefs = { @InterceptorRef(loginClienteInterceptor) }) public String cadastrarOrdemServico() { try { TbProjeto projetoOS = projetoService .getProjetoById(this.cdProjetoOS); TbTopicoOs topicoOs = topicoOsService.getTopicoById(cdTopicoOS); } - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Pre-selected s:checkbox problem.
Hi Sharath, do You have getSelected_rows() method in action? s:checkbox need to know what values are present somehow, and it asks the action for the field value that it generates. Best greetings, Paweł Wielgus. 2010/7/13 sharath karnati karna...@yahoo.com: I don't think I can use s:checkboxlist in my requirement. The checkboxs are created inside s:iterator. Is this not possible using s:checkbox?? --- On Tue, 7/13/10, Chris Pratt thechrispr...@gmail.com wrote: From: Chris Pratt thechrispr...@gmail.com Subject: Re: Pre-selected s:checkbox problem. To: Struts Users Mailing List user@struts.apache.org Date: Tuesday, July 13, 2010, 12:07 PM Look at the s:checkboxlist instead, it automatically handles maintaining state. (*Chris*) On Tue, Jul 13, 2010 at 9:04 AM, sharath karnati karna...@yahoo.com wrote: Hi All, Say I'm declaring s:checkbox in s:iterator s:iterator value=employeeList tr align=left td align=center s:checkbox name=selected_rows fieldValue=%{emp_id}/ /td td s:property value=emp_id/ /td td s:property value=emp_name/ /td td s:property value=dept_name/ /td /tr /s:iterator tr td align=left bSelect Division: /b s:select headerKey= headerValue=-- Select -- key=staff_division list=division_list onchange=javascript:getDivisionUserValues('userList'); / b Select User: /b s:select headerKey= headerValue=-- Select -- key=staff_name list=staff_list / /td /tr in action class selected_rows is selected as String[] When user selects 'Division then I'm calling my action and populating staff_list and re-displaying same page. The problem is that I selected checkbox for emp_id 100,102,105, when it is re-displaying page because of division selection, it is not showing selected checkbox as pre-selected. In action the array is populated with these values but when it is re-displaying page it is showing unchecked. Can anyone please let me know, how to display page with selected checkboxs using selected_rows array. Thanks in advance. Regards, Sharath. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Session error while loading an object
Hi all, You get this error every time when tomcat tries to save someone's session and object of class com.cart.Customer is in it. Like Robert said, add Serializable to com.cart.Customer and the problem will go away. Best greetings, Paweł Wielgus. 2010/7/13 abhishek jain abhishek.netj...@gmail.com: Hi, thanks for the comments, i will check but i get this error only at times, and not always. Can this still be the cause of the problem. thanks abhishek On Tue, Jul 13, 2010 at 6:39 PM, Robert Taylor rtay...@dtgresults.comwrote: Greetings, Does the Customer object implement Serializable interface? If not, try modifying Customer to implement Serializable and see if the error still persists. /robert - Original Message - From: abhishek jain abhishek.netj...@gmail.com To: Struts Users Mailing List user@struts.apache.org Sent: Tuesday, July 13, 2010 4:33 AM Subject: Session error while loading an object Hi friends, I am using tomcat 5.5 , struts 1.x and i encounter the following error: I actually store the object in session and retrieve that(for a shopping cart application), pl. advice what i can do to remove this error: Exception loading sessions from persistent storagejava.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: com.cart.Customer at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1333) at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947) at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351) at org.apache.catalina.session.StandardSession.readObject(StandardSession.java:1416) at org.apache.catalina.session.StandardSession.readObjectData(StandardSession.java:940) at org.apache.catalina.session.StandardManager.doLoad(StandardManager.java:394) at org.apache.catalina.session.StandardManager.load(StandardManager.java:321) at org.apache.catalina.session.StandardManager.start(StandardManager.java:637) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4202) at org.apache.catalina.core.StandardContext.reload(StandardContext.java:3056) at org.apache.catalina.loader.WebappLoader.backgroundProcess(WebappLoader.java:432) at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1278) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1570) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1579) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1579) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1559) at java.lang.Thread.run(Thread.java:619) Caused by: java.io.NotSerializableException: com.cart.Customer at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1156) at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509) at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1474) at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326) at org.apache.catalina.session.StandardSession.writeObject(StandardSession.java:1492) at org.apache.catalina.session.StandardSession.writeObjectData(StandardSession.java:957) at org.apache.catalina.session.StandardManager.doUnload(StandardManager.java:517) at org.apache.catalina.session.StandardManager.unload(StandardManager.java:463) at org.apache.catalina.session.StandardManager.stop(StandardManager.java:667) at org.apache.catalina.core.StandardContext.stop(StandardContext.java:4362) at org.apache.catalina.core.StandardContext.reload(StandardContext.java:3050) ... 7 more - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Session error while loading an object
2010/7/14 Paweł Wielgus poulw...@gmail.com Hi all, You get this error every time when tomcat tries to save someone's session and object of class com.cart.Customer is in it. Like Robert said, add Serializable to com.cart.Customer and the problem will go away. Best greetings, Paweł Wielgus. Hi, I have added the Serializable to com.cart.Customer, but now i am getting the following error, which i think is due to the reason that i am using reference of Datasource and Message Resource in the class which i believe is not serializable: IOException while loading persisted sessions: java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: org.apache.commons.dbcp.BasicDataSourcejava.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: org.apache.commons.dbcp.BasicDataSource at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1333) at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947) at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329) . Pl. advice thanks abhishek
Re: Session error while loading an object
Just the same problem: BasicDataSource is not serializable. Ernesto On Wed, Jul 14, 2010 at 11:15 AM, abhishek jain abhishek.netj...@gmail.com wrote: 2010/7/14 Paweł Wielgus poulw...@gmail.com Hi all, You get this error every time when tomcat tries to save someone's session and object of class com.cart.Customer is in it. Like Robert said, add Serializable to com.cart.Customer and the problem will go away. Best greetings, Paweł Wielgus. Hi, I have added the Serializable to com.cart.Customer, but now i am getting the following error, which i think is due to the reason that i am using reference of Datasource and Message Resource in the class which i believe is not serializable: IOException while loading persisted sessions: java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: org.apache.commons.dbcp.BasicDataSourcejava.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: org.apache.commons.dbcp.BasicDataSource at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1333) at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947) at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329) . Pl. advice thanks abhishek - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Session error while loading an object
Greetings, I think that you might want to separate your functional concerns into different objects. One common pattern in multi-level architectures is to have a model object like Customer which would contain domain information for the Customer and a Service object like CustomerService which would be a singleton (many times injected using some IoC container). CustomerService would be used as a fascade to retrieve and persist Customer objects (or rather would delegate to a DAO layer to do the actual retrieval and persistence). The DataSource is usually injected into the DAO layer using your IoC container. Spring is a popular IoC container which is used to manage the middle tier (and web tier if you like). By separating the layers, you could persist Customer to the session and collaborate with the CustomService object and MessageResources when necessary in the web tier and avoid the NotSerializableExceptions you are running into with the DataSource and MessageSources. These are often interfaces whose implementations are provided by some framework, so it's unlikely you will be able to easily make them Serializable (they probably weren't meant to be anyways). Keep in mind, there are many ways to implement multilevel architecture. You may want to do some research on best practices. Spring and Rod Johnson are good resources. You could also reference Martin Fowler. Good luck. /robert - Original Message - From: abhishek jain abhishek.netj...@gmail.com To: Struts Users Mailing List user@struts.apache.org Sent: Wednesday, July 14, 2010 5:15 AM Subject: Re: Session error while loading an object 2010/7/14 Paweł Wielgus poulw...@gmail.com Hi all, You get this error every time when tomcat tries to save someone's session and object of class com.cart.Customer is in it. Like Robert said, add Serializable to com.cart.Customer and the problem will go away. Best greetings, Paweł Wielgus. Hi, I have added the Serializable to com.cart.Customer, but now i am getting the following error, which i think is due to the reason that i am using reference of Datasource and Message Resource in the class which i believe is not serializable: IOException while loading persisted sessions: java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: org.apache.commons.dbcp.BasicDataSourcejava.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: org.apache.commons.dbcp.BasicDataSource at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1333) at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947) at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329) . Pl. advice thanks abhishek - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Advice on new Project
I've got a couple things that are requirements for a new project I'm starting. If anyone has any advice for some clean/simple way so to do this in Struts2, I'd very much appreciate pointers to more information. First.. I'm new to Struts2, but have done a fair amount with Struts. The app I'm writing has to be Internationalized, which by itself isn't a problem. It also is multi-tenant, which for us means that a single app will serve multiple customers and each customer can specify their own Content and styles. Our current J2EE (Servlet/JSP) apps use a combinations of custom tags that look up specific content in a database and a directory hierarchy that serves html/css out of subdirectory depending on a Session variable. Any advice is appreciated. -- Greg Akins http://insomnia-consulting.org http://www.pghcodingdojo.org http://pittjug.dev.java.net http://twitter.com/akinsgre http://www.linkedin.com/in/akinsgre - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Model Driven Preparable
My interceptor stack is as below interceptor-ref name=exception/interceptor-ref interceptor-ref name=prepare/interceptor-ref interceptor-ref name=model-driven/interceptor-ref interceptor-ref name=params/interceptor-ref Please guide. On Tue, Jul 13, 2010 at 4:27 PM, Amol Ghotankar ghotankaru...@gmail.comwrote: Dear List members, I have implemented model driven prepare able interface in S2, also included interceptor stack My method call flow is 1.prepare 2.getModel 3.getModel Why does getModel gets called twice. Is it to useful to call it twice or is my config setting wrong somewhere. Also I create a object in my prepare method, but this method creates new object every-time rather than using the created object in previous prepare. With Best Regards, Amol Ghotankar -- With Best Regards, Amol Ghotankar Technical Director Cursive Technologies Pvt. Ltd. 104, A1 Wing, W Sector, Masulkar Colony, Ajmera, Pimpri, Pune-18 INDIA O: +91 2020 270 570 M: +91 9960 980 419 www.cursivetech.com CURSIVE TECHNOLOGIES EMAIL NOTICE The information contained in this email and any attachments is confidential and may be subject to copyright or other intellectual property protection. If you are not the intended recipient, you are not authorized to use or disclose this information, and we request that you notify us by reply mail or telephone and delete the original message from your mail system.
Re: S2 validation without API ties
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Wes, Sorry for the delay in replying... I hadn't noticed that your reply was here. On 4/28/2010 11:49 AM, Wes Wannemacher wrote: I can understand your desire to remove the dependency of struts, making your actions reusable. But at the same time, without the helper methods that ActionSupport provides, implementing a mechanism for displaying validation failure error messages in the struts tags becomes extremely difficult. Agreed. I was just hoping that there might be a way for Struts 2 to do a kind of duck-typing in these situations. Perhaps I could write a single class that subclasses ActionSupport (or implements the appropriate interfaces) and can wrap any class, passing-through all the method calls. That will probably require some nasty on-the-fly compilation of classes, but I'm really trying to avoid having 2 classes for every action: one to do the real work, and one to provide the appropriate interface to Struts. It's like S1 all over again :( The motivation here is that we want to use the same business and controller objects for our webapp as well as a non-web-based app, where the use of S2 doesn't make any sense. I will add, ActionSupport is linked only against classes provided by the JDK. Yes, but it's kind of ugly to tear ActionSupport out of the rest of the S2 libraries just to get validation working. And, that extending ActionSupport isn't a requirement, but not extending it means you will lose mostly the integration with the tags on the frontend. Well, it seems that the validation itself can't properly run unless there is ActionSupport present. Without it, the error messages aren't written anywhere, which significantly limits the usefulness of the validator. What if the validator could accept a separate object that knows how to collect error messages? That's why I was asking if another object could go onto the value stack to accept the error messages. Even if you still don't want struts/xwork classes in your validation, i would suggest the OVal plugin, combined with a delegatory setup for executing your beans. I'll definitely check-out OVal. Thanks, - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkw9xJ4ACgkQ9CaO5/Lv0PDNJACeMAp/XpJKPoutdwUw/229ukLm /ykAn2JVGvAvp2hDhptQxL0GbA+fhdnB =L2DR -END PGP SIGNATURE- - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Reloading MessageResources without context reload
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 All, I've looked through the archives to see if there's a way to do this, and I feel like there must be an easier way, so I'll ask again. I'm using Struts 1.3.8 in a webapp deployed on Tomcat 6.0, and I'd like to reload my own MessageResource objects on demand (say, when I have to change a .properties file in production for some reason). I'd prefer to avoid an app reload if possible. I tried the simplest thing I could come up with, which was this: MessageResourcesFactory mrf = MessageResourcesFactory.createFactory(); MessageResources mr = mrf.createResources(MyResources); This gives me two unique objects every time I execute the code (that is, the hashcodes change), but mr.getMessage(foo) always returns the string that was (apparently) originally loaded. I also tried doing this: MessageResourcesFactory.setFactoryClass(MessageResourcesFactory.getFactoryClass()); MessageResourcesFactory mrf = MessageResourcesFactory.createFactory(); MessageResources mr = mrf.createResources(MyResources); The idea here was that I might be able to force a flush of some kind of cached object, but this doesn't help, either. I've been looking at the code for 1.3.8 for MessageResourcesFactory, MessageResources, and their Property* counterparts, and it doesn't look like any caching is being performed in these classes. The archives say that forcing a reload requires a replacement implementation of MessageResourcesFactory, but I can't see why that's necessary. Could it be that the ClassLoader provided by Tomcat is caching the contents of the properties file, and I'm not getting my updates because of that? I'd love an explanation for this. Thanks, - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkw9xrgACgkQ9CaO5/Lv0PANKQCeLNd+RWxBi0adhuWaCG+q+YUA tmwAnjBO7SU+5ZsUw2U7o3OXLkbUlMSl =/CPN -END PGP SIGNATURE- - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Struts2/Ajax Help
I have a form that uses the select tag to retrieve a list of values from my action when the JSP is rendered. What I would like to do is use the built in AJAX support so that I could populate another dropdown with a set of values that depends on that initial selection. Can someone post a simple example of how to do this using the struts tags? - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Accessing scoped variables via s:property.../ tags
On 7/14/10 1:22 PM, mailtolouis2020-str...@yahoo.com wrote: https://cwiki.apache.org/WW/application-session-request-objects-in-jsp.html I think the doc need to update. Done, thanks: https://cwiki.apache.org/confluence/pages/diffpages.action?pageId=14052originalId=23332622 -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Struts2: JSP vs JSPF issue
The following is in a file called menu.jspf %@ page pageEncoding=UTF-8 % %@ taglib prefix=s uri=/struts-tags % h2Menu/h2 s:a action=loginLogin/s:a The html produced is (produces s:a tags instead of a tags...): h2menu/h2 s:a action=loginLogin/s:a The exact same code is now placed in a file called menu.jsp and it produces (the expected result)... h2menu/h2 a href=/MZWEB/loginLogin/a I am using Netbeans 6.9 RC2 with Glassfish Prelude... What's causing this? I've never used jspf files before, but they have less template code in them, where the jsp files are templated for a new web page (meta, head, body...). So I thought jspf are just fragments the exact same behaviour but made to assemble pages... anyways I see no issue using jsp files with my tiles but was just wondering what this was about.
Re: Struts2: JSP vs JSPF issue
My bet would be that the .jspf extension is not mapped to be processed by the JSP Processor in your Servlet Container. I think .jspf is just a naming convention, it doesn't have any intrinsic meaning to the container, so if you want to continue putting your fragments in .jsp files, they should work fine. (*Chris*) On Wed, Jul 14, 2010 at 12:08 PM, Ken ken.mcwilli...@aerose.com wrote: The following is in a file called menu.jspf %@ page pageEncoding=UTF-8 % %@ taglib prefix=s uri=/struts-tags % h2Menu/h2 s:a action=loginLogin/s:a The html produced is (produces s:a tags instead of a tags...): h2menu/h2 s:a action=loginLogin/s:a The exact same code is now placed in a file called menu.jsp and it produces (the expected result)... h2menu/h2 a href=/MZWEB/loginLogin/a I am using Netbeans 6.9 RC2 with Glassfish Prelude... What's causing this? I've never used jspf files before, but they have less template code in them, where the jsp files are templated for a new web page (meta, head, body...). So I thought jspf are just fragments the exact same behaviour but made to assemble pages... anyways I see no issue using jsp files with my tiles but was just wondering what this was about.
ParentPackage annotation not applying to subpackages
I'm using struts 2 with convention plugin. The convention plugin page states for the ParentPackage annotation, To apply this annotation to all actions in a package (and subpackages), add it to package-info.java. I have two packages, my-default and my-secure. I have a package called actions.secure and in it I have a package-info.java with a ParentPackage annotation for my-secure. However, I have subpackages, actions.secure.view, etc. and in order for them to think they are also part of my-secure, they need their own package-info.java file. This is annoying. How do I make the package-info.java apply to all of the subpackages like the convention page says. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Currency Formatting
On further digging I have found out some more info. My action is /shop/getProduct.action?productId=61 The action is defined as follows: action name=getProduct class=org.chrismiles.sentiments.struts2.shop.GetProductAction result name=success/shop.jsp?content=/jsp/shopview/getProduct.jsp/result /action shop.jsp is basically main template page in which the content changes inside. It contains the following line s:include value=%{#parameters.content}/ So no matter what action I call I can forward to the shop page as the view and include the custom view page which in the above example is the getProduct jsp page. For testing I just used the following action result to go straight to the individual view page. result name=success/jsp/shopview/getProduct.jsp/result which includes s:text name=format.currencys:param value=product.price//s:text/span and it renders every thing successfully and even includes a localised £ sign which. Does this help shed any further light on it? Something in the including mechanism which is messing things up? Chris - Original Message - From: Chris Pratt thechrispr...@gmail.com To: Struts Users Mailing List user@struts.apache.org Sent: Wednesday, July 14, 2010 12:10 AM Subject: Re: Currency Formatting That's weird I've never experienced anything like that were rendering stops without putting anything into the logs. Looks like you'll have to dig into the code. (*Chris*) On Tue, Jul 13, 2010 at 4:05 PM, Chris Miles ch...@chrismiles.org wrote: HTML rendering just completely stops at that point. I get the following: span class=product-nameThis is a product name/span span class=product-price And nothing else for the rest of the page. Nothing in the logs. Nothing :) Chris - Original Message - From: Chris Pratt thechrispr...@gmail.com To: Struts Users Mailing List user@struts.apache.org Sent: Wednesday, July 14, 2010 12:03 AM Subject: Re: Currency Formatting Define fails, you get a stack trace? you don't get the output you expected? If so, what were you expecting vs. what did you get? I've used that code a thousand times, so I'm not sure what could be going wrong... (*Chris*) On Tue, Jul 13, 2010 at 3:56 PM, Chris Miles ch...@chrismiles.org wrote: Thanks Chris. The reason I use this method in my iterators is there are a few places where I use nested iterators so the # notation is the only way to access the current iterator but also the parent iterator. This specific iterator is not nested so I have changed it for learning and trial sake and it fails with the line span class=product-prices:text name=format.currencys:param value=price//s:text/span I can put span class=product-prices:property value=price//span and it displays the value fine. Chris - Original Message - From: Chris Pratt thechrispr...@gmail.com To: Struts Users Mailing List user@struts.apache.org Sent: Tuesday, July 13, 2010 11:28 PM Subject: Re: Currency Formatting I've never used the iterator tag like that, the standard way to use the Struts 2 Iterator would be: s:iterator value=products span class=product-names:property value=name http://product.name/ //span span class=product-pricepound;s:text name=format.currencys:param value=price//s:text/span /s:iterator Since the iterator tag puts the current value on the top of the stack, there's no reason to define a variable to hold it. It's much simpler to just use the value stack to pull the values from. Don't know if this might help or not. (*Chris*) On Tue, Jul 13, 2010 at 3:23 PM, Chris Miles ch...@chrismiles.org wrote: Chris, I have a list of products which contain a double price. I now have. s:iterator value=products var=product span class=product-names:property value=#product.name//span span class=product-pricepound;s:text name=format.currencys:param value=#product.price//s:text/span /s:iterator Chris - Original Message - From: Chris Pratt thechrispr...@gmail.com To: Struts Users Mailing List user@struts.apache.org Sent: Tuesday, July 13, 2010 11:04 PM Subject: Re: Currency Formatting s:iterator puts the value on the top of the stack, so if you have a list of doubles, we'll call it amounts, it would look something like this: s:iterator value=%{amounts} s:text name=format.currencys:param value=%{top}//s:text /s:iterator (*Chris*) On Tue, Jul 13, 2010 at 2:43 PM, Chris Miles ch...@chrismiles.org wrote: Chris, Hi that works perfectly for s:text name=format.currencys:param value=total//s:text where total is public Double getTotal but causes all rendering to stop at the following within an iterator. s:text name=format.currencys:param value=#product.price/ where ListProduct getProducts (for the iterator), public Product getProduct and public Double getPrice and also fails just on s:text name=format.currencys:param value=product.price//s:text where public Product getProduct Is there places where