Re: exception with automatic formbean population
"Emmanuel Cohen" <[email protected]>
| Newsgroups | gmane.comp.java.strutscx.user |
|---|---|
| Message-ID | <000d01c3d9c2$20376550$f837fa51@ordi> |
Hi, I'm using arrays of Strings and call all my fields the same name. It works ok, yet with some arrangements. For instance I do not want to set an array length, so I do not initialize my arrays. And it works ok. Thanks. Emmanuel ----- Original Message ----- From: "Bernhard Woehrlin" <[email protected]> To: "'Emmanuel Cohen'" <[email protected]>; <[email protected]> Sent: Sunday, January 11, 2004 3:09 PM Subject: AW: [Strutscx-user] exception with automatic formbean population Hi Emmanuel, I just checked the example - to get the data out of the form I used an Array (sorry, the List just the other way to prepare the data for the form): Inside the bean: private String[] para = new String[3]; Inside the Action: String[] oldParas = infoForm.getPara(); // if you prefer a List do this... ArrayList newParas = new ArrayList(); for (int i = 0; i < oldParas.length; i++) { newParas.add(new String(oldParas[i].getBytes("ISO-8859-1"), encoding)); } // now iterate through this list or do whatever with it ... Replace para with value... But this is just a quick Sunday afternoon solution - there should be a way to handle a HashMap, too. Regards, Berny -----Ursprüngliche Nachricht----- Von: [email protected] [mailto:[email protected]] Im Auftrag von Emmanuel Cohen Gesendet: Sonntag, 11. Januar 2004 14:51 An: [email protected] Betreff: Re: [Strutscx-user] exception with automatic formbean population Thank you for your prompt answer, Bernhard. It seems that in strutscx-demo.war, your infoformbean is static. By using Map values, my formbean is dynamic (I can populate dynamically my bean with any form -dynamically created with xsl and fields names gotten on the fly -). The only fields and methods in my formbean are : private final Map values = new HashMap(); public void setValue(String key, Object value); public Object getValue(String key); which is enough to retrieve all fields names and values in the Map. I failed to see how I could replace this mechanism. Would you explain me how it works without Map in the case of strutscx ? Thank you very much, Emmanuel ----- Original Message ----- From: "Bernhard Woehrlin" <[email protected]> To: "'Emmanuel'" <[email protected]>; <[email protected]> Sent: Sunday, January 11, 2004 1:05 PM Subject: AW: [Strutscx-user] exception with automatic formbean population Hi Emmanuel, The reason of the error is: XML names cannot contain the character "(". One solution would be to replace the Map with a List. Check out the strutscx-demo.war for an respective example. - Maybe there are other solutions, too. But keep in mind: StrutsCXStandardDocumentBuilder will try to make XML elements out of the Request's parameter names. Hope this is of help for you. Regards, Berny -----Ursprüngliche Nachricht----- Von: [email protected] [mailto:[email protected]] Im Auftrag von Emmanuel Gesendet: Samstag, 10. Januar 2004 22:28 An: [email protected] Betreff: [Strutscx-user] exception with automatic formbean population Hi All, I use a formbean that retrieves information passed in a form, like this : public class InfoFormBean extends StrutsCXValidatorForm { ... private final Map values = new HashMap(); public void setValue(String key, Object value) { logger.debug("key:"+key); values.put(key, value); } public Object getValue(String key) { return values.get(key); } ... } ##and my form looks like : <form ...> <input name="value(key1)" type="text" /> <input name="value(prop1)" type="text" /> ... </form> ##The formbean is populated alright. The associated action is called and execute is code also. ##But after the action executes its forward to another page, I get the following exception : 2004-01-10 22:04:02,158 DEBUG - [StrutsCXStandardDocumentBuilder] CONSTRUCT request Parameter: action = UPDATE 2004-01-10 22:04:02,158 DEBUG - [StrutsCXStandardDocumentBuilder] CONSTRUCT request Parameter: value(key1) = townname MonitorFilter::Error: The name "value(key2)" is not legal for JDOM/XML elements: XML names cannot contain the character "(". MonitorFilter::A web application object caused an exception MonitorFilter::org.jdom.IllegalNameException: The name "value(key2)" is not legal for JDOM/XML elements: XML names cannot contain the character "(". at org.jdom.Element.setName(Element.java:217) at org.jdom.Element.<init>(Element.java:145) at org.jdom.Element.<init>(Element.java:158) etc.... ##I tried to reset the formbean before doing the forward, but the error is exactly the same. I do not need this information (value(key2)) anymore at that time. How could I get rid of that ? Thanks in advance. Emmanuel --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.555 / Virus Database: 347 - Release Date: 23/12/2003 ------------------------------------------------------- This SF.net email is sponsored by: Perforce Software. Perforce is the Fast Software Configuration Management System offering advanced branching capabilities and atomic changes on 50+ platforms. Free Eval! http://www.perforce.com/perforce/loadprog.html _______________________________________________ Strutscx-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/strutscx-user --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.560 / Virus Database: 352 - Release Date: 08/01/2004 ------------------------------------------------------- This SF.net email is sponsored by: Perforce Software. Perforce is the Fast Software Configuration Management System offering advanced branching capabilities and atomic changes on 50+ platforms. Free Eval! http://www.perforce.com/perforce/loadprog.html