Re: [S2] apply i18n on java entity from DB
Few more thoughts on this matter: I haven't explicitly said that the solution I've proposed is far from standard i18n functionality, it was my best choice for the given example. If the "Product" described in the first message is pure fiction and you have the ability to change the data model you can get rid of the multiple names from the "Product" entity, put a "unique_name", use it to point to resource in your bundle with some static prefix like "product.name.". The actual names of the items you'll store like standard message resources. You can even use database message resources if you are not fan of the properties files. This way you'll get rid of the custom internationalization algorithms but it's definitely not the easiest way to go. The good thing about this solution is that you can go with it as far as adding new language for product names becomes a matter of simple configuration. Regards, Dimitar Vlasev. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: [S2] apply i18n on java entity from DB
Hi Steven, I don't know what's the best practice but I'll give you my quick thoughts. It seems you have to implement some sort of logic (choosing the right name). The main question is where is the best place to put this kind of logic? IMO this kind of problems are solved using the "decorator pattern". In the given example I'd choose to create "decorator" class for the Product class public class LocaleAwareProduct extends Product { private Locale locale; private String displayName; private LocaleAwareProduct() { // hide the default constructor } private LocaleAwareProduct(Produt aProduct, Locale aLocale) { this.locale = aLocale; if ( "en".equalsIgnoreCase(aLocale.getLanguage()) ) { this.displayName = aProduct.englissh_name; } else { if ( "fr".equalsIgnoreCase(aLocale.getLanguage()) ) { this.displayName = aProduct.french_name; } { } } Wrapping "products" into "locale aware products" will enable you to fetch the display name of a product without implementing the logic into the "view component". NOTE: the Java code has been typed in text editor and have never been compiled so it might be buggy. Regards, Dimitar Vlasev - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: [S2 V2.0.14] value attribute has rtexprvalue=false - shouldn't it be rtexprvalue=true?
Robert, you might find some clues here http://struts.apache.org/2.x/docs/ognl.html (as well as links to the full OGNL documentation) - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Handling probel.
I'm surprised how many people are asking questions the way nobody can help them Which version of struts are you using? If I use your .do pattern as a sign i might roll the dice and guess looking the guts of the sacrificed animal you are using Struts 1.x, aren't you? you should have struts dispatcher servlet configured in your web.xml with some servlet mapping action org.apache.struts.action.ActionServlet config /WEB-INF/struts-config.xml 1 action /do/* If the poor animal died without being able to help me, and you are using Struts 2.x then you'll have a filter mapping struts2 org.apache.struts2.dispatcher.FilterDispatcher struts2 /* These configurations are used from Tomcat to determine which module will take care / work onto / your request. Look for any configuration that might interfere with Struts dispatcher configuration. There might be some security constraints that prevent action execution. This is what I can think of. You'll need to investigate it. Good luck. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Cannot find bean in any scope
1. Try this (I cite these tags on memory so excuse me if I'm not right with the tag names) The dvd list is present The dvd list is NOT present 2. If the dvd list is not present try to set a simple string bean into the request and include it in the page you're forwarding to Regards, Dimitar Vlasev - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: setting a text field
Hi, have you ever read something about struts forms before asking questions here? Don't feel offended but this is a base functionality and I'm pretty sure you will not receive much help about issues like this. And you'll need to provide at least the version of Struts you're using. I guess you're using Struts 1.x Setting the value of the form field in the action that precedes the forward to the jsp will do what you need if all your configurations are OK. The form field is property of a struts form configured for your action. If this does not ring any bells for you you'll really need to read something for the version of Struts you're using. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Dojo datetimepicker problem
Sure I succeeded wrapping the String to Date conversion outside of the action class with custom type conversion class. I guess I expected that when uses java.util.Date property when rendering the HTML, I will get the new value in the same property after submitting the form which holds the Since I don't think the automated String to Date conversion stated here http://struts.apache.org/2.0.14/docs/type-conversion.html will do well for real application I didn't even try to go this way. Having the ability to use static content as attribute value made the solution with custom type conversion class good enough and I didn't bother further with this. Regards, Dimitar Vlasev - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re:
You'll have to set the default value to your action property: private String medicalCheckup = "Yes"; public String getMedicalCheckup() { return medicalCheckup; } public void setMedicalCheckup(String medicalCheckup) { this.medicalCheckup = medicalCheckup; } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Dojo datetimepicker problem
> Though it would be even elegant enough solution if I was able to refer > to the static pattern String in the .jsp like that > > But I got exception: > According to TLD or attribute directive in tag file, attribute > displayFormat does not accept any expressions Accessing static properties resolved http://struts.apache.org/2.0.11.1/docs/ognl-basics.html -- ======= Dimitar Vlasev - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Dojo datetimepicker problem
Few findings: http://struts.apache.org/2.0.14/docs/type-conversion.html at section "Built in Type Conversion Support" documentation says: XWork will automatically handle the most common type conversion for you. This includes support for converting to and from Strings for each of the following: . -> dates - uses the SHORT format for the Locale associated with the current request . But I haven't tried yet to utilize this feature. This is what worked for me: What I've done was to create custom type conversion class --- public class ShortDateConverter extends StrutsTypeConverter { public final static String pattern = "dd.MM."; private final static SimpleDateFormat format = new SimpleDateFormat(pattern); public Object convertFromString(Map context, String[] values, Class toClass) { Date result = null; if (values != null && values.length > 0) { try { result = format.parse(values[0]); } catch (ParseException e) { throw new TypeConversionException("Error converting date from '" + values[0] + "', pattern: '" + pattern + "'"); } } return result; } public String convertToString(Map context, Object o) { return null; } } and applied it to the setter method within my action class: (it worked well both using annotation and -conversion.properties file) - @TypeConversion (type=ConversionType.CLASS, converter="test.ShortDateConverter") public void setADate(Date date) { ... Though it would be even elegant enough solution if I was able to refer to the static pattern String in the .jsp like that But I got exception: According to TLD or attribute directive in tag file, attribute displayFormat does not accept any expressions I hope these findings will help someone else. Regards, Dimitar Vlasev - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Dojo datetimepicker problem
Thank you Timothy, I've suspected something like that. Of course anyone can read Date from String but the question was is this behavior a bug or a feature. Musachy: has attribute "displayFormat" but not "format". Of course it's not user friendly format thus I can't really use it in application, however I run a test with the format defined in RFC3339 and I hit the same rock again (the automated conversion didn't happen). here is what's being generated from the - . Thank you guys, I appreciate your help. Regards, Dimitar Vlasev - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Dojo datetimepicker problem
Hi all, I'm using Struts 2.0.14. I'm experiencing the following problem: I tried to use datetimepicker in sample application and it worked fine except that the java.util.Date property does not retrieve the new value selected in the interface. I don't have more time today to check this out and will continue trying to fix it tomorrow. What's more weird if i have getter for a String property with the same name I'll get the text that's in the edit box rendered from Here are some snippets from my test application: struts.xml --- . tiles_test the JSP --- <%@ page contentType="text/html; charset=UTF-8" %> <%@ taglib prefix="s" uri="/struts-tags" %> User Details changed Submit Date the Action (implements RequestAware) -- private Date aDate = new Date() public String fetchDate() { OgnlValueStack valueStack = (OgnlValueStack) this.request.get("struts.valueStack"); log.info("- this.aDate: " + this.aDate.toString()); log.info("- vs: aDate: " +valueStack.findString("aDate")); log.info("- vs: dojo.aDate: " +valueStack.findString("dojo.aDate")); return Action.SUCCESS; } public Date getADate() { return aDate; } public void setADate(Date date) { log.info(" Date set to: " + date.toString()); aDate = date; } public void setADate(String s) { log.info(" this one is called :" + s); } console output -- 17:37:24,644 INFO [Test] this one is called :12/3/08 17:37:24,644 INFO [Test] - this.aDate: Tue Dec 02 17:37:24 EET 2008 17:37:24,644 INFO [Test] - vs: aDate: 12/2/08 17:37:24,644 INFO [Test] - vs: dojo.aDate: null as you can see setADate(Date date) never get's called. I've checked the request made from the browser (using FF with FireBug) and the post parameters were fine "aDate" and "dojo.aDate" where both set to the correct value 12/3/08 I appreciate greatly your help. Regards. -- === Dimitar Vlasev - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to place struts2-core.jar outside web-app.war?
Thank you very much Nils, you've spotted the problem - the action class was packed in a .jar file which was outside the .war module. When I placed it in the .war everything worked smoothly. Best regards, On Tue, Nov 25, 2008 at 1:14 PM, Nils-Helge Garli Hegvik <[EMAIL PROTECTED]> wrote: > You'll probably save yourself a lot of troubles putting the jar files > inside the WEB-INF/lib folder of your war. What was your structure > like when it didn't work? Was your actions in your war file as well? > > Nils-H > > On Tue, Nov 25, 2008 at 12:09 PM, Dimitar Vlasev <[EMAIL PROTECTED]> wrote: >> Hi, >> I'm having problem to configure web application enclosed in .ear module. >> I'm using Struts 2.0.12 and JBoss 4.2.3 running on java 1.6. >> >> The application is in .war module, which is placed inside .ear module. >> [In fact this is small test application for me to get used with the >> new features in Struts 2] >> When I implemented SessionAware in my test action, I had .ear >> deployment exception which said that classloader can't find >> org.apache.struts2.interceptor.SessionAware >> I can get around this problem if I place the struts2-core.jar outside >> the web-app.war but then I have problems referring to /struts-tags in >> .jsp files: >> <%@ taglib prefix="s" uri="/struts-tags" %> >> >> And I'm not sure whether other problems might appear with this >> configuration in future (like using themes which I thing depend on >> content in the /templates folder of the struts2-core.jar) >> >> Any ideas how to overcome this obstacle - I mean besides splitting the >> struts2-core.jar in two and placing it's parts where needed. >> >> Thank you in advance. >> >> -- >> === >> Dimitar Vlasev >> >> - >> 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] > > -- === Dimitar Vlasev - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
How to place struts2-core.jar outside web-app.war?
Hi, I'm having problem to configure web application enclosed in .ear module. I'm using Struts 2.0.12 and JBoss 4.2.3 running on java 1.6. The application is in .war module, which is placed inside .ear module. [In fact this is small test application for me to get used with the new features in Struts 2] When I implemented SessionAware in my test action, I had .ear deployment exception which said that classloader can't find org.apache.struts2.interceptor.SessionAware I can get around this problem if I place the struts2-core.jar outside the web-app.war but then I have problems referring to /struts-tags in .jsp files: <%@ taglib prefix="s" uri="/struts-tags" %> And I'm not sure whether other problems might appear with this configuration in future (like using themes which I thing depend on content in the /templates folder of the struts2-core.jar) Any ideas how to overcome this obstacle - I mean besides splitting the struts2-core.jar in two and placing it's parts where needed. Thank you in advance. -- === Dimitar Vlasev - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]