validator + pre processing before foward
Hi all, I am using struts validator. I have a form that needs a object in the request to populate some bean:write outputs and some form input elements values. When I submit this form to an action mapping that has validate=true and the validation is not successfull, the user returns to the original page with the form, but my object is not in the request anymore, naturally. Is there a way to use validator and still be able to set a object in the request (or do something) before the user is forwarded to getInputForward()?? For now, I have disabled validator for this action and I am validating inside my action execute() method. (I use dyna action forms, that´s why I don´t use form.validate() ). Any suggestion?? tks Felipe - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
client side validation - DynaValidatorActionForm
Hi, I have a Form Bean of type DynaValidatorActionForm that is shared among multiple actions. I set validation.xml with something like the code bellow. But when I tried to enable client side validation placing html:javascript and adding onsubmit to html:form I can´t get it to work What I see is that having strus-config´s action-mapping´s path in the name attribute of validation.xml form element, it causes the javascript validate function to be created as something with / character in the middle, causing the problem. Am I doing something wrong?? validation.xml: formset form name=/createAddress field property=city depends=required arg0 key=prompt.city/ /field /form ... /formset Javascript generated by Validator: script type=text/javascript language=Javascript1.1 !-- Begin var bCancel = false; function validate/createAddress(form) { if (bCancel) return true; else return validateRequired(form); } ... html:form : . onsubmit=return validate/createAddress(this) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RES: from Action to Facade: simple attributes or Business Objects
Tks for the reply Tim. I now see the advantages of my latter case. But being my form bean a DynaActionForm, can I still use BeanUtils.populate()?? If not, what would be the alternative? Tks Felipe -Mensagem original- De: Tim Lucia [mailto:[EMAIL PROTECTED] Enviada em: domingo, 7 de dezembro de 2003 10:54 Para: 'Struts Users Mailing List' Assunto: RE: from Action to Facade: simple attributes or Business Objects The philosphy is that the Actions (controller) move bean properties from form bean(s) into business beans, and pass the business bean into a business object to perform an operation. I.e., the action should contain all of (and only) the web-specific portion of the application. I.e., the latter case in your example. Think about what happens if you add a property? How many places do you need to change it? One less (at least) in the patter case. You can (typically) use BeanUtils.populate() do move all properties in one fell swoop. Tim Lucia -Original Message- From: Felipe Nascimento [mailto:[EMAIL PROTECTED] Sent: Saturday, December 06, 2003 10:15 PM To: [EMAIL PROTECTED] Subject: from Action to Facade: simple attributes or Business Objects Hi, I was wondering what do experts recommend: inside Action´s execute method we should pass the attributes to the Facade or create the business objects in the Action and pass them on? 1) execute(){ Facade.addUser(name, surname, login, birth, ); } or 2) execute(){ User u = new User(); u.setName(name); u.setSurname(surname); ..others setters. Facade.addUser(u); } Tks Felipe - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.547 / Virus Database: 340 - Release Date: 2/12/2003 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.547 / Virus Database: 340 - Release Date: 2/12/2003 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RES: How to detect that session has expired ?
http://java.sun.com/products/servlet/Filters.html http://www.javaworld.com/javaworld/jw-06-2001/jw-0622-filters-p2.html http://securityfilter.sourceforge.net/ -Mensagem original- De: Baljinder Singh [mailto:[EMAIL PROTECTED] Enviada em: domingo, 7 de dezembro de 2003 13:16 Para: Struts Users Mailing List Assunto: RE: How to detect that session has expired ? Ashish, Can you provide me with more details about how to use Servlet Filter ? Thanks, BS -Original Message- From: Ashish Kulkarni [mailto:[EMAIL PROTECTED] Sent: Sunday, December 07, 2003 9:15 PM To: Struts Users Mailing List Subject: Re: How to detect that session has expired ? HI if u are using servelt 2.3 , then u can use servelt filter, in this filter u can have logic to check session before each request so u dont need to add any code in jsp or action class Ashish --- Ed Dowgiallo [EMAIL PROTECTED] wrote: Inheritance is your friend. If you need processing common to all your Action classes, extend the Struts Action class. Ed - Original Message - From: Baljinder Singh [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Sunday, December 07, 2003 5:41 AM Subject: RE: How to detect that session has expired ? Thomas, You mean to say that I should put this logic in ActionClass. But then I would need to put it in all my Action Classes. Can't I do something similar in JSP because then I would do it in a common JSP which is included in all other JSPs of mine. Or is there a common solution which can take care all Action Classes. Thanks, BS -Original Message- From: Thomas Cornet [mailto:[EMAIL PROTECTED] Sent: Sunday, December 07, 2003 2:17 PM To: Struts Users Mailing List Subject: Re: How to detect that session has expired ? When a session restarts, its context is empty, so all objects stored in the session context have disappeared. To detect if a session has restarted, you need first to store an object in the session context, then each time you need to know if the session has restarted, you test its presence in the context. If it is not there anymore, then the session has restarted. At 08:09 07/12/2003, you wrote: Hi All, How can I detect that session has expired and so throw the user out of system after showing him a message that Your session has expired. Please login again. Thanks, BS - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.547 / Virus Database: 340 - Release Date: 2/12/2003 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.547 / Virus Database: 340 - Release Date: 2/12/2003 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
from Action to Facade: simple attributes or Business Objects
Hi, I was wondering what do experts recommend: inside Action´s execute method we should pass the attributes to the Facade or create the business objects in the Action and pass them on? 1) execute(){ Facade.addUser(name, surname, login, birth, ); } or 2) execute(){ User u = new User(); u.setName(name); u.setSurname(surname); ..others setters. Facade.addUser(u); } Tks Felipe - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RES: Subclassing ActionServlet
A simple way that I use do go: Super Action class, like: UserMustBeLoggedAction{ execute(attribs){ verify session stuff if ok - myExecute(attribs); else return ActionForward; } abstract myExecute(attribs); } NewAction extends UserMustBeLoggedAction{ myExecute(){ .. } } What do experts recommend?? Regards Felipe -Mensagem original- De: Gopal Venkata Achi [mailto:[EMAIL PROTECTED] Enviada em: quinta-feira, 4 de dezembro de 2003 18:55 Para: Struts Users Mailing List Assunto: RE: Subclassing ActionServlet Hi I have come across a plug-in for Struts, that is called as SAIF (Struts Action Invocation Framework), which enables us to write a pre-action and post action methods. You can use PreAction method for doing all the session authentication, etc., I did not really use this, but the features are available at : http://struts.sourceforge.net/saif/ http://struts.sourceforge.net/saif/ Any thoughts on this. Regards, Gopal -Original Message- From: Fullam, Jonathan [mailto:[EMAIL PROTECTED] Sent: Thu 12/4/2003 1:07 PM To: 'Struts Users Mailing List' Cc: Subject: Subclassing ActionServlet All, I need to check the Session for an authenticated user before most requests. To do this I subclassed ActionServlet and only call super(request, response) upon verification that authenticated user is in the Session. if (request.getRequestURI().endsWith(welcome.do) | request.getRequestURI().endsWith(logon.do) | request.getRequestURI().endsWith(html)) { super.process(request, response); } else if (request.getSession().getAttribute(USER) == null) { //Forward to login page response.sendRedirect(/welcome.do); } I also know about the ability to subclass the RequestProcessor and providing my own implementation of the processPreprocess method to accomplish the same thing. Does anybody know of any serious disadvantages or side effects of subclassing the ActionServlet class rather than the RequestProcessor class. --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.547 / Virus Database: 340 - Release Date: 2/12/2003 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.547 / Virus Database: 340 - Release Date: 2/12/2003 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RES: RES: Subclassing ActionServlet
Ok. Nice to know about filters. I have found this SecurityFilter Projetct at sourceforge. http://securityfilter.sourceforge.net/ Has anyone used it? Tks Felipe -Mensagem original- De: Guido García Bernardo [mailto:[EMAIL PROTECTED] Enviada em: sexta-feira, 5 de dezembro de 2003 08:42 Para: Struts Users Mailing List Assunto: Re: RES: Subclassing ActionServlet This way you can't extend other 'struts core actions' (Dispatch, Lookup...). I think a better way may be: - Using a filter (servlet 2.3) in order to pre and post process the request - Extending RequestDispatcher Regards, Guido. PD. I am not sure, but i think you can find a discussion about that in Struts in Action. Felipe Nascimento wrote: A simple way that I use do go: Super Action class, like: UserMustBeLoggedAction{ execute(attribs){ verify session stuff if ok - myExecute(attribs); else return ActionForward; } abstract myExecute(attribs); } NewAction extends UserMustBeLoggedAction{ myExecute(){ .. } } What do experts recommend?? Regards Felipe -Mensagem original- De: Gopal Venkata Achi [mailto:[EMAIL PROTECTED] Enviada em: quinta-feira, 4 de dezembro de 2003 18:55 Para: Struts Users Mailing List Assunto: RE: Subclassing ActionServlet Hi I have come across a plug-in for Struts, that is called as SAIF (Struts Action Invocation Framework), which enables us to write a pre-action and post action methods. You can use PreAction method for doing all the session authentication, etc., I did not really use this, but the features are available at : http://struts.sourceforge.net/saif/ http://struts.sourceforge.net/saif/ Any thoughts on this. Regards, Gopal -Original Message- From: Fullam, Jonathan [mailto:[EMAIL PROTECTED] Sent: Thu 12/4/2003 1:07 PM To: 'Struts Users Mailing List' Cc: Subject: Subclassing ActionServlet All, I need to check the Session for an authenticated user before most requests. To do this I subclassed ActionServlet and only call super(request, response) upon verification that authenticated user is in the Session. if (request.getRequestURI().endsWith(welcome.do) | request.getRequestURI().endsWith(logon.do) | request.getRequestURI().endsWith(html)) { super.process(request, response); } else if (request.getSession().getAttribute(USER) == null) { //Forward to login page response.sendRedirect(/welcome.do); } I also know about the ability to subclass the RequestProcessor and providing my own implementation of the processPreprocess method to accomplish the same thing. Does anybody know of any serious disadvantages or side effects of subclassing the ActionServlet class rather than the RequestProcessor class. --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.547 / Virus Database: 340 - Release Date: 2/12/2003 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.547 / Virus Database: 340 - Release Date: 2/12/2003 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Guido García Bernardo - [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] Tfn. +34 983 54 89 08 IT DEUSTO http://www.itdeusto.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.547 / Virus Database: 340 - Release Date: 2/12/2003 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.547 / Virus Database: 340 - Release Date: 2/12/2003 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: RES: recursive tiles
I´ll try that tks a lot. Felipe - Original Message - From: Adam Hardy [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Tuesday, December 02, 2003 8:18 AM Subject: Re: RES: recursive tiles Basically subbody1 2 are just extra tiles? Try this - your tiles-defs.xml: definition name=tile.foo extends=mainTemplate put name=body value=/foo.jsp / put name=subbody1 value=/foo2.jsp / put name=subbody2 value=/minifoo.jsp / /definition in your mainTemplate.jsp, you would have: tiles:get name=body put name=subbody1 beanName=subbody1/ put name=subbody2 beanName=subbody2/ /tiles:get in your foo.jsp you would have: tiles:insert attribute=subbody1 / I haven't actually done tiles to 3 levels deep, just 2, but I've never heard of any problems with it. Adam On 12/01/2003 08:52 PM Felipe Nascimento wrote: That is my what I don´t know. I don´t know if I have to define the two components subbody1 and 2 in my foo.jsp (body file), or in my tiles-defs.xml. I suppose it is better in my tiles-defs.xml. So in foo.jsp I could only get the values and that´s it. Could you give a simple example of the definition in tiles-defs.xml, the getting and putting in foo.jsp? In your code bellow (put name=subbody1 value=subbody1/) where is defined subbody1? The name is the name in tiles-defs? And value is the jsp page? Tks a lot Felipe -Mensagem original- De: Adam Hardy [mailto:[EMAIL PROTECTED] Enviada em: segunda-feira, 1 de dezembro de 2003 08:41 Para: Struts Users Mailing List Assunto: Re: recursive tiles Hi Felipe, not quite sure exactly what you want to do - where do you expect subbody1 subbody2 to come from? If you are defining them in your tiles-defs.xml then you need to pass them as variables explicitly to 'body' in your maintemplate: tiles:get name=body put name=subbody1 value=subbody1/ /tiles:get HTH Adam On 12/01/2003 06:41 AM Felipe Nascimento wrote: Hi, I have the following definition in my tiles-defs.xml: definition name=mainTemplate path=/mainTemplate.jsp put name=title value=${title} / put name=header value=/components/header.jsp / put name=menu value=/componentes/menu.jsp / put name=body value= / put name=footer value=/componentes/footer.jsp / /definition definition name=tile.foo extends=mainTemplate put name=body value=/foo.jsp / /definition In mainTemplate.jsp I have: tiles:get name=body/ What I want is to put more variable content in my foo.jsp, the same way I put in mainTemplate.jsp something like foo.jsp: tiles:get name=subBody1/ tiles:get name=subBody2/ -- struts 1.1 + tomcat 5.0.14 + java 1.4.2 Linux 2.4.20 RH9 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RES: recursive tiles
That is my what I don´t know. I don´t know if I have to define the two components subbody1 and 2 in my foo.jsp (body file), or in my tiles-defs.xml. I suppose it is better in my tiles-defs.xml. So in foo.jsp I could only get the values and that´s it. Could you give a simple example of the definition in tiles-defs.xml, the getting and putting in foo.jsp? In your code bellow (put name=subbody1 value=subbody1/) where is defined subbody1? The name is the name in tiles-defs? And value is the jsp page? Tks a lot Felipe -Mensagem original- De: Adam Hardy [mailto:[EMAIL PROTECTED] Enviada em: segunda-feira, 1 de dezembro de 2003 08:41 Para: Struts Users Mailing List Assunto: Re: recursive tiles Hi Felipe, not quite sure exactly what you want to do - where do you expect subbody1 subbody2 to come from? If you are defining them in your tiles-defs.xml then you need to pass them as variables explicitly to 'body' in your maintemplate: tiles:get name=body put name=subbody1 value=subbody1/ /tiles:get HTH Adam On 12/01/2003 06:41 AM Felipe Nascimento wrote: Hi, I have the following definition in my tiles-defs.xml: definition name=mainTemplate path=/mainTemplate.jsp put name=title value=${title} / put name=header value=/components/header.jsp / put name=menu value=/componentes/menu.jsp / put name=body value= / put name=footer value=/componentes/footer.jsp / /definition definition name=tile.foo extends=mainTemplate put name=body value=/foo.jsp / /definition In mainTemplate.jsp I have: tiles:get name=body/ What I want is to put more variable content in my foo.jsp, the same way I put in mainTemplate.jsp something like foo.jsp: tiles:get name=subBody1/ tiles:get name=subBody2/ -- struts 1.1 + tomcat 5.0.14 + java 1.4.2 Linux 2.4.20 RH9 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.544 / Virus Database: 338 - Release Date: 25/11/2003 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.544 / Virus Database: 338 - Release Date: 25/11/2003 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
recursive tiles
Hi, I have the following definition in my tiles-defs.xml: definition name=mainTemplate path=/mainTemplate.jsp put name=title value=${title} / put name=header value=/components/header.jsp / put name=menu value=/componentes/menu.jsp / put name=body value= / put name=footer value=/componentes/footer.jsp / /definition definition name=tile.foo extends=mainTemplate put name=body value=/foo.jsp / /definition In mainTemplate.jsp I have: tiles:get name=body/ What I want is to put more variable content in my foo.jsp, the same way I put in mainTemplate.jsp something like foo.jsp: tiles:get name=subBody1/ tiles:get name=subBody2/ I tried some things here, but I always get a white screen in the body region. (and I am not forgetting taglib in the beginning of jsp file). Tks Felipe - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
ProcessAction and RESULT attribute
Hi, I really needed to know how ProcessAction acts. Struts In Action says The ProcessAction will than just save the ResultList collection in request scope, using the default RESULT attribute name, and forward control to success.. The problem is that i am not getting a RESULT attribute in my jsp. Please, anyone Tks Felipe --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.538 / Virus Database: 333 - Release Date: 10/11/2003 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
ExceptionHandler
Hi, I am trying to use the exception handling from default struts ExceptionHandler. I declared this inside a action tag in struts config.xml : exception type=br.com.tatil.tatilj.exception.FaseJaExisteException key=tatilJ.exception.faseJaExisteException path=tiles.erro / 1- I was always getting the white screen. So I put the input property in the action tag. It started going to the input I declared, but what I wanted was to go to the path declared above (tiles one). 2- Beside, I get: [ServletException in:/componentes/mensagens.jsp] Cannot find bean error in any scope' . Any clue??? Tks a lot, Felipe. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: ExceptionHandler
Yes it is. I am from Brazil. It is in portuguese. Tks. - Original Message - From: Rick Reumann [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Monday, November 17, 2003 2:39 AM Subject: Re: ExceptionHandler Felipe Nascimento wrote: key=tatilJ.exception.faseJaExisteException path=tiles.erro / Is the tiles definition really called tiles.erro and not tiles.error ? -- Rick - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
ProcessBeanBase subclass
Hi, I have a ProcessBeanBase subclass that is my business object. I implemented a JUnit test to see why I was getting the final Response Cannot create iterator for this collection' in my browser screen, and I always fall in that ClassCastException. Need help to understand why. Tks! Here is my business object, that extends Empresa that extends ProcessBeanBase : public class BuscaEmpresasComProjeto extends Empresa{ public final String LEGENDA = Empresas com Projetos.; public Object execute(Object parametros) throws Exception{ super.execute(parametros); ResultList list = new ResultListBase( TatilFacade.getInstance().getEmpresasComProjeto(this) ); list.setLegend(LEGENDA); return new ProcessResultBase(list); } } Here is the test: /* * Test for Object execute(Object) */ final public void testExecuteObject() { /** * Subclass of ProcessBeanBase. * Implements execute(Object) method; */ BuscaEmpresasComProjeto busca = new BuscaEmpresasComProjeto(); ArrayList c = null; try { c = (ArrayList) busca.execute(null); } catch (ClassCastException ex){ Assert.fail(Nao conseguiu fazer o cast de Object para ArrayList, vinda de BuscaEmpresasComProjeto.execute() ); ex.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } Assert.assertTrue( c.size() 0); Iterator i = c.iterator(); Assert.assertNotNull(i); } Felipe