Re: struts2 + javascript doubt
Hi, I have tried a href=*javascript:fPrimerNivel( ' *${info.id_html} ' *);* ( note the single quotes) and it works Thank you so much Cimballi, you are a crack 2010/5/24 Cimballi cimba...@cimballi.net Yes you can but instead of using s:property you can use directly JSP EL like {myBean.propertyName}. Cimballi On Mon, May 24, 2010 at 1:10 PM, lucas owen sr.ilus...@gmail.com wrote: Hi: is it possible to pass a dynamic parameter to a javascript function??? I'm trying this: h3 id=s:property value=*'info.id_html'*/ class=*head* a href=*javascript:fPrimerNivel(*s:property value=*'info.id_html'*/*);* s:property value=*info.titulo_menu*//a /h3 javascript function: fPrimerNivel(id){ alert(id); } yields [object] If I try the same, but with javascript:fPrimerNivel(this.id), I get [undefined] I dont know if this is possible, any help would be so much appreciated ciaooo -- Cimballi JAVA J2EE Freelance http://cimballi.elance.com/ - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Struts upgrade from 1.2 to 1.3.10 gone wrong
Hi. I have upgraded my Struts application from 1.2 to 1.3.10. With minor problems at first it finally worked. Suddenly it stopped working and I guess it must be after restart of the service. I guess it is a problem with versions of the jar file, but I am not sure. Does anybody have an idear, as I am ready to hang myself. I now get the following error message: 2010-05-26 10:41:20 org.apache.struts.chain.commands.ExceptionCatcher postprocess WARNING: Exception from exceptionCommand 'servlet-exception' java.lang.NullPointerException at nc.persistence.PersistenceFacade.closeConnection(PersistenceFacade.java:69) at nc.actions.secure.GetUserNameAction.execute(GetUserNameAction.java:66) at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction .java:58) at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecu teAction.java:67) at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase .java:51) at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191) at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:30 5) at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191) at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequest Processor.java:283) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913) at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449) at javax.servlet.http.HttpServlet.service(HttpServlet.java:627) at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application FilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh ain.java:173) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher. java:672) at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatch er.java:574) at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher .java:499) at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:9 65) at org.apache.jsp.includes.welcome_jsp._jspService(welcome_jsp.java:42) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98) at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:3 31) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:321) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:257) at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application FilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh ain.java:173) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher. java:672) at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatch er.java:574) at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher .java:499) at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:9 65) at org.apache.jsp.includes.header_jsp._jspService(header_jsp.java:62) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98) at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:3 31) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:321) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:257) at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application FilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh ain.java:173) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher. java:672) at
Re: PHP in the same folder of struts 1
Pl. reply On Tue, May 25, 2010 at 2:15 PM, abhishek jain abhishek.netj...@gmail.comwrote: hi friends, I am running struts 1.x and want to place the php code in the same domain as where i am already running struts. I cannt remove either struts or php. How can i do so. I am using apache + Tomcat 5.x thanks -- Thanks and kind Regards, Abhishek jain -- Thanks and kind Regards, Abhishek jain
Re: PHP in the same folder of struts 1
You dont need to bump your posts back up, especially only a day later. If someone knows the answer they will reply. Chris Pl. reply On Tue, May 25, 2010 at 2:15 PM, abhishek jain abhishek.netj...@gmail.comwrote: hi friends, I am running struts 1.x and want to place the php code in the same domain as where i am already running struts. I cannt remove either struts or php. How can i do so. I am using apache + Tomcat 5.x thanks -- Thanks and kind Regards, Abhishek jain -- Thanks and kind Regards, Abhishek jain - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Need Help For Struts2 Debugging
DO any one have other way to do this job done??? Please share their ideas On Tue, May 25, 2010 at 5:46 PM, aum strut aum.str...@gmail.com wrote: Alex i am some what agree.. but i am wondering how the Struts2 Development team is doing this..i am sure they are not following the things as you have mentioned. I am sure that must be some easy way to some one who wants to get knowledge about that internal working structure of struts2 id any one have better idea please do share here On Tue, May 25, 2010 at 5:13 PM, Alex Rodriguez Lopez alo...@flordeutopia.pt wrote: I use to find it impossible to do this... Then I started to use Maven, which can be used to download source code and attach it easily. If you use Eclipse I suggest using M2Eclipse plugin. After you get a Struts2 based project with Maven2 up and running it should be easy to do what you want, download sources and javadocs, and start debugging! Hi All, I am in process to explore internals of Struts2.Can any one suggest me how can i move ahead. All i need to know how framework internally called its different component and for this i guess i need to download the source code but how and what to do next i am confused.. can any one point me to a direction so that i can move ahead. Thanks in advance -Aum - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Additional JSP to render via AJAX
This http://struts2inaction.com/SimpleAjax.html should be a much simpler technique for you. Peace, Scott On Tue, May 25, 2010 at 11:34 AM, Oscar oscar.kalde...@gmail.com wrote: Hi to all, have a good day, i have a doubt about Struts 2.1.8 and AJAX with dojo, using dojo struts tags. My doubt is the next: Suppose that i have a combobox and when i select something in the combobox i want to refresh another combobox using selected value of first combo, via ajax. Then i reference to use struts dojo tags with this: %@ taglib prefix=sx uri=/struts-dojo-tags% And declare this on header (i dont't know very well why i do that but is neccesary) sx:head cache=true / after register a function in the controller: var controller = { refresh : function() {} }; dojo.event.topic.registerPublisher(/refresh, controller, refresh); In my form i declare s:url containing the url that will be called via ajax: s:url var=urlUpdUniMedida id=urlUpdUniMedida value=transTiendasEnvio!updUnisMedidaPrdAjax.action / And put a div whose content will refresh with ajax: sx:div id=divLstUniMedida autoStart=false href=%{urlUpdUniMedida} preload=false listenTopics=/refresh formId=transTiendaEnvioDetForm s:select name=coduni id=coduni list=#request.lstUniMedida listKey=coduni.coduni listValue=coduni.nombre cssStyle=width:320px; / /sx:div And finally, i have to do a second jsp containing the same that contains the div in my first jsp with some code more to set things like cache : %@ taglib prefix=s uri=/struts-tags % % request.setAttribute(decorator, none); response.setHeader(Cache-Control,no-cache); //HTTP 1.1 response.setHeader(Pragma,no-cache); //HTTP 1.0 response.setDateHeader (Expires, 0); //prevents caching at the proxy server % s:select name=coduni id=coduni list=#request.lstUniMedida listKey=coduni.coduni listValue=coduni.nombre cssStyle=width:320px; / My question is: Isn't possible to avoid to do a second jsp? Can't i just use the content of sx:div to rerender when i refresh it via ajax instead render it using a second jsp? Thanks in advance. -- Oscar Calderón SCJP 6 http://www.javahowto.net/ - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
PRG pattern question
Hi Everybody, I would like to ask some advice implementing PRG pattern with struts2 (using 2.0.14). I can easily handle a normal scenario : 1.GET showItem.action?itemId=1 result: showItem.jsp 2. POST saveItem.action result: redirect-action: success?itemId=1 3. GET success?itemId =1 result: success.jsp Browser back works perfectly with this workflow. However if there is a form error at step 2.: 1. GET showItem.action?itemId=1 result: showItem.jsp 2.1 POST saveItem.action result: showItem.jsp (with field/action errors) 2.2 POST saveItem.action (user fixed errors on form) result: redirect-action: success?itemId=1 3. GET success?itemId=1 result: success.jsp In this scenario if the user press back after the 3rd step he gets a page with saveItem.action url (without params) and with a re-submit browser alert. If a form validation error happens I could use a redirect-action result to showItem.action at step 2.1. But that way I'm loosing all the posted form data and the data field/action errors. Alternativelly I could use the same action to show and save, that way url would be showItem after 2.1 but still without url params. I could hack url query string to the reponse but still have re-submit alerts from browser after user press back button because that was a result of a post. What is the best practice to handle form errors with struts if I want to implement Post-Redirect-Get pattern? Thanks, Peter
Re: Struts2+Spring2+Interceptor+Invalid action class configuration that references an unknown class named
Thanks Wes for reply. I figured out that we can only forward to jsp not to action from interceptor. So Now I am forwarding to jsp from interceptor and it's working fine. Below is my changed code in struts.xml and LoginInterceptor.java. p[code] ?xml version=1.0 encoding=UTF-8 ? !DOCTYPE struts PUBLIC -//Apache Software Foundation//DTD Struts Configuration 2.0//EN http://struts.apache.org/dtds/struts-2.0.dtd; struts constant name=struts.objectFactory value=spring / constant name=struts.action.extension value=do/ constant name=struts.objectFactory.spring.autoWire value=AUTOWIRE_BY_NAME/ !-- Add packages here -- package name=dafault extends=struts-default result-types result-type name=tiles class=org.apache.struts2.views.tiles.TilesResult / /result-types interceptors interceptor name=loginInterceptor class=com.ncr.framework.interceptor.LoginInterceptor/ interceptor-stack name=capabilityStack interceptor-ref name=defaultStack/ interceptor-ref name=loginInterceptor/ /interceptor-stack /interceptors default-interceptor-ref name=capabilityStack/ global-results result name=loginPage type=tilespage.Login/result /global-results action name=logon class=loginAction method=execute result name=success type=tilespage.Login/result /action /package /struts LoginInterceptor.java public class LoginInterceptor extends AbstractInterceptor { public String intercept(ActionInvocation invocation) throws Exception { ActionContext context = invocation.getInvocationContext(); MapString, Object contextMap = context.getContextMap(); HttpServletRequestWrapper request = (HttpServletRequestWrapper) contextMap .get(HTTP_REQUEST); synchronized (request) { ThreadContext.setRequest(request); UserInfo userInfo = UserContext.getCurrentUserInfo(); if (userInfo == null !authenticate.equals(contextMap.get(ACTION_NAME))) { return logonPage; } return invocation.invoke(); } }} p Regards, Devendra Wes Wannemacher wrote: On Tue, May 25, 2010 at 8:47 AM, rocks devendra_tiwari12...@yahoo.com wrote: Martin, I haven't get any response from Wes [:(]. Sorry I didn't notice that I was being called out directly :)... I was out of town, in a magical place that my children really enjoyed, but unfortunately charged $9.99 / day for internet access[1] I am still trying to catch up on a lot of email (it's amazing how far behind you can get on email when you're cut off for only a few days). I haven't read your message thoroughly, and I can't promise that I will right away. But, I do have an example that might help[2]. If it doesn't help, post back here, there are tons of users on this list combining struts2, spring and hibernate. If you didn't get many responses before, you probably haven't posted enough details or the description of your problem was too vague. [1] http://disneyworld.disney.go.com/resorts/contemporary-resort/services-amenities/ [2] http://code.google.com/p/struts2inpractice/source/browse/#svn/trunk/ch04ex01 (check the ch04ex01 project) -Wes -- Wes Wannemacher Head Engineer, WanTii, Inc. Need Training? Struts, Spring, Maven, Tomcat... Ask me for a quote! - 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%2BSpring2%2BInterceptor%2BInvalid-action-class-configuration-that-references-an-unknown-class-named-tp28636590p28680342.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
PersistenceFacade
Hi. I have used the following code with struts 1.2x and it works just fine. Now I have upgraded to Struts 1.3.10. Now I get the following error when I try to login to my Struts app. Can anybody point me in the right direction. Soren, DK The Code: package nc.persistence; import java.sql.Connection; import java.sql.SQLException; import javax.servlet.http.HttpServlet; import java.sql.DriverManager; public class PersistenceFacade { //--- fields -// public static final String CONNECTION_DRIVER = org.gjt.mm.mysql.Driver; public static final String CONNECTION_USER = username; public static final String CONNECTION_PASS = password; public static final String CONNECTION_URL= url; static { try { Class.forName(CONNECTION_DRIVER); } catch (ClassNotFoundException ex) { ex.printStackTrace(); } } private String connectionUrl = null; private String connectionUser = null; private String connectionPass = null; // constructors ---// //public PersistenceFacade() {} public PersistenceFacade(HttpServlet servlet) { connectionUser = servlet.getInitParameter(CONNECTION_USER); connectionPass = servlet.getInitParameter(CONNECTION_PASS); connectionUrl = servlet.getInitParameter(CONNECTION_URL); } //- public methods ---// public Connection getConnection() throws SQLException { if(connectionUser == null) { throw new SQLException(Missing parameter +CONNECTION_USER); } else if(connectionPass == null) { throw new SQLException(Missing parameter +CONNECTION_PASS); } else if(connectionUrl == null) { throw new SQLException(Missing parameter +CONNECTION_URL); } return DriverManager.getConnection( connectionUrl, connectionUser, connectionPass ); } public void closeConnection(Connection conn) { try { if(!conn.isClosed()) { conn.close(); } } catch (SQLException ex) { ex.printStackTrace(); } } // private methods --// }
Re: PersistenceFacade
Hi, You would need to post your strack trace and where the problem happens. Chris Hi. I have used the following code with struts 1.2x and it works just fine. Now I have upgraded to Struts 1.3.10. Now I get the following error when I try to login to my Struts app. Can anybody point me in the right direction. Soren, DK The Code: package nc.persistence; import java.sql.Connection; import java.sql.SQLException; import javax.servlet.http.HttpServlet; import java.sql.DriverManager; public class PersistenceFacade { //--- fields -// public static final String CONNECTION_DRIVER = org.gjt.mm.mysql.Driver; public static final String CONNECTION_USER = username; public static final String CONNECTION_PASS = password; public static final String CONNECTION_URL= url; static { try { Class.forName(CONNECTION_DRIVER); } catch (ClassNotFoundException ex) { ex.printStackTrace(); } } private String connectionUrl = null; private String connectionUser = null; private String connectionPass = null; // constructors ---// //public PersistenceFacade() {} public PersistenceFacade(HttpServlet servlet) { connectionUser = servlet.getInitParameter(CONNECTION_USER); connectionPass = servlet.getInitParameter(CONNECTION_PASS); connectionUrl = servlet.getInitParameter(CONNECTION_URL); } //- public methods ---// public Connection getConnection() throws SQLException { if(connectionUser == null) { throw new SQLException(Missing parameter +CONNECTION_USER); } else if(connectionPass == null) { throw new SQLException(Missing parameter +CONNECTION_PASS); } else if(connectionUrl == null) { throw new SQLException(Missing parameter +CONNECTION_URL); } return DriverManager.getConnection( connectionUrl, connectionUser, connectionPass ); } public void closeConnection(Connection conn) { try { if(!conn.isClosed()) { conn.close(); } } catch (SQLException ex) { ex.printStackTrace(); } } // private methods --// } - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
SV: PersistenceFacade
Of course. Here it comes 75203 [http-80-Processor24] ERROR org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/hb].[jsp] - Servlet.service() for servlet jsp threw exception java.lang.NullPointerException at nc.persistence.PersistenceFacade.closeConnection(PersistenceFacade.java:69) at nc.actions.secure.GetUserNameAction.execute(GetUserNameAction.java:66) at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction .java:58) at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecu teAction.java:67) at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase .java:51) at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191) at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:30 5) at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191) at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequest Processor.java:283) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913) at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449) at javax.servlet.http.HttpServlet.service(HttpServlet.java:689) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application FilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh ain.java:173) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher. java:672) at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatch er.java:574) at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher .java:499) at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:9 65) at org.apache.jsp.includes.welcome_jsp._jspService(welcome_jsp.java:42) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:3 31) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:321) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:257) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application FilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh ain.java:173) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher. java:672) at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatch er.java:574) at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher .java:499) at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:9 65) at org.apache.jsp.includes.header_jsp._jspService(header_jsp.java:62) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:3 31) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:321) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:257) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application FilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh ain.java:173) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher. java:672) at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatch er.java:574) at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher .java:499) at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:9 65) at org.apache.jsp.secure.errorpage_jsp._jspService(errorpage_jsp.java:86) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:3 31) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:321) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:257) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application FilterChain.java:252) at
RE: PersistenceFacade
i would strongly suggest you re-consider *not* publishing the username/password to your database.. in fact changing the username/password asap (if someone can ping your mailing address IP and append 3306 they can might be able access your database) suppose: your host is NewOrleansCommandCenterHost your DB name is DeepWaterHorizonDB your username is TonyHayward your password is PlugTheHole then the dbUrl = //jdbc:msql://NewOrleansCommandCenterHost:3306/DeepWaterHorizonDB?user=TonyHaywardpassword=PlugTheHole //and you could connect in using a thin Type4 driver with java.util.Properties urlProps = new com.mysql.jdbc.NonRegisteringDriver().parseURL(dbUrl, null); something to think about Martin Gainty __ Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen. Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni. From: ch...@chrismiles.org Date: Wed, 26 May 2010 09:39:54 -0400 Subject: Re: PersistenceFacade To: user@struts.apache.org Hi, You would need to post your strack trace and where the problem happens. Chris Hi. I have used the following code with struts 1.2x and it works just fine. Now I have upgraded to Struts 1.3.10. Now I get the following error when I try to login to my Struts app. Can anybody point me in the right direction. Soren, DK The Code: package nc.persistence; import java.sql.Connection; import java.sql.SQLException; import javax.servlet.http.HttpServlet; import java.sql.DriverManager; public class PersistenceFacade { //--- fields -// public static final String CONNECTION_DRIVER = org.gjt.mm.mysql.Driver; public static final String CONNECTION_USER = username; public static final String CONNECTION_PASS = password; public static final String CONNECTION_URL = url; static { try { Class.forName(CONNECTION_DRIVER); } catch (ClassNotFoundException ex) { ex.printStackTrace(); } } private String connectionUrl = null; private String connectionUser = null; private String connectionPass = null; // constructors ---// //public PersistenceFacade() {} public PersistenceFacade(HttpServlet servlet) { connectionUser = servlet.getInitParameter(CONNECTION_USER); connectionPass = servlet.getInitParameter(CONNECTION_PASS); connectionUrl = servlet.getInitParameter(CONNECTION_URL); } //- public methods ---// public Connection getConnection() throws SQLException { if(connectionUser == null) { throw new SQLException(Missing parameter +CONNECTION_USER); } else if(connectionPass == null) { throw new SQLException(Missing parameter +CONNECTION_PASS); } else if(connectionUrl == null) { throw new SQLException(Missing parameter +CONNECTION_URL); } return DriverManager.getConnection( connectionUrl, connectionUser, connectionPass ); } public void closeConnection(Connection conn) { try { if(!conn.isClosed()) { conn.close(); } } catch (SQLException ex) { ex.printStackTrace(); } } // private methods --// } - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org _ The New Busy is not the too busy. Combine all your e-mail accounts with Hotmail. http://www.windowslive.com/campaign/thenewbusy?tile=multiaccountocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_4
Re: PRG pattern question
I don't believe there is any canned best practice solution for this issue. My apps do the same thing; on a successful post I redirect to a get, on a validation error they simply forward back to the jsp so as to preserve the input data. It is possible to manually include all your form fields data as parameters on the redirect but that is very tedious and error prone and on large forms you may hit url size limitations. For me I've just accepted that on a validation fail the back button will be un-friendly. If you want to take the route of passing all your fields back on the redirect when validation fails you could probably write a custom result type that would automatically append all the request parameters to the redirect url. I don't think this would be too hard to write. Your only other option would be to stuff the data into the session and then pull in out on the next get. I would not recommend this approach, it appears to me to be very error prone as there is no guarantee that the next request will be the one that wants the data or that the request will ever happen. You could end up filling up the session with data that never get retrieved. Just seems like a poor design. On Wed, May 26, 2010 at 8:45 AM, szerintedmi szerinte...@gmail.com wrote: Hi Everybody, I would like to ask some advice implementing PRG pattern with struts2 (using 2.0.14). I can easily handle a normal scenario : 1.GET showItem.action?itemId=1 result: showItem.jsp 2. POST saveItem.action result: redirect-action: success?itemId=1 3. GET success?itemId =1 result: success.jsp Browser back works perfectly with this workflow. However if there is a form error at step 2.: 1. GET showItem.action?itemId=1 result: showItem.jsp 2.1 POST saveItem.action result: showItem.jsp (with field/action errors) 2.2 POST saveItem.action (user fixed errors on form) result: redirect-action: success?itemId=1 3. GET success?itemId=1 result: success.jsp In this scenario if the user press back after the 3rd step he gets a page with saveItem.action url (without params) and with a re-submit browser alert. If a form validation error happens I could use a redirect-action result to showItem.action at step 2.1. But that way I'm loosing all the posted form data and the data field/action errors. Alternativelly I could use the same action to show and save, that way url would be showItem after 2.1 but still without url params. I could hack url query string to the reponse but still have re-submit alerts from browser after user press back button because that was a result of a post. What is the best practice to handle form errors with struts if I want to implement Post-Redirect-Get pattern? Thanks, Peter - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: SV: PersistenceFacade
This appears not to be a Struts problem, just a coincidence as it clearly states the problem is a null pointer exception, but I will point you to an partial answer anyway. When closing a database connection like that you should always check that it is not null before closing it. Why it is null I could not tell you. You should step through your code and make sure it is doing every it should be before you call the close. If yuo are not obtaining a valid connection I suggest starting there. You should probably be closing your database within a finaly block as well. Chris Of course. Here it comes 75203 [http-80-Processor24] ERROR org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/hb].[jsp] - Servlet.service() for servlet jsp threw exception java.lang.NullPointerException at nc.persistence.PersistenceFacade.closeConnection(PersistenceFacade.java:69) public void closeConnection(Connection conn) { try { if(!conn.isClosed()) { conn.close(); } } catch (SQLException ex) { - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
SV: SV: PersistenceFacade
I will do that. Thanks. But what I dont understand is that I have not changed the PersistenceFacade.java and the classes that uses it has not been changed either. I have only upgraded Struts and the dependencies. Soren -Oprindelig meddelelse- Fra: ch...@chrismiles.org [mailto:ch...@chrismiles.org] Sendt: 26. maj 2010 17:15 Til: Struts Users Mailing List Emne: Re: SV: PersistenceFacade This appears not to be a Struts problem, just a coincidence as it clearly states the problem is a null pointer exception, but I will point you to an partial answer anyway. When closing a database connection like that you should always check that it is not null before closing it. Why it is null I could not tell you. You should step through your code and make sure it is doing every it should be before you call the close. If yuo are not obtaining a valid connection I suggest starting there. You should probably be closing your database within a finaly block as well. Chris Of course. Here it comes 75203 [http-80-Processor24] ERROR org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/hb].[jsp] - Servlet.service() for servlet jsp threw exception java.lang.NullPointerException at nc.persistence.PersistenceFacade.closeConnection(PersistenceFacade.java:69) public void closeConnection(Connection conn) { try { if(!conn.isClosed()) { conn.close(); } } catch (SQLException ex) { - 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: SV: SV: PersistenceFacade
Struts is only a facade round the existing JSP and servlet technologies so I cant personally see them causing the problem (prove me wrong?). Coincidences happen I am afraid (to myself included). Good luck debugging your code. Chris I will do that. Thanks. But what I dont understand is that I have not changed the PersistenceFacade.java and the classes that uses it has not been changed either. I have only upgraded Struts and the dependencies. Soren -Oprindelig meddelelse- Fra: ch...@chrismiles.org [mailto:ch...@chrismiles.org] Sendt: 26. maj 2010 17:15 Til: Struts Users Mailing List Emne: Re: SV: PersistenceFacade This appears not to be a Struts problem, just a coincidence as it clearly states the problem is a null pointer exception, but I will point you to an partial answer anyway. When closing a database connection like that you should always check that it is not null before closing it. Why it is null I could not tell you. You should step through your code and make sure it is doing every it should be before you call the close. If yuo are not obtaining a valid connection I suggest starting there. You should probably be closing your database within a finaly block as well. Chris Of course. Here it comes 75203 [http-80-Processor24] ERROR org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/hb].[jsp] - Servlet.service() for servlet jsp threw exception java.lang.NullPointerException at nc.persistence.PersistenceFacade.closeConnection(PersistenceFacade.java:69) public void closeConnection(Connection conn) { try { if(!conn.isClosed()) { conn.close(); } } catch (SQLException ex) { - 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
SV: SV: SV: PersistenceFacade
I feel like such an ass. During the upgrade I must have deleted an initparam from the struts-config, and that was why the PersistenceFacade didnt work. Sorry for wasting your time, but thanks for the effort. Soren -Oprindelig meddelelse- Fra: ch...@chrismiles.org [mailto:ch...@chrismiles.org] Sendt: 26. maj 2010 17:24 Til: Struts Users Mailing List Emne: Re: SV: SV: PersistenceFacade Struts is only a facade round the existing JSP and servlet technologies so I cant personally see them causing the problem (prove me wrong?). Coincidences happen I am afraid (to myself included). Good luck debugging your code. Chris I will do that. Thanks. But what I dont understand is that I have not changed the PersistenceFacade.java and the classes that uses it has not been changed either. I have only upgraded Struts and the dependencies. Soren -Oprindelig meddelelse- Fra: ch...@chrismiles.org [mailto:ch...@chrismiles.org] Sendt: 26. maj 2010 17:15 Til: Struts Users Mailing List Emne: Re: SV: PersistenceFacade This appears not to be a Struts problem, just a coincidence as it clearly states the problem is a null pointer exception, but I will point you to an partial answer anyway. When closing a database connection like that you should always check that it is not null before closing it. Why it is null I could not tell you. You should step through your code and make sure it is doing every it should be before you call the close. If yuo are not obtaining a valid connection I suggest starting there. You should probably be closing your database within a finaly block as well. Chris Of course. Here it comes 75203 [http-80-Processor24] ERROR org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/hb].[jsp] - Servlet.service() for servlet jsp threw exception java.lang.NullPointerException at nc.persistence.PersistenceFacade.closeConnection(PersistenceFacade.java:69) public void closeConnection(Connection conn) { try { if(!conn.isClosed()) { conn.close(); } } catch (SQLException ex) { - 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: PRG pattern question
If you search the forum, someone posted an Interceptor (quite a while ago) that saves the Action/Field Errors/Messages in the Session so that they will survive a redirect. It could easily be extended to do what you require. (*Chris*) On Wed, May 26, 2010 at 5:45 AM, szerintedmi szerinte...@gmail.com wrote: Hi Everybody, I would like to ask some advice implementing PRG pattern with struts2 (using 2.0.14). I can easily handle a normal scenario : 1.GET showItem.action?itemId=1 result: showItem.jsp 2. POST saveItem.action result: redirect-action: success?itemId=1 3. GET success?itemId =1 result: success.jsp Browser back works perfectly with this workflow. However if there is a form error at step 2.: 1. GET showItem.action?itemId=1 result: showItem.jsp 2.1 POST saveItem.action result: showItem.jsp (with field/action errors) 2.2 POST saveItem.action (user fixed errors on form) result: redirect-action: success?itemId=1 3. GET success?itemId=1 result: success.jsp In this scenario if the user press back after the 3rd step he gets a page with saveItem.action url (without params) and with a re-submit browser alert. If a form validation error happens I could use a redirect-action result to showItem.action at step 2.1. But that way I'm loosing all the posted form data and the data field/action errors. Alternativelly I could use the same action to show and save, that way url would be showItem after 2.1 but still without url params. I could hack url query string to the reponse but still have re-submit alerts from browser after user press back button because that was a result of a post. What is the best practice to handle form errors with struts if I want to implement Post-Redirect-Get pattern? Thanks, Peter
action chain tag
There is a action tag like this in my application. What happens here? whether the request goes to the render action or the page product_main.jsp is displayed? How to find this? Thanks action name=viewedit_ajax com.tebs.augusta.web.actions.product.ProductAction_viewedit result type=chainrender/result result name=inputproduct_main.jsp/result /action -- View this message in context: http://old.nabble.com/action-chain-tag-tp28689353p28689353.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
Migration problem from 2.0.x to 2.1.6
Hi, I got a Servlet which doesn't extends to an action. Looking for a work around without extending the servlet to an action because it's already has extends another class. Any ideas ? I'm getting this in the logs 2010-05-27 13:46:44,962 [btpool0-8] WARN org.apache.struts2.dispatcher.Dispatcher - Could not find action or result There is no Action mapped for namespace / and action name repository/internal/. - [unknown location] at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:177) at org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61) at org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39) at com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:47) at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:458) - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org