old struts 1.3 app not work in GF3
I have an app written in 1.3.10 + Netbeans 6.8 + glassfishv2.1. It works fine both when GFv2.1 is run from Netbeans or standalone. I am trying to switch to GFv3. It still works if I start GFv3 in Netbeans. But if I run it in a standalone GFv3, it failed to start with message: [#|2010-04-javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=26;_ThreadName=Thread-1;|WebModule[/whale-war]PWC1396: Servlet /whale-war threw load() exception javax.servlet.UnavailableException: Parsing error processing resource path jndi:/server/whale-war/WEB-INF/struts-config.xml I tried to start it with a dummy struts-config.xml (with start and end tag only) and it failed with the same message. I expect the parsing of the xml is done by struts modules, but looks from above it is not. Any idea what's wrong? -- View this message in context: http://old.nabble.com/old-struts-1.3-app-not-work-in-GF3-tp28175468p28175468.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Struts 1: character encoding
The components I use NetBean, Glassfish, Struts 1, EJB, Toplink, jdbc, MySQL. Basically what I want is to extract info from a web site (utf8 encoded Chinese), store the info in MySQL, retrieve the info and display on my web site for user to update/change it. But I got problem on the character encoding. Here is briefly my logic and coding: (1) extract from a web page which uses UTF-8 encoded, my coding in an EJB run on glassfish: char c = (char) myInputStream.read(); Listbyte token; token.add((byte) c); byte[] ba = new byte[token.size()]; for (int i=0; itoken.size(); i++) { ba[i] = token.get(i); } String s = new String(ba, UTF-8); I know it can be simpler, but it's a copy of others coding + my amendment. But it works. (2) String s above is stored onto MySQL via toplink, jdbc. Table is DEFAULT CHARSET=utf8. The jdbc URL is jdbc:mysql://mysys:3306/testinguseUnicode=truecharacterEncoding=utf-8. (3) Retrieve by Struts Action via EJB. Both EJB and Action does not have change of string encoding. The Action put the Chinese string into a DynaForm, then to JSP. JSP has %...@page contentType=text/html pageEncoding=UTF-8% and it generates an html input form. (4) However, the Chinese characters were NOT displayed properly in the html form on IE. (5) Anyway, in the html form, I override the incorrect Chinese character by a writing pad with the correct characters (equivalent to unicode 9326 6c5f) and submit. Again, no re-encoding in the Action that process the update. The Action calls an EJB to update the database with the input data. But I found that the database was updated with ascii string amp;#37670;amp;#27743; (exactly this string, not its equivalent encoded). I feel somehow there is/are encoding changes done by the software components I use (Struts? toplink? jdbc?), but don't know which one and I may be wrong. If anybody has any idea on this problem please help. -- View this message in context: http://www.nabble.com/Struts-1%3A-character-encoding-tp25766281p25766281.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: [Struts 1.3] converter converts but not set property
Thanks for the reply. The warType is WarrType. The convert() method executed. It has correct input parm and output return (I've used debugger to check it). The copyProperties() just doesn't copy it after the convert(). That's why I have to add copyProperty() to explicitly copy warType. Arthur Neves wrote: BeansUtils just call your converter, if your form bean property warType, will be a 'WarrType' . On Wed, Sep 23, 2009 at 7:16 AM, senderj send...@hotmail.com wrote: I wrote a converter to convert a enum for BeanUtils.copyProperties(). I have this in my struts config: form-bean name=MyForm type=org.apache.struts.validator.DynaValidatorForm form-property name=warType type=java.lang.String/ Here is my converters (embedded class in my Action) public class MyConverter1 implements Converter { @Override public WarrType convert(Class c, Object s) { Object result = null; String ss = (String) s; if (c.getSimpleName().equals(WarrType)) { System.out.println(ss); if (ss.equals(NONE)) result = WarrType.NONE; if (ss.equals(CALL)) result = WarrType.CALL; if (ss.equals(PUT)) result = WarrType.PUT; } return (WarrType) result; } } and here is the code in my Action: MyConverter1 mc1 = new MyConverter1(); ConvertUtils.register(mc1, WarrType.class); BeanUtils.copyProperties(stk, form); I've ensured both Stk and form have the same name warType. But the copyProperties() takes care of all other properties, except the warType! I have another converter for a date properties coded in similar way and it works. Only this warType doesn't. I have checked the convert() method in MyConverter in debug mode and it can convert correctly. But the stk.warType was not set (although its setWarType() was run with correct parm and output). But if I add this code after the copyProperties() at the above, then it works BeanUtils.copyProperty(stk, warType, PropertyUtils.getSimpleProperty(form, warType)); Any idea why? -- View this message in context: http://www.nabble.com/-Struts-1.3--converter-converts-but-not-set-property-tp25531070p25531070.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org -- View this message in context: http://www.nabble.com/-Struts-1.3--converter-converts-but-not-set-property-tp25531070p25605191.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
[Struts 1.3] first time use custom converter not working
I have a class Stk with property warType of type enum WarrType public enum WarrType { NONE, CALL, PUT; } I have in my struts config form-bean name=MyForm type=org.apache.struts.validator.DynaValidatorForm form-property name=warType type=java.lang.String/ and in my Action MyConverter mc = new MyConverter(); ConvertUtils.register(mc, WarrType.class); PropertyUtils.copyProperties(stk, form); .. and embedded in the Action class public class MyConverter implements Converter { @Override public WarrType convert(Class c, Object s) { WarrType result = null; System.out.println(I am running); if (s.equals(NONE)) result = WarrType.NONE; return result; The problem is the convert() never executed. the copyProperties failed with ...had String ... expect WarrType Any idea why? -- View this message in context: http://www.nabble.com/-Struts-1.3--first-time-use-custom-converter-not-working-tp25531027p25531027.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
[Struts 1.3] converter converts but not set property
I wrote a converter to convert a enum for BeanUtils.copyProperties(). I have this in my struts config: form-bean name=MyForm type=org.apache.struts.validator.DynaValidatorForm form-property name=warType type=java.lang.String/ Here is my converters (embedded class in my Action) public class MyConverter1 implements Converter { @Override public WarrType convert(Class c, Object s) { Object result = null; String ss = (String) s; if (c.getSimpleName().equals(WarrType)) { System.out.println(ss); if (ss.equals(NONE)) result = WarrType.NONE; if (ss.equals(CALL)) result = WarrType.CALL; if (ss.equals(PUT)) result = WarrType.PUT; } return (WarrType) result; } } and here is the code in my Action: MyConverter1 mc1 = new MyConverter1(); ConvertUtils.register(mc1, WarrType.class); BeanUtils.copyProperties(stk, form); I've ensured both Stk and form have the same name warType. But the copyProperties() takes care of all other properties, except the warType! I have another converter for a date properties coded in similar way and it works. Only this warType doesn't. I have checked the convert() method in MyConverter in debug mode and it can convert correctly. But the stk.warType was not set (although its setWarType() was run with correct parm and output). But if I add this code after the copyProperties() at the above, then it works BeanUtils.copyProperty(stk, warType, PropertyUtils.getSimpleProperty(form, warType)); Any idea why? -- View this message in context: http://www.nabble.com/-Struts-1.3--converter-converts-but-not-set-property-tp25531070p25531070.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
logic:iterate
If I have a text input in my jsp named scoreNdays, I know I should declare my variable scoreNdays in the struts formbean with getter and setter like getScoreNdays(). Then it will work with the jsp. Now I have an iternation in my jsp like logic:iterate name=MainControlForm property=scoreItems id=score html:checkbox name=score property=scoreChkBox indexed=true/ html:text name=score property=scoreNdays size=2 readonly=true indexed=true/ . Since the two input are indexed, they generate a web form that post with parameter like score[1].scoreNdays. Then I don't know how I should declare the corresponding variables and getter setter in the formbean. Please help. -- View this message in context: http://www.nabble.com/logic%3Aiterate-tp25270728p25270728.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Struts and EJB 3
My env is Netbean with Glassfish. I am able to create a servlet to call EJB with this code: public class TryAdvise_create extends HttpServlet { @EJB AdviseFacadeRemote advBean; .. protected void processRequest(HttpServletRequest request, { .. Advise adv = new Advise(123, 123 Company); advBean.create(adv); It works great. But when doing the same on a Struts Action: public class TryAdviseAction extends Action { @EJB AdviseFacadeRemote advBean; .. public ActionForward execute(ActionMapping mapping, . { Advise a = advBean.find(new Long(1)); advBean is always null. Why? Please help. -- View this message in context: http://www.nabble.com/Struts-and-EJB-3-tp22368697p22368697.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org