Re: Struts2 + Spring/Hibernate
Seems fine with me. CRANFORD, CHRIS wrote: !-- actions -- bean id=personAction scope=prototype class=com.company.app.struts2.actions.PersonAction constructor-arg ref=personService/ /bean I don't see any advantage on creating Actions with Spring. It works fine without it and it seems unnecessary configuration. Perhaps someone else can point out clear advantages of this. CRANFORD, CHRIS wrote: Per one example I saw, struts.xml should be as follows: package name=persons namespace=/persons extends=struts-default action name=list class=personAction method=list result name=success/WEB-INF/pages/persons/list.jsp/result /action /package I would suggest using wildcards to reduce the configuration of your actions, and also giving your actions a better name for when you have more than one domain class (otherwise you don't know if list is related to Person or to Address). For example: package name=persons namespace=/persons extends=struts-default action name=*-* class={1}Action method={2} result name=success/WEB-INF/pages/{1]/{2}.jsp/result /action /package This example would allow any action named Something-someaction to be mapped to method someaction of class SomethingAction and have a result of pages/Something/someaction -- View this message in context: http://old.nabble.com/Struts2-%2B-Spring-Hibernate-tp26329368p26333817.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: Struts2 + Spring/Hibernate
Hi, I've just created similar skeleton couple of days ago. To let Spring generate your Service and DAO beans, you have to specify also the GenericService and GenericDAO in your applicationContext xml. You (can) set them as abstract and you have to specify the inheritance relationship between the PersonDAO and GenericDAO, the same for Service of course. At least this worked for me... Regarding your design... I thought that DAO design pattern is here to handle access to data objects, i.e. CRUD. So I don't see the benefit of the Service here? Can someone explain this? In my application I don't have any business logic but CRUD. Is the Service layer needed here or can DAO act as the Service as well? And finally I've got one more question, which I believe is related to this... One thing everyone suggest is to use wildcards in the Struts2 web.xml for CRUD operations. But this reference to many action classes with the same functionality. My question is, if we remove the duplicity in web.xml, can't we remove the duplicity in the Java code as well? Can't we create generic CRUD action as well? (Similar to generic DAO or generic Service). Thanks, Jozef On Fri, Nov 13, 2009 at 12:47 AM, CRANFORD, CHRIS chris.cranf...@setech.com wrote: I am in the process of implementing Struts2 along with integrated support with Spring and Hibernate. While I have found various examples on the web, I tend to find they vary. My application will primarily focus about 75% of the time on data queries and displaying this data to end users while a smaller 25% will actually support a full CRUD based system for certain data records. So far the examples I have seen have focused on implementing a class structure similar to the following: com.company.app.hibernate.dao.PersonDAO.java com.company.app.hibernate.dao.GenericDAO.java com.company.app.hibernate.model.Person.java com.company.app.hibernate.service.PersonService.java com.company.app.hibernate.service.GenericService.java com.company.app.struts2.actions.PersonAction.java The GenericDAO class is a template-like class that holds a reference to the EntityManager along with methods for saving, deleting, and retreiving objects persisted inside the EntityManager. The PersonDAO object extends GenericDAO and provides an additional list method shown below: public class PersonDAO extends GenericDAOPerson,Integer { public ListPerson list(int page, int size) { Query query = this.em.createQuery(from Person order by lastName, firstName); query.setFirstResult((page-1) * size); query.setMaxResults(size); return query.getResultList(); } } The Person class itself is annotated as an @Entity object with a unique property that is marked as the entity's unique ID and all the properties of the Person table along with get/set methods for each property. GenericService is another template-like interface class that defines create/delete/update/getById/list methods. Then PersonService implements this GenericService interface with calls to the PersonDAO object for each of these methods. And lastly PersonAction extends ActionSupport and implements StrutsStatics where it gets constructed with the GenericServicePerson class. Inside my web\WEB-INF\myAppContext.xml file I have: !-- daos -- bean id=personDao class=com.company.app.hibernate.dao.PersonDAO/ !-- services -- bean id=personService class=com.company.app.hibernate.service.PersonService property name=dao ref=personDao/ /bean !-- actions -- bean id=personAction scope=prototype class=com.company.app.struts2.actions.PersonAction constructor-arg ref=personService/ /bean Is there anything else I should include in myAppContext.xml? Any special inclusions or statements I need in my applicationContext.xml? Per one example I saw, struts.xml should be as follows: package name=persons namespace=/persons extends=struts-default action name=list class=personAction method=list result name=success/WEB-INF/pages/persons/list.jsp/result /action /package Thus far this example seemed easy to understand, particularly because we're only dealing with a single table. Before I go into how to take this example and build from it, do any of you have any input or suggestions on the approach I am taking with objects? Any lessons learned? Thanks Chris - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
How to get Login page while submitting a data form
Hi All, My requirement is this: 1. User fills a form and submits. 2. If he has not logged in, login form comes up. 3. after logging in, the data automatically gets submitted and next page comes. I am new to struts and unable to figure out the natural solution, even after a lot of googling. As I understand step 2 should be easy using interceptor, but how to get step 3 work? I am using struts 2.1.8. thanks, Sanjay http://www.sanjaypatel.name _ New Windows 7: Find the right PC for you. Learn more. http://windows.microsoft.com/shop
RE: Struts2 + Spring/Hibernate
Hi Wild Oscar, thanks for your input. First, I agree my design needs work with respect to naming conventions and thank you for the suggestions. This was more of a very crude example of how I should be relating components in the Hibernate/Spring/Struts2 design pattern so I can grasp the concept. In my Struts1.2 days, we didn't leverage spring nor hibernate and wrote our own DAO object framework. While it worked nicely, Hibernate has far more benefits. Now taking the example deeper, lets assume that Person is also related to two other tables in my database. For example, one table that stores Payroll and another that stores MenuPermissions. I would need to create two additional Entity objects, create their DAO and Service layers and then in all three entity objects, I would need to annotate the relationship amongst the 3 tables, correct? When I finally get to the point where this framework will hit the road is when I will have 4 or 5 tables in a database, all with relevant information about a key record or set of records in the main table and I will need to join all these records together. In the past we typically created a single record object for each query we had and while that worked nicely, there were lots of duplicity that I aim to avoid. Is this the right path and expectation for hibernate/spring/struts when I have a join between multiple database tables? Chris -Original Message- From: wild_oscar [mailto:mig...@almeida.at] Sent: Fri 11/13/2009 3:42 AM To: user@struts.apache.org Subject: Re: Struts2 + Spring/Hibernate Seems fine with me. CRANFORD, CHRIS wrote: !-- actions -- bean id=personAction scope=prototype class=com.company.app.struts2.actions.PersonAction constructor-arg ref=personService/ /bean I don't see any advantage on creating Actions with Spring. It works fine without it and it seems unnecessary configuration. Perhaps someone else can point out clear advantages of this. CRANFORD, CHRIS wrote: Per one example I saw, struts.xml should be as follows: package name=persons namespace=/persons extends=struts-default action name=list class=personAction method=list result name=success/WEB-INF/pages/persons/list.jsp/result /action /package I would suggest using wildcards to reduce the configuration of your actions, and also giving your actions a better name for when you have more than one domain class (otherwise you don't know if list is related to Person or to Address). For example: package name=persons namespace=/persons extends=struts-default action name=*-* class={1}Action method={2} result name=success/WEB-INF/pages/{1]/{2}.jsp/result /action /package This example would allow any action named Something-someaction to be mapped to method someaction of class SomethingAction and have a result of pages/Something/someaction -- View this message in context: http://old.nabble.com/Struts2-%2B-Spring-Hibernate-tp26329368p26333817.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
Re: How to get Login page while submitting a data form
Hi Sanjay, when intercepting action for the first time (no logged user), You can save submited data along with request uri and put it into session/database then after login (inside login action), check if these informations are present in sesion/database and forward to desired action with all the params that You have collected before login. Best greetings, Paweł Wielgus. 2009/11/13 Sanjaya Kumar Patel skpate...@hotmail.com: Hi All, My requirement is this: 1. User fills a form and submits. 2. If he has not logged in, login form comes up. 3. after logging in, the data automatically gets submitted and next page comes. I am new to struts and unable to figure out the natural solution, even after a lot of googling. As I understand step 2 should be easy using interceptor, but how to get step 3 work? I am using struts 2.1.8. thanks, Sanjay http://www.sanjaypatel.name _ New Windows 7: Find the right PC for you. Learn more. http://windows.microsoft.com/shop - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Catching: Unable to instantiate Action
I haven't been following this thread so if my answer doesn't help... sorry. I have configured a default Action setup to catch all unknown actions. The default-action-ref tag [1] sets the action to use when the requested action isn't found. default-action-ref name=Unknown / action name=Unknown class=com.nexmobile.server.struts.UnknownAction interceptor-ref name=unknownActionStack / result type=redirectActionLogin/result /action I use a restricted interceptor stack since all I'm going to do is log it and redirect to the login action. interceptor-stack name=unknownActionStack interceptor-ref name=log / interceptor-ref name=servletConfig / /interceptor-stack Your other option would be to configure a wildcard default [2] action name=* result/Unknown.jsp/result /action [1] http://struts.apache.org/2.x/docs/action-configuration.html#ActionConfiguration-ActionDefault [2] http://struts.apache.org/2.x/docs/action-configuration.html#ActionConfiguration-WildcardDefault On Fri, Nov 13, 2009 at 5:51 AM, RogerV roger.var...@googlemail.com wrote: Brian Thompson-5 wrote: I can only speculate, but it seems logical that the ClassNotFoundException is being thrown from outside the purview of Struts, in Tomcat's ClassLoaders - thus the Struts exception mapping never enters into it. Theres definitely something odd going on. With global mappings disabled and devmode set to true, entering an invalid action into the browser gives the Struts formatted No Action Mapped exception (it's not ClassNotFoundException). With global mappings and devmode set to false, entering an invalid action give the Tomcat 404 page with the no Action Mapped message. With global mappings set to catch java.lang.exception and devmode set to false, Struts seems to catch every exception thrown except when an invalid action is keyed into the browser. The fact that both the error message texts talk about No Action Mapped must surely mean that the error is being caught by Struts as Action Mapping is a Struts concept, not a Tomcat concept. I would have thought that catching in Invalid Action was one of the messages you would most want to catch to stop unfriendly users experimenting with your application! Regards -- View this message in context: http://old.nabble.com/Re%3A-Catching%3A-Unable-to-instantiate-Action-tp26303352p26334735.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: displaytag - Nothing found to display.
The problem has something to do with the get method in the action class not being called. Any ideas why this would happen? If I hit refresh a time or two it works fine. - http://www.kremsoft.com Kremsoft - Software Development -- View this message in context: http://old.nabble.com/displaytag---Nothing-found-to-display.-tp26301323p26338855.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: displaytag - Nothing found to display.
Kris Reid escribió: The problem has something to do with the get method in the action class not being called. Any ideas why this would happen? If I hit refresh a time or two it works fine. - http://www.kremsoft.com Kremsoft - Software Development Are you using ajax tags (like dojo ) or something like that with displaytag? - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: displaytag - Nothing found to display.
Oscar Calderón-2 wrote: Are you using ajax tags (like dojo ) or something like that with displaytag? No - haven't got any ajax or anything fancy I seem to have found a work around In the action class I stick the List into the request object request.setAttribute(list, list); And in the JSP display:table name=leads class=table id=request.list pagesize=100 Is their any reason why this should not be done? - http://www.kremsoft.com Kremsoft - Software Development -- View this message in context: http://old.nabble.com/displaytag---Nothing-found-to-display.-tp26301323p26339226.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: displaytag - Nothing found to display.
You're attributes are wrong. Should be: display:table name=list class=table id=bean pagesize=100 /display:table @name is the name of your request attribute. @id is the request attribute created at each the iteration. Paul On Fri, Nov 13, 2009 at 10:21 AM, Kris Reid krisrei...@gmail.com wrote: Oscar Calderón-2 wrote: Are you using ajax tags (like dojo ) or something like that with displaytag? No - haven't got any ajax or anything fancy I seem to have found a work around In the action class I stick the List into the request object request.setAttribute(list, list); And in the JSP display:table name=leads class=table id=request.list pagesize=100 Is their any reason why this should not be done? - http://www.kremsoft.com Kremsoft - Software Development -- View this message in context: http://old.nabble.com/displaytag---Nothing-found-to-display.-tp26301323p26339226.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
Re: displaytag - Nothing found to display.
Whoops - made I typo whilst I was mucking around. That's not the problem though Paul Benedict-2 wrote: You're attributes are wrong. Should be: display:table name=list class=table id=bean pagesize=100 /display:table @name is the name of your request attribute. @id is the request attribute created at each the iteration. Paul - http://www.kremsoft.com Kremsoft - Software Development -- View this message in context: http://old.nabble.com/displaytag---Nothing-found-to-display.-tp26301323p26339829.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
Validation and conversion conflict - best method?
I have an object with a java.util.Date field. I present the object inside a form with the following tag: s:textfield key=detail.date value=%{getText('detail.date',{schedule.dateTime})} label=Date/Time/ where detail.date is a date formatting pattern. The problem arises because after getText(), the field is populated with a String. When the String is submitted, I get an error because I don't have a setDateTime(String) method. I've written a data type conversion routine and applied it to the field, and it works fine as long as the user enters a date string in a valid format. If an invalid string is entered, the type conversion fails and a null is returned - so the user doesn't see the original date string, or even the incorrect one they entered - they see 'null'. So, I tried to add validation (using a validation xml file). However, it seems that the conversion is done regardless of whether or not the validation fails, so I end up with the same results. Next, I tried to implement the validation using the validate() method in the class, but I'm having similar troubles - I need to use the converter to convert the String to a Date - and I end up with all the previously described problems. If I don't use a converter, the field is null when it gets to the validate() method. It isn't practical for me to change the class that contains the Date field to add a setDateTime(String) method. It seems like a hack to use a variable outside of the class to hold the Date in String form and then worry about keeping it in sync with the actual object. I can't be the first to struggle with this, so I'd be interested in hearing how some of you have solved this in the past - is there a clean and elegant solution? Thanks in advance! -- View this message in context: http://old.nabble.com/Validation-and-conversion-conflict---best-method--tp26341189p26341189.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
Problem with s:iterator tag
Hi to all, i have a simple question about s:iterator tag. Let's say that we have a property in our action of type List, but in that list i only store Strings. When i want to print the value of the list on the JSP i use this code snipped: s:iterator value=selIngredientes s:property value=? / /s:iterator But i don't know if that's right, because i don't know how to put in the value attribute of the property tag, because the list isn't a list of objects, is a list of simple strings so each object doesn't have a property to get the string value. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Validation and conversion conflict - best method?
One quick solution might be , which I am using but most of them may not agree with me, -- Delcare a string in the action which take the value enter in the text box. -- Add the validation in the validation.xml as a regular expression and can add as requiredString , if the filed is mandatory to enter. -- The regular expression will check the format of the date. -- once validation passes can convert the string to date throught the util. Its an alternate solution. - Siddiq. ben_979 wrote: I have an object with a java.util.Date field. I present the object inside a form with the following tag: s:textfield key=detail.date value=%{getText('detail.date',{schedule.dateTime})} label=Date/Time/ where detail.date is a date formatting pattern. The problem arises because after getText(), the field is populated with a String. When the String is submitted, I get an error because I don't have a setDateTime(String) method. I've written a data type conversion routine and applied it to the field, and it works fine as long as the user enters a date string in a valid format. If an invalid string is entered, the type conversion fails and a null is returned - so the user doesn't see the original date string, or even the incorrect one they entered - they see 'null'. So, I tried to add validation (using a validation xml file). However, it seems that the conversion is done regardless of whether or not the validation fails, so I end up with the same results. Next, I tried to implement the validation using the validate() method in the class, but I'm having similar troubles - I need to use the converter to convert the String to a Date - and I end up with all the previously described problems. If I don't use a converter, the field is null when it gets to the validate() method. It isn't practical for me to change the class that contains the Date field to add a setDateTime(String) method. It seems like a hack to use a variable outside of the class to hold the Date in String form and then worry about keeping it in sync with the actual object. I can't be the first to struggle with this, so I'd be interested in hearing how some of you have solved this in the past - is there a clean and elegant solution? Thanks in advance! -- View this message in context: http://old.nabble.com/Validation-and-conversion-conflict---best-method--tp26341189p26341590.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: Problem with s:iterator tag
Try this: s:iterator value=selIngredientes s:property / /s:iterator Calling s:property without specifying a value will default to the top of the value stack which ought to be the current element in the list because you're inside the s:iterator tag. -Brian On Fri, Nov 13, 2009 at 12:53 PM, Oscar oscar.kalde...@gmail.com wrote: Hi to all, i have a simple question about s:iterator tag. Let's say that we have a property in our action of type List, but in that list i only store Strings. When i want to print the value of the list on the JSP i use this code snipped: s:iterator value=selIngredientes s:property value=? / /s:iterator But i don't know if that's right, because i don't know how to put in the value attribute of the property tag, because the list isn't a list of objects, is a list of simple strings so each object doesn't have a property to get the string value. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
RE: Problem with s:iterator tag
//Assuming we have this Action //A Simple Action Class which demonstrates placing information in a Map public class GetEntryAction extends ActionSupport { private ArrayList stats_list=new ArrayList(30); //a collection of stats private class stats { private ArrayList entries_list=new ArrayList(30); // a collection of Entries String StatusGroupName=StatusGroupName; String StatusGroupID=StatusGroupID; } private class Entry { String HOHName; public String getHOH Name() { return HOHName; } public void setHOH Name(String HOHName) { this.HOHName=HOHName; } String Price; public String getPrice() { return Price; } public void setPrice(String price) { Price=price; } String OriginalValue; public String getOriginalValue() { return OriginalValue; } public void setOriginalValue(String str) { OriginalValue=str; } } public String execute() throws Exception { Map session = com.opensymphony.xwork2.ActionContext.getContext().getSession(); //construct new Uber stats class stats stats1=new stats(); stats1.StatusGroupName=new String(StatusGroupName1); stats1.StatusGroupID=new String(StatusGroupID); //Name,Value,OriginalValue //construct the 1st entry Entry entry1=new Entry(); entry1.setHOHName(ALL); entry1.setPrice(50.00); entry1.setOriginalValue(10.00); //put it into stats Map stats1.entries_list.add(entry1); //construct the second entry Entry entry2=new Entry(); entry2.setHOHName(ALL); entry2.setPrice(50.00); entry2.setOriginalValue(10.00); //put it into entries Map stats1.entries_list.add(entry2); //put the stats class into stats_list stats_list.add(stats1); //construct new Uber stats class stats stats2=new stats(); stats2.StatusGroupName=new String(StatusGroupName2); stats2.StatusGroupID=new String(StatusGroupID2); //construct the 1st entry Entry entry2a=new Entry(); entry2a.setHOHName(ALL); entry2a.setPrice(50.00); entry2a.setOriginalValue(10.00); //put it into stats Map stats2.entries_list.add(entry2a); //construct the second entry Entry entry2b=new Entry(); entry2b.setHOHName(ALL); entry2b.setPrice(50.00); entry2b.setOriginalValue(10.00); //put it into entries Map stats2.entries_list.add(entry2b); session.put(stats_list,stats_list); //All of the information you require is now in the map which is now in the Session return SUCCESS; } } s:iterator value=#session.stats_list status=statsStatus var=stats_list tr class=s:if test=#statsStatus.odd == true odd/s:ifs:elseeven/s:else tds:property value=name //td tds:property value=description //td td !-- notice the statsStatus.indexis used to refer to iterate from -- s:iterator value=#session.stats_list.entries_list('#statsStatus.index') status=userStatus var=user_list !-- display HOHName for anything other than 0 entry -- s:property value=HOHName /s:if test=!#userStatus.index,/s:if /s:iterator /td /tr /s:iterator a few things to notice: notice how the index from statsStatus outer loop is being used for the session_stats inner loop also take a look at this List which is later pushed onto OGNLStack (session) private ArrayList stats_list=new ArrayList(30); //a collection of stats and then referenced later on as #session.stats_list once inside the session.stats_list there is a inner list private ArrayList entries_list=new ArrayList(30); which is populated and pushed onto OGNLStack (session) and then referenced later on as #session.stats_list.entries_list 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
Re: Problem with s:iterator tag
Brian Thompson escribió: Try this: s:iterator value=selIngredientes s:property / /s:iterator Calling s:property without specifying a value will default to the top of the value stack which ought to be the current element in the list because you're inside the s:iterator tag. -Brian On Fri, Nov 13, 2009 at 12:53 PM, Oscar oscar.kalde...@gmail.com wrote: Hi to all, i have a simple question about s:iterator tag. Let's say that we have a property in our action of type List, but in that list i only store Strings. When i want to print the value of the list on the JSP i use this code snipped: s:iterator value=selIngredientes s:property value=? / /s:iterator But i don't know if that's right, because i don't know how to put in the value attribute of the property tag, because the list isn't a list of objects, is a list of simple strings so each object doesn't have a property to get the string value. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org ThanksBrian, it works. Before your answer i tried this: s:iterator value=selIngredientes s:property value=selIngredientes / /s:iterator But it prints me the values with [] like this: [TOMATO] [PINEAPPLE] [ANOTHER] - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
some love for the documentation
I created new space to work on the documentation, the guide main page is here: http://cwiki.apache.org/confluence/display/S2NewDocDraft/Guides I think it is very important that we clean up the documentation, document missing parts, remove outdated stuff, the version boxes, and the snippets as well. I will reuse content from the current documentation and add new entries. I have seen a bunch of tutorials and articles around the net, if you like to contribute those to be included on the docs, and you have a CLA on file, let me know. Anyone that has a CLA on file and wants to help with this effort, let me know and I will give rights to edit/create on that space. If you don't have a CLA on file and would like to help: http://apache.org/licenses/icla.txt This would make a great addition for 2.2. Also, feel free to reply to this thread with ideas for new topics, suggestions, or just to cheer us up :) musachy - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: some love for the documentation
wrong link: http://cwiki.apache.org/confluence/display/S2NewDocDraft/User+Guide On Fri, Nov 13, 2009 at 11:30 AM, Musachy Barroso musa...@gmail.com wrote: I created new space to work on the documentation, the guide main page is here: http://cwiki.apache.org/confluence/display/S2NewDocDraft/Guides I think it is very important that we clean up the documentation, document missing parts, remove outdated stuff, the version boxes, and the snippets as well. I will reuse content from the current documentation and add new entries. I have seen a bunch of tutorials and articles around the net, if you like to contribute those to be included on the docs, and you have a CLA on file, let me know. Anyone that has a CLA on file and wants to help with this effort, let me know and I will give rights to edit/create on that space. If you don't have a CLA on file and would like to help: http://apache.org/licenses/icla.txt This would make a great addition for 2.2. Also, feel free to reply to this thread with ideas for new topics, suggestions, or just to cheer us up :) musachy - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
RE: html:link submit with request parameters
Use javascript to get a reference to the form, and call its submit method. EG form name=form id=form action=/setup.do input name=blah / input type=submit/ /form script function submit() { document.getElementById(form).submit() return false; } /script a href=javascript:submit(); onclick=return submit();click me/a -Original Message- From: fea jabi [mailto:zy...@hotmail.com] Sent: Thursday, November 12, 2009 8:43 PM To: user@struts.apache.org Subject: html:link submit with request parameters I need to submit the form when the html:link . is clicked/pressed and also need to pass parameters. c:url value=/setup.do var=setupUrl c:param name=empId value=${custItr.empId}/ /c:url html:link href=%= (String)pageContext.getAttribute(\setupUrl\) % transaction=true c:out value=${custItr.empName}/ /html:link but this is not submitting the form. How can I submit the form and also pass the request params? Basically I want other values entered in the html form are set to the form bean so i can acess those in action class when the link is pressed. How can this be done? Thanks. _ Hotmail: Trusted email with Microsoft's powerful SPAM protection. http://clk.atdmt.com/GBL/go/177141664/direct/01/ http://clk.atdmt.com/GBL/go/177141664/direct/01/ Notice: This e-mail message, together with any attachments, contains information of Merck Co., Inc. (One Merck Drive, Whitehouse Station, New Jersey, USA 08889), and/or its affiliates Direct contact information for affiliates is available at http://www.merck.com/contact/contacts.html) that may be confidential, proprietary copyrighted and/or legally privileged. It is intended solely for the use of the individual or entity named on this message. If you are not the intended recipient, and have received this message in error, please notify us immediately by reply e-mail and then delete it from your system. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
RE: How to get Login page while submitting a data form
Hi Pawel, Thanks for the insight. I would give a try. Being a common scenario, is there any existing work already present for this, so that I don't have to reinvent the wheel? I guess there should already be some established library / code sample which people follow. What do people normally do? when intercepting action for the first time (no logged user), You can save submited data along with request uri and put it into session/database then after login (inside login action), check if these informations are present in sesion/database and forward to desired action with all the params that You have collected before login. My requirement is this: 1. User fills a form and submits. 2. If he has not logged in, login form comes up. 3. after logging in, the data automatically gets submitted and next page comes. I am new to struts and unable to figure out the natural solution, even after a lot of googling. As I understand step 2 should be easy using interceptor, but how to get step 3 work? I am using struts 2.1.8. _ New Windows 7: Find the right PC for you. Learn more. http://windows.microsoft.com/shop
Re: Validation and conversion conflict - best method?
Hi Ben, I think I understand your problem. I am have a similar situation where I have a person class with a birthday. I ended up writing a Converter to handle the date (because I needed it in the format dd/mm/). I used the Person-conversion.properties to say that I want that converter applied to that field. And for the validation I have something like the following in the Person-validation.xml file. field name=birthday field-validator type=conversion message${getText(persona.birthday)} : ${getText(validation.invalid)}/message /field-validator /field So my converter handles the case where there is no date. I don't have to use the getText method. I just refer to the property as I would with a normal field. Then my converter throws a conversion exception if there are problems converting the date. I then catch this with the above line in my validation.xml. I am new to the Struts 2 world but I think this is a relatively clean solution. Happy to hear if anyone else has a better way. Cheers, Carl. Quoting ben_979 benninesevenn...@yahoo.ca: I have an object with a java.util.Date field. I present the object inside a form with the following tag: s:textfield key=detail.date value=%{getText('detail.date',{schedule.dateTime})} label=Date/Time/ where detail.date is a date formatting pattern. The problem arises because after getText(), the field is populated with a String. When the String is submitted, I get an error because I don't have a setDateTime(String) method. I've written a data type conversion routine and applied it to the field, and it works fine as long as the user enters a date string in a valid format. If an invalid string is entered, the type conversion fails and a null is returned - so the user doesn't see the original date string, or even the incorrect one they entered - they see 'null'. So, I tried to add validation (using a validation xml file). However, it seems that the conversion is done regardless of whether or not the validation fails, so I end up with the same results. Next, I tried to implement the validation using the validate() method in the class, but I'm having similar troubles - I need to use the converter to convert the String to a Date - and I end up with all the previously described problems. If I don't use a converter, the field is null when it gets to the validate() method. It isn't practical for me to change the class that contains the Date field to add a setDateTime(String) method. It seems like a hack to use a variable outside of the class to hold the Date in String form and then worry about keeping it in sync with the actual object. I can't be the first to struggle with this, so I'd be interested in hearing how some of you have solved this in the past - is there a clean and elegant solution? Thanks in advance! -- View this message in context: http://old.nabble.com/Validation-and-conversion-conflict---best-method--tp26341189p26341189.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
RE: How to get Login page while submitting a data form
If a form requires authentication, don't render it until the user is logged in. If you are worried about the user's session timing out before the form is submitted, implement some sort of javascript timer that (after a period equal to a session timeout), pops up a modal login form. Successfully submitting the login form Resets the timer, makes the login form disappear, and the user is free to submit their form. -Original Message- From: Sanjaya Kumar Patel [mailto:skpate...@hotmail.com] Sent: Friday, November 13, 2009 3:48 PM To: Struts User Group Subject: RE: How to get Login page while submitting a data form Hi Pawel, Thanks for the insight. I would give a try. Being a common scenario, is there any existing work already present for this, so that I don't have to reinvent the wheel? I guess there should already be some established library / code sample which people follow. What do people normally do? when intercepting action for the first time (no logged user), You can save submited data along with request uri and put it into session/database then after login (inside login action), check if these informations are present in sesion/database and forward to desired action with all the params that You have collected before login. My requirement is this: 1. User fills a form and submits. 2. If he has not logged in, login form comes up. 3. after logging in, the data automatically gets submitted and next page comes. I am new to struts and unable to figure out the natural solution, even after a lot of googling. As I understand step 2 should be easy using interceptor, but how to get step 3 work? I am using struts 2.1.8. _ New Windows 7: Find the right PC for you. Learn more. http://windows.microsoft.com/shop Notice: This e-mail message, together with any attachments, contains information of Merck Co., Inc. (One Merck Drive, Whitehouse Station, New Jersey, USA 08889), and/or its affiliates Direct contact information for affiliates is available at http://www.merck.com/contact/contacts.html) that may be confidential, proprietary copyrighted and/or legally privileged. It is intended solely for the use of the individual or entity named on this message. If you are not the intended recipient, and have received this message in error, please notify us immediately by reply e-mail and then delete it from your system. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Validation and conversion conflict - best method?
I have a related question, but it's a bit of a side-track as I try to solve my original problem. What is the naming convention and the difference between the two types of -validation.xml file naming? I think I understand that ActionClass-validation.xml is called for all (non-excluded) methods in the Action. The documentation on the other method is very scarce and difficult to understand. It suggests that the name should be ActionClass-ActionAlias-validation.xml, however it isn't really clear what ActionAlias really means. In my case, my action class is called ScheduleDetail. The form that invokes the update is coded as follows : s:form action=ScheduleDetail_update So, my understanding is that if I want validation ONLY for this method, the naming convention should be: ScheduleDetail-ScheduleDetail_update-validation.xml Is this correct? I've tried ScheduleDetail-validation.xml just to use the basic naming definition, but it doesn't seem to get invoked. The messages that I have defined in the file are never presented, I am seeing what I think are generic struts error messages for type conversion errors (I'm trying to force failure by entering a string in an int field). -- View this message in context: http://old.nabble.com/Validation-and-conversion-conflict---best-method--tp26341189p26345292.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
Struts Dojo Question
Hello all. In working through some Dojo stuff, I have come to a roadblock, on which I hope someone will be able to shed some light. I have a page that displays a user's account info. If they press update, Dojo pops up a dialog box which allows them to update their info. Opening a Dialog box in a web browser is very cool, and it's easy to do with Dojo. In the dialog, there is are three dropdown boxes, named Continent, Country, and Locality. If the user chooses the continent of North America, the Country box should show only the countries for North America. If the user chooses Western Europe, the Country box should show only the countries for Western Europe. And so on; you get the idea. I am using the standard Json ItemFileReadStore attached to my Postgres database. The Continent: field gets filled properly. But when I select a different Continent, and the call is made to the Action class to retrieve the list of countries for the new continent, the new continent's abbreviation is never passed in. My javascript reads like so: var selectedContinent ; function continentWasChanged() {selectedContinent = dijit.byId('continent').attr('value') ; console.log ('found selectedContinent as ' + selectedContinent) ; theStore.fetch(selectedContinent) ; } The console.log statement shows that selectedContinent DOES have the value I expect. The intention is to have the selectedContinent passed into my action class. My struts.xml snippet reads like so: action name=countryData method=countryData class=LocationAction result name=NONE/result param name=continent#attr.selectedContinent/param /action In my LocationAction class, I have a setContinent(String) method, and the passed parameter is the string #attr.selectedContinent, not NA when North America is selected. In going through the OGNL docs, I thought that #attr is the way of selecting data on a page, but maybe not in this case, because the LocationAction class is only used to serve up locations. The jsp is really bound to the UserDisplayAction class. I'm thinking if I move the Action logic into the UserDisplayAction class, it might work better, but I hope I can separate the logic in this fashion. I guess the question is whether it is possible to do what I am trying to do here, or not? Thanks, Tom
RE: How to get Login page while submitting a data form
If a form requires authentication, don't render it until the user is logged in. If you are worried about the user's session timing out before the form is submitted, implement some sort of javascript timer that (after a period equal to a session timeout), pops up a modal login form. Successfully submitting the login form Resets the timer, makes the login form disappear, and the user is free to submit their form. Nice idea! Curious to know what is the common practice. Would like to hear if people are using some established libraries or pattern etc. Hi Pawel, Thanks for the insight. I would give a try. Being a common scenario, is there any existing work already present for this, so that I don't have to reinvent the wheel? I guess there should already be some established library / code sample which people follow. What do people normally do? when intercepting action for the first time (no logged user), You can save submited data along with request uri and put it into session/database then after login (inside login action), check if these informations are present in sesion/database and forward to desired action with all the params that You have collected before login. My requirement is this: 1. User fills a form and submits. 2. If he has not logged in, login form comes up. 3. after logging in, the data automatically gets submitted and next page comes. I am new to struts and unable to figure out the natural solution, even after a lot of googling. As I understand step 2 should be easy using interceptor, but how to get step 3 work? I am using struts 2.1.8. _ New Windows 7: Find the right PC for you. Learn more. http://windows.microsoft.com/shop Notice: This e-mail message, together with any attachments, contains information of Merck Co., Inc. (One Merck Drive, Whitehouse Station, New Jersey, USA 08889), and/or its affiliates Direct contact information for affiliates is available at http://www.merck.com/contact/contacts.html) that may be confidential, proprietary copyrighted and/or legally privileged. It is intended solely for the use of the individual or entity named on this message. If you are not the intended recipient, and have received this message in error, please notify us immediately by reply e-mail and then delete it from your system. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org _ Windows 7: Simplify what you do everyday. Find the right PC for you. http://windows.microsoft.com/shop
Hibernate/Spring
I have done a fair amount of reading today on the topic again and developed a few simple classes to support my service, model, and dao architecture for using Hibernate 3.3.2 and Spring 2 with Struts2. The problem I am currently facing is I get a detached error when deleting an object and I get a null pointer exception in SessionImpl.java when I try to locate an object by its id. /* GenericDAO.java */ public T findById(Object id) { return(getEntityManager().find(clazz, id)); } public void delete(T entity) { getEntityManager().remove(entity); } Some posts I have seen say for the delete, you should use getReference() or merge() in order to get an association to the entity before you call the remove() method. I attempted to use the same type of logic with getReference() during the findById() and it failed. Am I missing something in my configuration with Hibernate/Spring with respect to the session factory or something that I need to revisit? It really seems as though I may have a missing component or a poor configuration somewhere. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Trouble with struts2 validation
vikrant S wrote: Initially I did not check for null textfield and I was able to validate the username and password directly from database.but When I applied validate method in my action class It began to validate for null fields but not for stored username and password. I am pasting my code.. Are you sure the validate() method you've written is doing what you think it is? If there are no field errors after the validate() method, the execute() action will run--that's just how it works. ResultSet results =sql.executeQuery(select * from my_table where usr = + '+userid+'+ and pass = +'+pwd+'); SQL injection: be wary here. if (results != null) Is this the appropriate check, or should you be checking for a length? Have you turned up the logging levels to get a handle on what's going on behind the scenes? Dave - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org