Re: Localization and Dates
Thanks very much for the detailed answer Greg. Thanks Tommy for the links but the problem I have isn't related to displaying of dates. Specifically, I've narrowed it down to the type conversion carried out by Struts. The struts type conversion documentation states type conversion for dates works as : dates - uses the SHORT format for the Locale associated with the current request It seems that when my application is deployed on the US server, the xwork validation/type conversion insists on the dates being US formatted MM/dd/ despite my locale being reported by struts as: GBR eng class java.util.Locale GB United Kingdom English English (United Kingdom) en It seems that the Date conversion provided by struts/xwork is not working in this case as expected. I have no idea if this is a config issue or not. If nobody else can shed a light on this problem, I shall fall back to defining date fields as String and following the recommendations made by Greg. Greg Lindholm wrote: Properly handling dates in a fully internationalized application can be harder then you might think. As in your example "Dec. 20, 2009" is not an absolute value, it depends on which timezone the user is in because if may be Dec 20 in London, but it's already Dec 21 in Hong Kong. And of course 12/10/2009 means different dates depending on which country or region you are in. So a date is only fully defined if you know both the TimeZone and the Locale of the user. In the apps I've written I always include the Locale and TimeZone as part of the User object. Then I always use a DataFormat object and set both the Locale and TimeZone, if you don't set them they will default to the servers settings which often (but not always) are GMT ( which is almost always incorrect for the user). If you don't know the timezone or locale of the user (or have unregistered users) then you could provide a select dropdown list that lets them specify it as part of the request (then cookie it). As a last and worst resort you could always tell them which timezone the app is running in and what format you expect dates to be entered in. In either case you do not want to use automatic String to Date conversion for parameter setting. Have your 'date' field defined as a String and in your action convert it to a Date using a DateFormat object based on the TimeZone and Locale that you chose. On a related note, if you are selecting records from a database based on a Date field, (e.g. select orders for Dec 20, 2009) and your db column is a datetime then you really need to specify your select as a range e.g. "select orders where orderDate >= :startDate and orderDate < :endDate". To create the startDate and endDate you use a Calender object and again you must set the TimeZone and Locale (Calendar.getInstance(timeZone, locale);) you would then set the date to the date you want (Dec 20, 2009) and set the time portion to zero (Hours, minutes, seconds, milliseconds). For the the endDate you would add one day to the calendar. You range expression then gives you the 24 hour period that is considered "Dec 20, 2009" for a user in that timezone. Hope that helps. On Wed, Sep 30, 2009 at 5:18 AM, Robin Mannering wrote: Hello, Can anyone give me some 'best practice' advice for dealing with dates in an international app (Struts2). We are based in the UK and have an application running locally that stores dates within action classes as java.util.Date. These dates are sometimes passed to the application via querystring in the format: somePage.action?startDate=20/12/2009 The action class picks up this date and stores it correctly as the 20th day of December when running locally. However, on installation to our US based server (Struts 2 / Glassfish) where of course date formats are mm/dd/, the action class makes the assumption that we are trying to refer to the 20th month of the year and so returns control to the input page with an accompanying error message. I know this is to do with localization, but I am at a loss as to the best practice for defining locales so that struts knows how to deal with this kind of scenario. The problem is passing those localized value back to the server action classes. Any advice would be gratefully received. Thanks - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org No virus found in this incoming message. Checked by AVG - www.avg.com Version: 8.5.409 / Virus Database: 270.13.115/2404 - Release Date: 09/30/09 05:52:00
Localization and Dates
Hello, Can anyone give me some 'best practice' advice for dealing with dates in an international app (Struts2). We are based in the UK and have an application running locally that stores dates within action classes as java.util.Date. These dates are sometimes passed to the application via querystring in the format: somePage.action?startDate=20/12/2009 The action class picks up this date and stores it correctly as the 20th day of December when running locally. However, on installation to our US based server (Struts 2 / Glassfish) where of course date formats are mm/dd/, the action class makes the assumption that we are trying to refer to the 20th month of the year and so returns control to the input page with an accompanying error message. I know this is to do with localization, but I am at a loss as to the best practice for defining locales so that struts knows how to deal with this kind of scenario. The problem is passing those localized value back to the server action classes. Any advice would be gratefully received. Thanks - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Field-Validator and BigDecimal
Hello all, I have a rather strange validation problem. I have a field agencyCommRate declared as a BigDecimal. I need to validate that a value between 0.0 and 100.0 is entered and assumed the following validation rules would work. Values outside the range are picked up correctly. However, when the values are inside the range, the validation rule 'requiredstring' insists that there is no value for agencyCommRate and validation always fails. Can anybody spot a glaring mistake in my below declaration, or is there a known problem on combining requiredstring and double validation rules? Thanks Robin true key="form.createShopForm.validationMsg.agencyCommRateRequired"> 0.00 100.00 key="form.createShopForm.validationMsg.agencyCommRateBadValue"> - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: URL Mappings
Thanks for all the feedback on this post! Having seen the post from Martin regarding I've now also seen the equivalent declaration in struts.properties : struts.action.extension=action But most probably know that I guess. Thanks also for the heads up on the deprecated org.apache.struts2.dispatcher.FilterDispatcher in favour of org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter. Robin Wes Wannemacher wrote: Next generation? Multiple filters were created to deal with problems arising from using things like the sitemesh filter and struts tags inside of decorators. On 8/15/09, Dale Newfield wrote: musom...@aol.com wrote: Note that org.apache.struts2.dispatcher.FilterDispatcher is deprecated since 2.1.3 in favor of org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter. D'oh! I didn't know that! I'm a bit confused, though -- are the javadocs here: http://struts.apache.org/2.x/struts2-core/apidocs/org/apache/struts2/dispatcher/ng/package-summary.html out of date? The example web.xml code doesn't include the .ng portion of the packages... (what's "NG" short for, anyway?) -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org No virus found in this incoming message. Checked by AVG - www.avg.com Version: 8.5.392 / Virus Database: 270.13.57/2303 - Release Date: 08/14/09 18:10:00
URL Mappings
Please excuse if this question has been answered before. I can't find any direct reference to it. How would I configure Struts2 to treat .htm requests in the same way as .action requests. I freely admit I do not understand how org.apache.struts2.dispatcher.FilterDispatcher identifies between static and not static content. For SEO and for familiarity for average users, I'd like all our URLs to end in .htm Is this possible and how do I go about this. Thanks Robin - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Internationalization and SEO
Hello, I have a question relating to serving international content that I hope someone can help with. It is kind of leaning towards an SEO question, but it does relate to Struts in terms of how I can use Struts 2 to control page direction because of language selection. In terms of SEO, I am guessing that serving the content for three languages on one page, would be bad for SEO. For example, serving English, French and German versions for a page all on the same URL: www.mydomain.com/myPage.htm This is possible of course creating and using the corresponding language resource bundles. Struts 2 would serve up the correct content based on the browser locale setting. However, looking around Googles knowledgebase, it would be better to have: www.mydomain.com/en/myPage.htm www.mydomain.com/fr/myPage.htm www.mydomain.com/de/myPage.htm How can I configure struts to work in this way, ie redirect a user to a subdirectory tree based on the language locale set in their browser. Thanks for any thoughts. Robin - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: EJB Injection in Interceptor
Wow! Thanks for all this great feedback and ideas regards this problem. I'm sorry I cannot add any useful prompts to help you develop a plugin Wes as Spring and it's methods for injection are something I know nothing about. I have to admit, injection is not something I fully understand and anything I offered as a solution would likely be incorrect. However, my only real requirement (currently) is to obtain local references to both stateless and stateful session beans in Glassfish 2.1 from within Struts 2 action classes. Looking at Haroons' examples, this would seem to be exactly the solution I'm looking for and I will try and implement this. Can I just ask two further small questions to Haroon? Is the EJBInvokerServlet set to initialise at app startup via the web.xml definition? Does the EJBInvokerServlet approach work for stateful session bean references as well as stateless? Again, thank you for the time and effort everyone has gone through in providing ideas and solutions to this problem. It is good to know that this kind of expert help is available via the forum. Many thanks, Robin Wes Wannemacher wrote: On Thu, Jul 30, 2009 at 10:34 AM, Haroon Rafique wrote: Hi Wes, I don't know much of the details about the JEE spec, however, I can share my implementation with you. The code is not in production yet, so caveat emptor (it works for us, for now in development). I use glassfish as my app server. To expose local EJB interfaces within our entire application, I use an EJBInvokerServlet (uses the @EJB and @EJBs annotations). The listing is as follows (took out package and import statements and anonymized): @EJBs( value = { @EJB(beanInterface = Local1.class, name = "ejb/local1"), @EJB(beanInterface = Local2.class, name = "ejb/local2"), } ) /** * Used to make local interfaces of listed EJBs available within the whole * web application. */ public class EJBInvokerServlet extends HttpServlet { } The other way to inject beans is by specifying inside web.xml. Local1Bean Session Local1 I prefer the Servlet approach as its simpler. Wherever we need the EJBs to be automagically injected (the container does its part because of EJBInvokerServlet), we then use the @Resource annotation, e.g., to inject the Local1 interface, I would use: @Resource(mappedName = "ejb/local1") private Local1 local1; Hope that helps. Haroon, it does and it doesn't. @EJB/@EJBs and @Resource aren't the only DI annotations that are part of the EE specs. This is the problem Robin has with the existing integration plugins. My understanding of what he wants is that he wants to be able to use other annotations (like @PersistenceContext) on fields in a struts action and have those fields injected. To turn it around and consider it compared to another similar plugin... In the spring plugin, we delegate the class instantiation to spring, then spring can decide what needs injected, etc. based on spring configuration. What I'd like to do is apply the same concept to EE. To do this in spring, there is an implementation of the ObjectFactory that first tries to instantiate objects using spring, and when that fails, it falls back on traditional xwork instantiation (reflection-based). Once the object is created, the spring object factory then checks to see if it can autowire the instance (based on plugin configuration). I'd like to try a similar approach with EE. The hard part is that I don't know what API, or where to look for an API that instantiates EE objects. Spring has 'applicationContext.getBean', is there something similar for EE? Even if it's not as easy as Spring, I'm still willing to wade through it for a bit since it seems like it would be useful to at least a few users. The advantage to an object factory based EE plugin is that I don't need to be aware of the annotations at all, I'd be delegating that sort of thing to the EE app server's own mechanisms. -Wes No virus found in this incoming message. Checked by AVG - www.avg.com Version: 8.5.392 / Virus Database: 270.13.37/2273 - Release Date: 07/30/09 18:09:00
Re: EJB Injection in Interceptor
Just to clear up my actual question from the thread below as feedback has run dry unfortunately. Is there anybody working daily with Struts 2 and EJB 3.0? If so, what is the best way to obtain local references to EJB 3 session beans from within Struts 2 action classes? Thanks for any thoughts on this subject. Robin Mannering wrote: Just wondering if the below thread has gone any further. After creating another thread on the same subject at an earlier date, we discussed using the EJB plugin here: http://cwiki.apache.org/S2PLUGINS/ejb3-plugin.html However, having started to use this plugin so that I can reference stateless session beans, it seems that all EJB Session bean classes must be defined as @Remote rather than @Local in order for the injection to obtain the references correctly. Failure to specify them as remote throws a javax.naming.NameNotFoundException. However, reading from a book entitled "Pro EJB 3.0", the following performance issues are mentioned in relation to using @Remote when @Local is available. Hopefully this link will work for you. http://books.google.co.uk/books?id=fVCuB_Xq3pAC&pg=PA40&lpg=PA40&dq=Making+an+interface+remote+has+consequences&source=bl&ots=Bg9DdpVAWW&sig=vxrumZhYLhjmqbt6bdMJ96hrY7s&hl=en&ei=QIdtStuLC-WhjAf34KGeCw&sa=X&oi=book_result&ct=result&resnum= So, the problem is : How can we obtain references to EJB 3 session beans from within Struts 2 action classes? I'd be very interested to hear your thoughts. Thanks Robin Nathan Schulte wrote: Wes Wannemacher wantii.com> writes: Seems to me that my idea to create an ObjectFactory based plugin ... needs to pick up some steam. I only have one question for the EJB users out there... Do you guys need Spring integration as well? To answer your question, _I_ personally don't need Spring integration. I've never used Spring, and for this project, it was too much overhead to learn (on top of Java EE, the JPA, Hibernate intricacies, Struts2...), and from what I understand, it seemed like using it and S2 together provided duplicate functionality (another topic altogether...). On another note, I find it awesome that the community (or whatever group you're part of) is so willing to provide support. I mean, in my eyes, this is something that I could see myself writing to make my coding easier, it's just that given my situation, it's easier to use the "workaround." Admittedly, I'm not very familiar with JEE5. Some of this is still black magic, and I don't fully understand the issue, I just know enough to understand that the architecture permits it as an issue (and not everyone is just blowing smoke my way) and can leave all of the intricate details be, as they don't directly affect my project. -Nate - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org No virus found in this incoming message. Checked by AVG - www.avg.com Version: 8.5.387 / Virus Database: 270.13.20/2248 - Release Date: 07/19/09 05:57:00 No virus found in this incoming message. Checked by AVG - www.avg.com Version: 8.5.392 / Virus Database: 270.13.31/2265 - Release Date: 07/26/09 17:59:00
Re: EJB Injection in Interceptor
Just wondering if the below thread has gone any further. After creating another thread on the same subject at an earlier date, we discussed using the EJB plugin here: http://cwiki.apache.org/S2PLUGINS/ejb3-plugin.html However, having started to use this plugin so that I can reference stateless session beans, it seems that all EJB Session bean classes must be defined as @Remote rather than @Local in order for the injection to obtain the references correctly. Failure to specify them as remote throws a javax.naming.NameNotFoundException. However, reading from a book entitled "Pro EJB 3.0", the following performance issues are mentioned in relation to using @Remote when @Local is available. Hopefully this link will work for you. http://books.google.co.uk/books?id=fVCuB_Xq3pAC&pg=PA40&lpg=PA40&dq=Making+an+interface+remote+has+consequences&source=bl&ots=Bg9DdpVAWW&sig=vxrumZhYLhjmqbt6bdMJ96hrY7s&hl=en&ei=QIdtStuLC-WhjAf34KGeCw&sa=X&oi=book_result&ct=result&resnum= So, the problem is : How can we obtain references to EJB 3 session beans from within Struts 2 action classes? I'd be very interested to hear your thoughts. Thanks Robin Nathan Schulte wrote: Wes Wannemacher wantii.com> writes: Seems to me that my idea to create an ObjectFactory based plugin ... needs to pick up some steam. I only have one question for the EJB users out there... Do you guys need Spring integration as well? To answer your question, _I_ personally don't need Spring integration. I've never used Spring, and for this project, it was too much overhead to learn (on top of Java EE, the JPA, Hibernate intricacies, Struts2...), and from what I understand, it seemed like using it and S2 together provided duplicate functionality (another topic altogether...). On another note, I find it awesome that the community (or whatever group you're part of) is so willing to provide support. I mean, in my eyes, this is something that I could see myself writing to make my coding easier, it's just that given my situation, it's easier to use the "workaround." Admittedly, I'm not very familiar with JEE5. Some of this is still black magic, and I don't fully understand the issue, I just know enough to understand that the architecture permits it as an issue (and not everyone is just blowing smoke my way) and can leave all of the intricate details be, as they don't directly affect my project. -Nate - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org No virus found in this incoming message. Checked by AVG - www.avg.com Version: 8.5.387 / Virus Database: 270.13.20/2248 - Release Date: 07/19/09 05:57:00
Re: Login with Struts2
Hi, I recently implemented a login mechanism but did it slightly differently after recommendations from this mailing list to use an interceptor. Each action/page that requires a validated login is directed via a Interceptor. The sole purpose of the interceptor is to verify the existence of an object in the session. Here is the guts of the method: public String intercept(ActionInvocation invocation) throws Exception { ActionContext ac = invocation.getInvocationContext(); Map session = ac.getSession(); // retrieve the login status from the session by key name. User user = (User) session.get(Constants.USER_SESSION_SCOPE); // if the user object is non null, the user is logged in. if (user != null) {; return invocation.invoke(); } return "notLoggedIn"; } It is then necessary to create a new interceptor stack: I also defined a global-result as follows to take care of directing the client when not logged in. showLogin Finally, here is an example of a protected action using the new interceptor stack: /controlPanel.ftl You then simply need a regular action to take of the "login" which will place a valid object/flag in the session. Hope this helps mathias-ewald wrote: Hi, I am trying to implement a login mechanism. I will now explain what I did and what error I get but in case there is a more sophisticated way to do that - please tell me! I created a BaseAction which is the parent of all my Actions. The BaseAction is supposed to be responsible for displaying a login page if there is no User object in session scope. Then the login form should put the username and password into the BaseAction. The BaseAction then tries to find a match in the database and places the User object into session scope: - public abstract class BaseAction { private String username; private String password; protected Log log; private Boolean loginStatus; public String execute() { if(log == null) { log = LogFactory.getLog(getClass()); } if(isProtected()) { Map session = ActionContext.getContext().getSession(); Object o = session.get("user"); if(o instanceof User) { loginStatus = true; } else { return "login"; } } return executeAction(); } public abstract String executeAction(); public abstract Boolean isProtected(); public Boolean getLoginStatus() { return loginStatus; } public void setLoginStatus(Boolean loginStatus) { this.loginStatus = loginStatus; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } } - An Action that wants to be password protected must implement #isProtected() to return "true". This is my JSP file that is shown if #isProtected() == true and there's no User in session scope: - ... ... - This is the error I get - 20:35:42,179 WARN OgnlValueStack:49 - Error setting value ognl.OgnlException: target is null for setProperty(null, "password", [Ljava.lang.String;@1f22dad5) at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:1651) at ognl.ASTProperty.setValueBody(ASTProperty.java:101) at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:177) at ognl.SimpleNode.setValue(SimpleNode.java:246) at ognl.ASTChain.setValueBody(ASTChain.java:172) at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:177) at ognl.SimpleNode.setValue(SimpleNode.java:246) at ognl.Ognl.setValue(Ognl.java:476) ... - Why is that happening? cu mathias No virus found in this incoming message. Checked by AVG - www.avg.com Version: 8.5.387 / Virus Database: 270.13.16/2240 - Release Date: 07/15/09 17:58:00
Freemarker and Select Tag
Hello, Platform : Struts 2, EJB 3.0, Glassfish 2.1 I'm having trouble using the Freemarker equivalent of the JSP Struts 2 Select Tag. I need to convert: into the Freemarker equivalent. userTypes is an application defined attribute. I have checked the existence of the attribute within the page and it is shown as expected. My List/Map is defined as Map userTypes = new HashMap(); userTypes.put(1, "AGENCY_USER"); userTypes.put(2, "SHOP_USER"); userTypes.put(3, "TOUR_OPERATOR_USER"); I have tried the following, none of which work (or work correclty). <@s.select list=application.userTypes/> -- elements are placed into the select box, but are valued as 1=AGENCY_USER, 2=SHOP_USER The following produce empty select boxes (or errors) <@s.select list="application.userTypes"/> <@s.select list="${application.userTypes}"/> Does anybody have any ideas ? Thanks - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Struts2 Action Class and EJB Injection
Thanks for the example. I shall download the source and give it a go. Thanks again. Nathan Schulte wrote: Robin Mannering mtndesigns.co.uk> writes: Can you please tell me how you obtained the EJB plugin and a short example of using it. I would prefer to use this if possible. Sorr, I misspoke earlier. I'm actually using the EJB3 JBoss Plugin, from here http://cwiki.apache.org/S2PLUGINS/ejb3-jboss-plugin.html. However, browsing the source for the EJB3 Plugin, the annotations and even classes are named the same, so the following example should still apply; http://pastebin.com/f7053a2bc. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org No virus found in this incoming message. Checked by AVG - www.avg.com Version: 8.5.387 / Virus Database: 270.13.14/2238 - Release Date: 07/14/09 18:03:00
Re: Struts2 Action Class and EJB Injection
Can you please tell me how you obtained the EJB plugin and a short example of using it. I would prefer to use this if possible. Nathan Schulte wrote: Robin Mannering wrote: Is there anybody that is using Struts2 as the 'frontend' to an EJB 3 'backend' and what solution do you currently employ. I am using the described setup, yes. Our solution was to use the mentioned EJB3 plugin and it's @InjectEJB annotation. It works well, I have not had any issues thus far. Wes Wannemacher wrote: Would anyone else be interested in an ObjectFactory based plugin? If so, would any of you also want it to work with Spring? I am interested in this, particularly for supporting persistence annotations, like the aforementioned @PersistenceContext. Most of the persistence support that I have seen for struts, and the questions posted regarding persistence, all seem to be using application managed persistence. Getting things to work with CMT would be excellent. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org No virus found in this incoming message. Checked by AVG - www.avg.com Version: 8.5.387 / Virus Database: 270.13.14/2238 - Release Date: 07/14/09 18:03:00
Re: Struts2 Action Class and EJB Injection
Yes, using annotations would be the ideal method. I think I remember reading that declaring beans as 'remote' when this is not that case, may cause unnecessary serialization/deserialization as calls are supposedly being made remotely. Depending on the EJB app server configuration. Obviously, this could cause significant overhead when returning large result sets from a session bean. I've yet to find where I read that but will update this thread if/when I do. Robin Wes Wannemacher wrote: I don't see anything wrong with that. I'd still like to eventually create a plugin that removes the need to do that in your execute method. The EJB spec added those annotations, so I'd like to figure out a way to honor them (cleanly). -Wes On Wed, Jul 15, 2009 at 10:37 AM, Robin Mannering wrote: Hi Wes, I found a resource on the web that seems to be a simpler solution: InitialContext ic = new InitialContext(); UserServiceBeanLocal userService = (UserServiceBeanLocal) ic.lookup(UserServiceBeanLocal.class.getName()); As in the web resource I found, it was necessary to change @Local to @Remote in the session bean for it to be found correctly. It worked perfectly using the above. Here is a link to the resource. What do you think of this solution? http://www.coderanch.com/t/58279/Struts/Connecting-ejb-session-bean-from Thanks Robin Wes Wannemacher wrote: You are right, there is only one, the other one in that list is a jboss-ejb plugin. Take a look at the source for the plugin, it is not particularly complex and I know the author is lurking around here somewhere. I would suggest that you do one of two things - 1. Create an interceptor, probably identical to the one in the plugin. If you have troubles, bring them to the list, we'll help. 2. Create an object factory implementation that creates actions using your container's semantics. Again, if you have troubles, bring 'em back here, we'll help you. -Wes On Wed, Jul 15, 2009 at 9:48 AM, Robin Mannering wrote: Many thanks for the prompt and detailed reply. I understand why the use of injection does not work now within a Struts2 action class. However, there only seems one EJB plugin available, which doesn't actually have a download available and hasn't had for some time it appears. http://code.google.com/p/struts2ejb3/downloads/list I'm wary to trust in a plugin that doesn't appear to be currently maintained (available to download). Is there anybody that is using Struts2 as the 'frontend' to an EJB 3 'backend' and what solution do you currently employ. Thanks Robin Wes Wannemacher wrote: The difference is that the container did not instantiate your struts action, struts did. There are EJB plugins available, check the plugin registry. http://cwiki.apache.org/S2PLUGINS/home.html The ones I have seen are based on injection via interceptor. I've toyed with the notion of creating an ObjectFactory based plugin so that struts can delegate creation of action classes to the ejb container. This would allow for injection for more than just @EJB (@PersistenceContext comes to mind). The only issue is that it doesn't seem like we see much traffic on here from ejb users. Would anyone else be interested in an ObjectFactory based plugin? If so, would any of you also want it to work with Spring? The interceptor-based solution works good because it doesn't interfere with object-creation-based plugins like spring/guice/etc. -Wes On Wed, Jul 15, 2009 at 9:21 AM, Robin Mannering wrote: Hello, Platform : Struts 2, EJB 3.0, Glassfish 2.1 I wish to obtain a reference to an EJB using injection. This works fine within a servlet, but from within a Struts2 action class, all references to injected EJB variables hold a 'null' reference. I've included a portion of my action class below. I'm confused as to why a Servlet has no trouble using injection as compared to the Struts 2 action class. Both the servlet and action class reside in the same Web application. Does anybody have any ideas? /public class UserAction extends ActionSupport implements ServletRequestAware, SessionAware { private static Logger logger = Logger.getLogger(SetupServlet.class); @EJB SetupServiceBeanLocal setupService; @EJB UserServiceBeanLocal userService; ... }/ No virus found in this incoming message. Checked by AVG - www.avg.com Version: 8.5.387 / Virus Database: 270.13.14/2238 - Release Date: 07/14/09 18:03:00 No virus found in this incoming message. Checked by AVG - www.avg.com Version: 8.5.387 / Virus Database: 270.13.14/2238 - Release Date: 07/14/09 18:03:00 ---
Re: Struts2 Action Class and EJB Injection
Hi Wes, I found a resource on the web that seems to be a simpler solution: InitialContext ic = new InitialContext(); UserServiceBeanLocal userService = (UserServiceBeanLocal) ic.lookup(UserServiceBeanLocal.class.getName()); As in the web resource I found, it was necessary to change @Local to @Remote in the session bean for it to be found correctly. It worked perfectly using the above. Here is a link to the resource. What do you think of this solution? http://www.coderanch.com/t/58279/Struts/Connecting-ejb-session-bean-from Thanks Robin Wes Wannemacher wrote: You are right, there is only one, the other one in that list is a jboss-ejb plugin. Take a look at the source for the plugin, it is not particularly complex and I know the author is lurking around here somewhere. I would suggest that you do one of two things - 1. Create an interceptor, probably identical to the one in the plugin. If you have troubles, bring them to the list, we'll help. 2. Create an object factory implementation that creates actions using your container's semantics. Again, if you have troubles, bring 'em back here, we'll help you. -Wes On Wed, Jul 15, 2009 at 9:48 AM, Robin Mannering wrote: Many thanks for the prompt and detailed reply. I understand why the use of injection does not work now within a Struts2 action class. However, there only seems one EJB plugin available, which doesn't actually have a download available and hasn't had for some time it appears. http://code.google.com/p/struts2ejb3/downloads/list I'm wary to trust in a plugin that doesn't appear to be currently maintained (available to download). Is there anybody that is using Struts2 as the 'frontend' to an EJB 3 'backend' and what solution do you currently employ. Thanks Robin Wes Wannemacher wrote: The difference is that the container did not instantiate your struts action, struts did. There are EJB plugins available, check the plugin registry. http://cwiki.apache.org/S2PLUGINS/home.html The ones I have seen are based on injection via interceptor. I've toyed with the notion of creating an ObjectFactory based plugin so that struts can delegate creation of action classes to the ejb container. This would allow for injection for more than just @EJB (@PersistenceContext comes to mind). The only issue is that it doesn't seem like we see much traffic on here from ejb users. Would anyone else be interested in an ObjectFactory based plugin? If so, would any of you also want it to work with Spring? The interceptor-based solution works good because it doesn't interfere with object-creation-based plugins like spring/guice/etc. -Wes On Wed, Jul 15, 2009 at 9:21 AM, Robin Mannering wrote: Hello, Platform : Struts 2, EJB 3.0, Glassfish 2.1 I wish to obtain a reference to an EJB using injection. This works fine within a servlet, but from within a Struts2 action class, all references to injected EJB variables hold a 'null' reference. I've included a portion of my action class below. I'm confused as to why a Servlet has no trouble using injection as compared to the Struts 2 action class. Both the servlet and action class reside in the same Web application. Does anybody have any ideas? /public class UserAction extends ActionSupport implements ServletRequestAware, SessionAware { private static Logger logger = Logger.getLogger(SetupServlet.class); @EJB SetupServiceBeanLocal setupService; @EJB UserServiceBeanLocal userService; ... }/ No virus found in this incoming message. Checked by AVG - www.avg.com Version: 8.5.387 / Virus Database: 270.13.14/2238 - Release Date: 07/14/09 18:03:00 No virus found in this incoming message. Checked by AVG - www.avg.com Version: 8.5.387 / Virus Database: 270.13.14/2238 - Release Date: 07/14/09 18:03:00
Re: Struts2 Action Class and EJB Injection
Many thanks for the prompt and detailed reply. I understand why the use of injection does not work now within a Struts2 action class. However, there only seems one EJB plugin available, which doesn't actually have a download available and hasn't had for some time it appears. http://code.google.com/p/struts2ejb3/downloads/list I'm wary to trust in a plugin that doesn't appear to be currently maintained (available to download). Is there anybody that is using Struts2 as the 'frontend' to an EJB 3 'backend' and what solution do you currently employ. Thanks Robin Wes Wannemacher wrote: The difference is that the container did not instantiate your struts action, struts did. There are EJB plugins available, check the plugin registry. http://cwiki.apache.org/S2PLUGINS/home.html The ones I have seen are based on injection via interceptor. I've toyed with the notion of creating an ObjectFactory based plugin so that struts can delegate creation of action classes to the ejb container. This would allow for injection for more than just @EJB (@PersistenceContext comes to mind). The only issue is that it doesn't seem like we see much traffic on here from ejb users. Would anyone else be interested in an ObjectFactory based plugin? If so, would any of you also want it to work with Spring? The interceptor-based solution works good because it doesn't interfere with object-creation-based plugins like spring/guice/etc. -Wes On Wed, Jul 15, 2009 at 9:21 AM, Robin Mannering wrote: Hello, Platform : Struts 2, EJB 3.0, Glassfish 2.1 I wish to obtain a reference to an EJB using injection. This works fine within a servlet, but from within a Struts2 action class, all references to injected EJB variables hold a 'null' reference. I've included a portion of my action class below. I'm confused as to why a Servlet has no trouble using injection as compared to the Struts 2 action class. Both the servlet and action class reside in the same Web application. Does anybody have any ideas? /public class UserAction extends ActionSupport implements ServletRequestAware, SessionAware { private static Logger logger = Logger.getLogger(SetupServlet.class); @EJB SetupServiceBeanLocal setupService; @EJB UserServiceBeanLocal userService; ... }/ No virus found in this incoming message. Checked by AVG - www.avg.com Version: 8.5.387 / Virus Database: 270.13.14/2238 - Release Date: 07/14/09 18:03:00
Struts2 Action Class and EJB Injection
Hello, Platform : Struts 2, EJB 3.0, Glassfish 2.1 I wish to obtain a reference to an EJB using injection. This works fine within a servlet, but from within a Struts2 action class, all references to injected EJB variables hold a 'null' reference. I've included a portion of my action class below. I'm confused as to why a Servlet has no trouble using injection as compared to the Struts 2 action class. Both the servlet and action class reside in the same Web application. Does anybody have any ideas? /public class UserAction extends ActionSupport implements ServletRequestAware, SessionAware { private static Logger logger = Logger.getLogger(SetupServlet.class); @EJB SetupServiceBeanLocal setupService; @EJB UserServiceBeanLocal userService; ... }/
Interceptor Use
Hello, Struts 2.1.6 I wish to ensure a user is logged into an application before allowing him/her to execute certain tasks. Would using an Interceptor be a good way to go? My idea is to retrieve session data in the intercept() method of the interceptor and verify a certain attribute is held in the session. If it is not, I would then like to redirect the user to a login page with an appropriate error message. Is this an approriate use of interceptors? Previously, I simply had a verifyLoginStatus() method in a base action class which I extended in actions I wanted to protect. I'd appreciate any thoughts... Thanks Robin - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Struts 2 and Velocity
Hi Dave, It worked ! It seems to be case sensitive. Thanks for your help. Can you please tell me how you knew to specify 'fieldName' ? I cannot find it documented anywhere Dave Newton wrote: It might be fieldName; case-sensitive. I'm not very familiar with the Velocity tag support, but it may be similar to Freemarker in that some tags are in-line tags, some are block tags, and decisions were made at some point to try and cover the most common use-case. If that's the case then you'll probably have to loop over the field names of interest. Dave Robin Mannering wrote: Thanks for your response. Unfortunately, #sfielderror ("fieldname=username") does not work. All the current field errors are rendered in an unordered list. Using struts2 tags, it would be: field1 field2 OR These are two tags nested which I'm having trouble translating into Velocity. Any other ideas? Dave Newton wrote: Robin Mannering wrote: From the documentation at http://struts.apache.org/2.1.6/docs/velocity-tags.html, I see the format is: #s**tag **(...) ... #end However, I'm having difficult using the tags. The following is ok and works as expected #stextfield ("label=Employee Name" "name=empname" "size=15" "maxlength=10") However, I would like to display fieldErrors as I need by name. I'm trying the following which doesn't seem to work. #sfielderror #sparam ("value=username") #end The 'end' tag is not expected on this one Can anybody point me in the right direction? Does #sfielderror ("fieldname=username") not work, or do you need multiple fields? - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org No virus found in this incoming message. Checked by AVG - www.avg.com Version: 8.5.375 / Virus Database: 270.12.93/2205 - Release Date: 06/27/09 05:53:00
Re: Struts 2 and Velocity
Thanks for your response. Unfortunately, #sfielderror ("fieldname=username") does not work. All the current field errors are rendered in an unordered list. Using struts2 tags, it would be: field1 field2 OR These are two tags nested which I'm having trouble translating into Velocity. Any other ideas? Dave Newton wrote: Robin Mannering wrote: From the documentation at http://struts.apache.org/2.1.6/docs/velocity-tags.html, I see the format is: #s**tag **(...) ... #end However, I'm having difficult using the tags. The following is ok and works as expected #stextfield ("label=Employee Name" "name=empname" "size=15" "maxlength=10") However, I would like to display fieldErrors as I need by name. I'm trying the following which doesn't seem to work. #sfielderror #sparam ("value=username") #end The 'end' tag is not expected on this one Can anybody point me in the right direction? Does #sfielderror ("fieldname=username") not work, or do you need multiple fields? Dave - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org No virus found in this incoming message. Checked by AVG - www.avg.com Version: 8.5.375 / Virus Database: 270.12.93/2205 - Release Date: 06/27/09 05:53:00
Struts 2 and Velocity
Hi all I've recently switched from Struts 1.x to Struts 2.1.6 and would like to continue using velocity to render the view. I also wish to take advantage of the Struts 2 tag library by using velocity directly. From the documentation at http://struts.apache.org/2.1.6/docs/velocity-tags.html, I see the format is: #s**tag **(...) ... #end However, I'm having difficult using the tags. The following is ok and works as expected #stextfield ("label=Employee Name" "name=empname" "size=15" "maxlength=10") However, I would like to display fieldErrors as I need by name. I'm trying the following which doesn't seem to work. #sfielderror #sparam ("value=username") #end The 'end' tag is not expected on this one Can anybody point me in the right direction? Thanks Robin - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: ActionServlet failing to load
Excellent, tried running that JSP and it revealed the true error: A missing jar file on the deployment box. The jar is expected in tomcat/common/lib directory. I've added it to my application lib directory and the problem has disappeared. Thanks for your help Robin The error shown: 17-Jul 12:31:12 ERROR TP-Processor5 [StandardWrapperValve.invoke] Servlet.service() for servlet jsp threw exception java.lang.NoClassDefFoundError: org/apache/commons/collections/FastHashMap at org.apache.struts.action.ActionServlet.(ActionServlet.java:348) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:494) at java.lang.Class.newInstance0(Class.java:350) at java.lang.Class.newInstance(Class.java:303) at org.apache.jsp.pages.test_jsp._jspService(org.apache.jsp.pages.test_jsp:47) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:325) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) at org.apache.catalina.valves.FastCommonAccessLogValve.invoke(FastCommonAccessLogValve.java:481) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:526) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:306) at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:385) at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:745) at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:675) at org.apache.jk.common.SocketConnection.runIt(ChannelSocket.java:868) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684) at java.lang.Thread.run(Thread.java:595) From: "Frank W. Zammetti" <[EMAIL PROTECTED]> Reply-To: "Struts Users Mailing List" To: "Struts Users Mailing List" CC: user@struts.apache.org Subject: Re: ActionServlet failing to load Date: Sun, 17 Jul 2005 12:18:14 -0400 (EDT) Is there any chance struts.jar is simply not in the classpath? The stack trace seems to indicate your not even getting into Struts code, so its I think either (a) not finding the ActionServlet class or (b) failing during construction. The first seems far more likely. I suppose an easy way to test would be to remove the ActionServlet entry from web.xml, then just have a simple JSP that tries to dynamically load the class... <%@ page language="java" import="org.apache.struts.action.*" %> <% try { Class clazz = Class.forName("org.apache.struts.action.ActionServlet"); ActionServlet as = (ActionServlet)clazz.newInstance(); } catch (Exception e) { e.printStackTrace(); } %> ...and see if you get an exception... Looking at the ActionServlet source for 1.2.6, unless I'm missing something, it's just using the default constructor, so I very much doubt its a construction problem. -- Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies http://www.omnytex.com On Sun, July 17, 2005 12:02 pm, Robin Mannering said: > Sure, I've just included the relevant bits I hope. > > The strtup serlvet loads just fine by the way.. > > web.xml snippet > --- > > > > >action > org.apache.struts.action.ActionServlet > >config >/WEB-INF/struts-config.xml > > >debug >2
Re: ActionServlet failing to load
Sure, I've just included the relevant bits I hope. The strtup serlvet loads just fine by the way.. web.xml snippet --- action org.apache.struts.action.ActionServlet config /WEB-INF/struts-config.xml debug 2 detail 2 application uk.co.sibo.buyone.struts.resources.sibo 2 StartupServlet uk.co.sibo.buyone.servlets.StartupServlet 3 action *.htm StartupServlet /servlets/StartupServlet Struts-config.xml snippet -- http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd";> index.jsp From: "Martin Gainty" <[EMAIL PROTECTED]> Reply-To: "Martin Gainty" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" Subject: Re: ActionServlet failing to load Date: Sun, 17 Jul 2005 10:43:29 -0400 Hard to decipher without knowing the 'root cause' can we see the contents of your web.xml index.jsp struts-config.xml M- - Original Message - From: "Robin Mannering" <[EMAIL PROTECTED]> To: Sent: Sunday, July 17, 2005 9:55 AM Subject: ActionServlet failing to load Hi all, I'm having a bizarre problem upon application startup where the ActionServlet is failing to load. This only happens on our deployment server, and the ActionServlet loads normally whilst on our dev machine. Does anyone have on ideas on the below error? I'd be very grateful for any help. 17-Jul 09:53:30 INFO main [ApplicationContext.log] Marking servlet action as unavailable 17-Jul 09:53:30 ERROR main [ApplicationContext.log] Servlet /sibo threw load() exception javax.servlet.ServletException: Error instantiating servlet class org.apache.struts.action.ActionServlet at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1034) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:900) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3823) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4087) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1011) at org.apache.catalina.core.StandardHost.start(StandardHost.java:718) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1011) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:440) at org.apache.catalina.core.StandardService.start(StandardService.java:450) at org.apache.catalina.core.StandardServer.start(StandardServer.java:683) at org.apache.catalina.startup.Catalina.start(Catalina.java:537) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409) 17-Jul 09:53:30 DEBUG main [JspRuntimeContext.] Parent class loader is: WebappClassLoader delegate: false repositories: /WEB-INF/classes/ --> Parent Classloader: [EMAIL PROTECTED] Many thanks Robin _ It's fast, it's easy and it's free. Get MSN Messenger 7.0 today! http://messenger.msn.co.uk - 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] _ Be the first to hear what's new at MSN - sign up to our free newsletters! http://www.msn.co.uk/newsletters - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
ActionServlet failing to load
Hi all, I'm having a bizarre problem upon application startup where the ActionServlet is failing to load. This only happens on our deployment server, and the ActionServlet loads normally whilst on our dev machine. Does anyone have on ideas on the below error? I'd be very grateful for any help. 17-Jul 09:53:30 INFO main [ApplicationContext.log] Marking servlet action as unavailable 17-Jul 09:53:30 ERROR main [ApplicationContext.log] Servlet /sibo threw load() exception javax.servlet.ServletException: Error instantiating servlet class org.apache.struts.action.ActionServlet at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1034) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:900) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3823) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4087) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1011) at org.apache.catalina.core.StandardHost.start(StandardHost.java:718) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1011) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:440) at org.apache.catalina.core.StandardService.start(StandardService.java:450) at org.apache.catalina.core.StandardServer.start(StandardServer.java:683) at org.apache.catalina.startup.Catalina.start(Catalina.java:537) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409) 17-Jul 09:53:30 DEBUG main [JspRuntimeContext.] Parent class loader is: WebappClassLoader delegate: false repositories: /WEB-INF/classes/ --> Parent Classloader: [EMAIL PROTECTED] Many thanks Robin _ It's fast, it's easy and it's free. Get MSN Messenger 7.0 today! http://messenger.msn.co.uk - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Bean Constants and JSP EL
Hi, Thanks for the help, but I went for a non static method in the end: /** * @return Returns the sTATUS_ONGOING. */ public String getSTATUS_ONGOING() { return STATUS_ONGOING; } which works with the following JSP/JSTL then it be draft etc I don't like being forced to use capitals in my bean getXXX() but it looks right in the JSP I guess -Original Message- From: Paul McCulloch [mailto:[EMAIL PROTECTED] Sent: 20 October 2004 15:32 To: 'Struts Users Mailing List' Subject: RE: Bean Constants and JSP EL See http://marc.theaimsgroup.com/?l=struts-user&m=109636066026332&w=2 > -Original Message----- > From: Robin Mannering [mailto:[EMAIL PROTECTED] > Sent: Wednesday, October 20, 2004 3:21 PM > To: [EMAIL PROTECTED] > Subject: Bean Constants and JSP EL > > > Hi, > > Wondering if anyone has encountered this before and perhaps > a solution :) > > I have constants defined in a regular Java bean class. ie. > > public static final String STATUS_DRAFT = "draft"; > > The bean has request scope in the page, no problem there, but > I can't reference this constant value using EL, ie. > > ${myObject.STATUS_DRAFT} > > Does anyone know how I can do this perhaps using a struts > tag, I'm miffed. Have already tried adding gettters by they > are of course static and so don't work. > > Any ideas would be great. > > Many thanks > > Robin > > > > > This e-mail and any attachments may be confidential and/or legally > privileged. If you have received this e-mail and you are not a named > addressee, please inform Landmark Information Group on 01491 413030 > and then delete the e-mail from your system. If you are not a named > addressee you must not use, disclose, distribute, copy, print or rely > on this e-mail. This email and any attachments have been scanned for > viruses and to the best of our knowledge are clean. To ensure > regulatory compliance and for the protection of our clients and > business, we may monitor and read e-mails sent to and from our > servers. > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > ** Axios Email Confidentiality Footer Privileged/Confidential Information may be contained in this message. If you are not the addressee indicated in this message (or responsible for delivery of the message to such person), you may not copy or deliver this message to anyone. In such case, you should destroy this message, and notify us immediately. If you or your employer does not consent to Internet email messages of this kind, please advise us immediately. Opinions, conclusions and other information expressed in this message are not given or endorsed by my Company or employer unless otherwise indicated by an authorised representative independent of this message. WARNING: While Axios Systems Ltd takes steps to prevent computer viruses from being transmitted via electronic mail attachments we cannot guarantee that attachments do not contain computer virus code. You are therefore strongly advised to undertake anti virus checks prior to accessing the attachment to this electronic mail. Axios Systems Ltd grants no warranties regarding performance use or quality of any attachment and undertakes no liability for loss or damage howsoever caused. ** - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This e-mail and any attachments may be confidential and/or legally privileged. If you have received this e-mail and you are not a named addressee, please inform Landmark Information Group on 01491 413030 and then delete the e-mail from your system. If you are not a named addressee you must not use, disclose, distribute, copy, print or rely on this e-mail. This email and any attachments have been scanned for viruses and to the best of our knowledge are clean. To ensure regulatory compliance and for the protection of our clients and business, we may monitor and read e-mails sent to and from our servers. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Bean Constants and JSP EL
Hi, Wondering if anyone has encountered this before and perhaps a solution :) I have constants defined in a regular Java bean class. ie. public static final String STATUS_DRAFT = "draft"; The bean has request scope in the page, no problem there, but I can't reference this constant value using EL, ie. ${myObject.STATUS_DRAFT} Does anyone know how I can do this perhaps using a struts tag, I'm miffed. Have already tried adding gettters by they are of course static and so don't work. Any ideas would be great. Many thanks Robin This e-mail and any attachments may be confidential and/or legally privileged. If you have received this e-mail and you are not a named addressee, please inform Landmark Information Group on 01491 413030 and then delete the e-mail from your system. If you are not a named addressee you must not use, disclose, distribute, copy, print or rely on this e-mail. This email and any attachments have been scanned for viruses and to the best of our knowledge are clean. To ensure regulatory compliance and for the protection of our clients and business, we may monitor and read e-mails sent to and from our servers. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Tracing action dispatching
Sorry, Missed a bit on my cut and paste, Last line og log4j.properties should have read: log4j.appender.file2.layout.ConversionPattern=%d{dd-MMM HH:mm:ss} %-5p %t%x [%C{1}.%M] %m%n -Original Message- From: Robin Mannering Sent: 06 October 2004 15:44 To: 'Struts Users Mailing List' Subject: RE: Tracing action dispatching Hi Laurent, I use log4j and the following log4j.properties file to achieve this. It gets the framework logging to one file (ie. struts) and my application logging to another file Can change the levels for each as desired as Struts put out a hefty chunk at debug level... but very useful... Hope it's of some help Contents of my log4j.properties __ log4j.debug=true # # set root Category priority to DEBUG and it's only Appender to "file2" log4j.rootCategory=DEBUG, file1 # Ensures uk.co.landmark logging does not also get added to the root log category log4j.additivity.uk.co.landmarkinfo=false log4j.logger.uk.co.landmarkinfo=DEBUG, file2 # "file1" RollingFileAppender options log4j.appender.file1=org.apache.log4j.RollingFileAppender log4j.appender.file1.Threshold=DEBUG log4j.appender.file1.ImmediateFlush=true log4j.appender.file1.File=/usr/tomcat/logs/framework_stl.log log4j.appender.file1.MaxFileSize=850KB log4j.appender.file1.MaxBackupIndex=1 # "file2" uses a Pattern Layout log4j.appender.file1.layout=org.apache.log4j.PatternLayout log4j.appender.file1.layout.ConversionPattern=%d{dd-MMM HH:mm:ss} %-5p %t%x [%C{1}.%M] %m%n # "file2" RollingFileAppender options log4j.appender.file2=org.apache.log4j.RollingFileAppender log4j.appender.file2.Threshold=DEBUG log4j.appender.file2.ImmediateFlush=true log4j.appender.file2.File=/usr/tomcat/logs/stl.log log4j.appender.file2.MaxFileSize=850KB log4j.appender.file2.MaxBackupIndex=1 # "file2" uses a Pattern Layout log4j.appender.file2.layout=org.apache.log4j.PatternLayout log4j.appender.file2.la -Original Message- From: news [mailto:[EMAIL PROTECTED] Behalf Of Laurent Duperval Sent: 06 October 2004 15:18 To: [EMAIL PROTECTED] Subject: Tracing action dispatching Hi, Is there a flag I can set so that Struts tells me what it's doing? I'm having a problem with one of my actions: when I click on it, I get a blank page and I don't understand why. I'd like to be able to see what decisions Sruts is taking in order to load my pages, to determine where I made a mistake in my config. Thanks, L - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This e-mail and any attachments may be confidential and/or legally privileged. If you have received this e-mail and you are not a named addressee, please inform Landmark Information Group on 01491 413030 and then delete the e-mail from your system. If you are not a named addressee you must not use, disclose, distribute, copy, print or rely on this e-mail. This email and any attachments have been scanned for viruses and to the best of our knowledge are clean. To ensure regulatory compliance and for the protection of our clients and business, we may monitor and read e-mails sent to and from our servers. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Tracing action dispatching
Hi Laurent, I use log4j and the following log4j.properties file to achieve this. It gets the framework logging to one file (ie. struts) and my application logging to another file Can change the levels for each as desired as Struts put out a hefty chunk at debug level... but very useful... Hope it's of some help Contents of my log4j.properties __ log4j.debug=true # # set root Category priority to DEBUG and it's only Appender to "file2" log4j.rootCategory=DEBUG, file1 # Ensures uk.co.landmark logging does not also get added to the root log category log4j.additivity.uk.co.landmarkinfo=false log4j.logger.uk.co.landmarkinfo=DEBUG, file2 # "file1" RollingFileAppender options log4j.appender.file1=org.apache.log4j.RollingFileAppender log4j.appender.file1.Threshold=DEBUG log4j.appender.file1.ImmediateFlush=true log4j.appender.file1.File=/usr/tomcat/logs/framework_stl.log log4j.appender.file1.MaxFileSize=850KB log4j.appender.file1.MaxBackupIndex=1 # "file2" uses a Pattern Layout log4j.appender.file1.layout=org.apache.log4j.PatternLayout log4j.appender.file1.layout.ConversionPattern=%d{dd-MMM HH:mm:ss} %-5p %t%x [%C{1}.%M] %m%n # "file2" RollingFileAppender options log4j.appender.file2=org.apache.log4j.RollingFileAppender log4j.appender.file2.Threshold=DEBUG log4j.appender.file2.ImmediateFlush=true log4j.appender.file2.File=/usr/tomcat/logs/stl.log log4j.appender.file2.MaxFileSize=850KB log4j.appender.file2.MaxBackupIndex=1 # "file2" uses a Pattern Layout log4j.appender.file2.layout=org.apache.log4j.PatternLayout log4j.appender.file2.la -Original Message- From: news [mailto:[EMAIL PROTECTED] Behalf Of Laurent Duperval Sent: 06 October 2004 15:18 To: [EMAIL PROTECTED] Subject: Tracing action dispatching Hi, Is there a flag I can set so that Struts tells me what it's doing? I'm having a problem with one of my actions: when I click on it, I get a blank page and I don't understand why. I'd like to be able to see what decisions Sruts is taking in order to load my pages, to determine where I made a mistake in my config. Thanks, L - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This e-mail and any attachments may be confidential and/or legally privileged. If you have received this e-mail and you are not a named addressee, please inform Landmark Information Group on 01491 413030 and then delete the e-mail from your system. If you are not a named addressee you must not use, disclose, distribute, copy, print or rely on this e-mail. This email and any attachments have been scanned for viruses and to the best of our knowledge are clean. To ensure regulatory compliance and for the protection of our clients and business, we may monitor and read e-mails sent to and from our servers. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: input form
Hi All, Just tried it out as defined in the struts link below and it works a treat... You don't need to instantiate an instance of the form, as this has already been done for you by the Struts framework before the Action is reached, and you don't need to set the form as a request attribute. My edit action method (the pre-populating action) is as follows: public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response ) throws Exception { UserRegForm userRegForm = (UserRegForm)form; userRegForm.setEmailAddressDisplay("defaultValue"); // return the ActionForward you use for success return mapping.findForward("success"); } -----Original Message- From: Robin Mannering [mailto:[EMAIL PROTECTED] Sent: 05 October 2004 17:55 To: Struts Users Mailing List Subject: RE: input form Hi All, Just chewing over this problem myself since it was brought up. The solution is here I believe, yet to implement it but I'm sure it'll work. http://struts.apache.org/faqs/newbie.html#prepopulate Hope this helps, not sure if it repeats what has been said already. Robin -Original Message- From: Fogleson, Allen [mailto:[EMAIL PROTECTED] Sent: 05 October 2004 17:32 To: 'Struts Users Mailing List' Subject: RE: input form Wendy, True enough, the original question though revolved around prepopulating the form from the DB before getting to the view of the submitting page so that initial page would have data pre-populated. :) Al -Original Message- From: Wendy Smoak [mailto:[EMAIL PROTECTED] Sent: Tuesday, October 05, 2004 12:05 PM To: Struts Users Mailing List Subject: Re: input form From: "Freddy Villalba A." <[EMAIL PROTECTED]> > I have a similar question: when you say create the action form and put it > into request scope... I suppose you refer to the same ActionForm that will > be used when, say, saving that prepopulated form again (the changes you've > made). Struts will instantiate the ActionForm and place it in the correct scope according to your struts-config.xml setup. All you have to do is use the 'form' object that's passed into your 'execute' (or similar) method, setting values as necessary. You have a reference to the form, you don't have to worry about where it lives, or put it anywhere. -- Wendy Smoak - 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] This e-mail and any attachments may be confidential and/or legally privileged. If you have received this e-mail and you are not a named addressee, please inform Landmark Information Group on 01491 413030 and then delete the e-mail from your system. If you are not a named addressee you must not use, disclose, distribute, copy, print or rely on this e-mail. This email and any attachments have been scanned for viruses and to the best of our knowledge are clean. To ensure regulatory compliance and for the protection of our clients and business, we may monitor and read e-mails sent to and from our servers. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This e-mail and any attachments may be confidential and/or legally privileged. If you have received this e-mail and you are not a named addressee, please inform Landmark Information Group on 01491 413030 and then delete the e-mail from your system. If you are not a named addressee you must not use, disclose, distribute, copy, print or rely on this e-mail. This email and any attachments have been scanned for viruses and to the best of our knowledge are clean. To ensure regulatory compliance and for the protection of our clients and business, we may monitor and read e-mails sent to and from our servers. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: input form
Hi All, Just chewing over this problem myself since it was brought up. The solution is here I believe, yet to implement it but I'm sure it'll work. http://struts.apache.org/faqs/newbie.html#prepopulate Hope this helps, not sure if it repeats what has been said already. Robin -Original Message- From: Fogleson, Allen [mailto:[EMAIL PROTECTED] Sent: 05 October 2004 17:32 To: 'Struts Users Mailing List' Subject: RE: input form Wendy, True enough, the original question though revolved around prepopulating the form from the DB before getting to the view of the submitting page so that initial page would have data pre-populated. :) Al -Original Message- From: Wendy Smoak [mailto:[EMAIL PROTECTED] Sent: Tuesday, October 05, 2004 12:05 PM To: Struts Users Mailing List Subject: Re: input form From: "Freddy Villalba A." <[EMAIL PROTECTED]> > I have a similar question: when you say create the action form and put it > into request scope... I suppose you refer to the same ActionForm that will > be used when, say, saving that prepopulated form again (the changes you've > made). Struts will instantiate the ActionForm and place it in the correct scope according to your struts-config.xml setup. All you have to do is use the 'form' object that's passed into your 'execute' (or similar) method, setting values as necessary. You have a reference to the form, you don't have to worry about where it lives, or put it anywhere. -- Wendy Smoak - 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] This e-mail and any attachments may be confidential and/or legally privileged. If you have received this e-mail and you are not a named addressee, please inform Landmark Information Group on 01491 413030 and then delete the e-mail from your system. If you are not a named addressee you must not use, disclose, distribute, copy, print or rely on this e-mail. This email and any attachments have been scanned for viruses and to the best of our knowledge are clean. To ensure regulatory compliance and for the protection of our clients and business, we may monitor and read e-mails sent to and from our servers. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: good book about struts
Hi, Can't say which is best as I have only read Struts in Action: Ted Husted. I find it invaluable as a reference and very easy to read ! I recommend it. Nice extra chapters too, especially the chapter on replacing JSPs with Velocity templates Robin -Original Message- From: Ye, Young [mailto:[EMAIL PROTECTED] Sent: 05 October 2004 16:39 To: 'Struts Users Mailing List' Subject: good book about struts Hi Struters, I am working in a project which use struts. I would like to buy a book about struts. But there are many of them in the market. Can you recommend the one which you think is best? Thanks a lot - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This e-mail and any attachments may be confidential and/or legally privileged. If you have received this e-mail and you are not a named addressee, please inform Landmark Information Group on 01491 413030 and then delete the e-mail from your system. If you are not a named addressee you must not use, disclose, distribute, copy, print or rely on this e-mail. This email and any attachments have been scanned for viruses and to the best of our knowledge are clean. To ensure regulatory compliance and for the protection of our clients and business, we may monitor and read e-mails sent to and from our servers. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: ActionError and JSP display
Thanks for all the help received on this one.. As pointed out by Joe, the tag is conditional, and when supplying the "parameter" atribute I get exactly what I need. For reference, it looks like this: <%-- Display error message keyed under 'usernameError' if it exists --%> ${error} Thanks again all! -Original Message- From: Joe Germuska [mailto:[EMAIL PROTECTED] Sent: 05 October 2004 14:00 To: Struts Users Mailing List Subject: RE: ActionError and JSP display At 1:45 PM +0100 10/5/04, Robin Mannering wrote: >Hi, > > >I was intending to use , >specifying the property for display, but it still doesn't allow me >to test for it's existence. > > >What I'd like to do is test if an error exists, then add a new HTML >table row and cell into the output containing the error message, >otherwise I do not want to create the HTML table row and cell at all. > >Is there a way to do this ? Personally, I think is "the old way", although at least one committer has expressed a preference for it. I prefer It is essentially a combination conditional block and iterator. Here is my "standard" error messages JSP block: By default, it looks for an ActionMessages object saved using Struts' "saveErrors" semantics (that is, stored in the request under "org.apache.struts.action.ERROR" You can set the "message" attribute to "true" to get "messages" instead, and you can set the "name" attribute to fetch any arbitrary ActionMessages. Furthermore, you can use the "property" attribute to constrain the condition to only if the ActionMessages contains messages for the given property. If you're not using the JSTL, you can use instead of to display the message itself. And, of course, you can use table rows instead of divs to wrap each message provided by the iterator. http://struts.apache.org/userGuide/struts-html.html#messages Hope this helps... Joe -- Joe Germuska [EMAIL PROTECTED] http://blog.germuska.com "In fact, when I die, if I don't hear 'A Love Supreme,' I'll turn back; I'll know I'm in the wrong place." - Carlos Santana This e-mail and any attachments may be confidential and/or legally privileged. If you have received this e-mail and you are not a named addressee, please inform Landmark Information Group on 01491 413030 and then delete the e-mail from your system. If you are not a named addressee you must not use, disclose, distribute, copy, print or rely on this e-mail. This email and any attachments have been scanned for viruses and to the best of our knowledge are clean. To ensure regulatory compliance and for the protection of our clients and business, we may monitor and read e-mails sent to and from our servers. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: ActionError and JSP display
Hi, I was intending to use , specifying the property for display, but it still doesn't allow me to test for it's existence. What I'd like to do is test if an error exists, then add a new HTML table row and cell into the output containing the error message, otherwise I do not want to create the HTML table row and cell at all. Is there a way to do this ? Thanks Robin -Original Message- From: news [mailto:[EMAIL PROTECTED] Behalf Of Jeff Beal Sent: 05 October 2004 13:40 To: [EMAIL PROTECTED] Subject: Re: ActionError and JSP display Robin Mannering wrote: > Hi, > > > Platorm is : Tomcat 5, Struts 1.1 > > Context: HTML Form submissions and validation. > > > I'm trying to conditionally test for the existince of error messages by their keys. > And I'd then like to show the error with HTML formatting around it. > > > Basically, using tags, I'd like to do the same as the following following pseudo > code. > > > if (errorMessage named 'usernameError' exists) { > > showError('usernameError' + some html) > > } > > > The error message is set from within the Form class as: > > > errors.add("usernameError", new ActionError("errors.form.username.required")); > > > I've been trawling around and have found lots of references to > and then looping through each message using > but not a test for the existence of a particular message. > > > I'm trying to display the error message next to each appropriate form element rather > than in a list. I probably can't see the solution for looking. Can anyone help? > > > Many thanks > > Robin Read http://struts.apache.org/api/org/apache/struts/taglib/html/package-summary.html#doc.Other.errors, paying attention to the property attribute of html:errors -- Jeff This e-mail and any attachments may be confidential and/or legally privileged. If you have received this e-mail and you are not a named addressee, please inform Landmark Information Group on 01491 413030 and then delete the e-mail from your system. If you are not a named addressee you must not use, disclose, distribute, copy, print or rely on this e-mail. This email and any attachments have been scanned for viruses and to the best of our knowledge are clean. To ensure regulatory compliance and for the protection of our clients and business, we may monitor and read e-mails sent to and from our servers. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
ActionError and JSP display
Hi, Platorm is : Tomcat 5, Struts 1.1 Context: HTML Form submissions and validation. I'm trying to conditionally test for the existince of error messages by their keys. And I'd then like to show the error with HTML formatting around it. Basically, using tags, I'd like to do the same as the following following pseudo code. if (errorMessage named 'usernameError' exists) { showError('usernameError' + some html) } The error message is set from within the Form class as: errors.add("usernameError", new ActionError("errors.form.username.required")); I've been trawling around and have found lots of references to and then looping through each message using but not a test for the existence of a particular message. I'm trying to display the error message next to each appropriate form element rather than in a list. I probably can't see the solution for looking. Can anyone help? Many thanks Robin This e-mail and any attachments may be confidential and/or legally privileged. If you have received this e-mail and you are not a named addressee, please inform Landmark Information Group on 01491 413030 and then delete the e-mail from your system. If you are not a named addressee you must not use, disclose, distribute, copy, print or rely on this e-mail. This email and any attachments have been scanned for viruses and to the best of our knowledge are clean. To ensure regulatory compliance and for the protection of our clients and business, we may monitor and read e-mails sent to and from our servers. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
causing internal html and anchoring to fail.
Hi, Has anyone anecountered this problem before. When using , the browser mistakes internal links and anchors within a page to reference anchor points within another page. So what? Well, this forces a reload of the page rather than the browser simply snapping to the point in the page. In my application, this would require additional DB processes to be executed for the data that is already held in the HTML page on screen. It comes about because of the actual page being shown and the browser URL are different. i.e. the URL holds a reference to a struts action, while the browser recognises the internal HTML links in association with the HTML page name - myPage.jsp (due to the use of the element). Is there a way round this, other than removing the from the doc as this is not an option? Robin Mannering Java Web Developer - Legal & Finance Tel:01491 418957 Fax:01491 413031 Email: [EMAIL PROTECTED] Landmark Information Group - www.landmarkinfo.co.uk This e-mail and any attachments may be confidential and/or legally privileged. If you have received this e-mail and you are not a named addressee, please inform Landmark Information Group on 01491 413030 and then delete the e-mail from your system. If you are not a named addressee you must not use, disclose, distribute, copy, print or rely on this e-mail. This email and any attachments have been scanned for viruses and to the best of our knowledge are clean. To ensure regulatory compliance and for the protection of our clients and business, we may monitor and read e-mails sent to and from our servers. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]