Re: Problem assiging elements in to list
Just out of curiosity, when you say "All of this is done automatically by the framework" do you mean if you populate from a form? or how do you mean the framework does this automatically? Cesar - Original Message From: Dave Newton <[EMAIL PROTECTED]> To: Struts Users Mailing List Sent: Friday, March 14, 2008 10:27:19 AM Subject: Re: Problem assiging elements in to list --- Cesar Arevalo <[EMAIL PROTECTED]> wrote: > by the time you get to the for loop I don't see the list initialized, > unless you are doing this from your jsp I don't think it will work as how > you have it, a better way would be with a normal for like this : > > for (int index = 0; index < someLimit; index++) { >Person person = new Person(); >persons.add(index, person); > _logger.error("Person ::" + > person); > > e.persist(person); > } > > hope this helps. That would create a list of empty Person instances (then persist the last empty Person, but I'm assuming that's a typo). All of this is done automatically by the framework. > From: Vamsi Gmail! <[EMAIL PROTECTED]> > > I have a requirement where I need to assign a Objects to a list. > I tried the example given in showcase there is working (in the site). > But It is not assigning to that list > > I am also attaching code for your reference. > > [code] You never really state how you're expecting the list to be filled: is this from a form with multiple Person form fields, or...? Dave - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem assiging elements in to list
HI Vamsi, by the time you get to the for loop I don't see the list initialized, unless you are doing this from your jsp I don't think it will work as how you have it, a better way would be with a normal for like this : for (int index = 0; index < someLimit; index++) { Person person = new Person(); persons.add(index, person); _logger.error("Person ::" + person); e.persist(person); } hope this helps. Cesar - Original Message From: Vamsi Gmail! <[EMAIL PROTECTED]> To: Struts Users Mailing List Sent: Thursday, March 13, 2008 11:14:53 PM Subject: Problem assiging elements in to list Hi all, I have a requirement where I need to assign a Objects to a list. I tried the example given in showcase there is working (in the site). But It is not assigning to that list I am also attaching code for your refernce. ---Vamsi -Inline Attachment Follows- /* * $Id: PersonAction.java 471756 2006-11-06 15:01:43Z husted $ * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package test.actions; import java.util.ArrayList; import java.util.List; import javax.persistence.EntityManager; import javax.persistence.EntityTransaction; import javax.persistence.PersistenceUnit; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.hibernate.exception.ConstraintViolationException; import test.examples.Person; import com.opensymphony.xwork2.ActionSupport; @SuppressWarnings("serial") public class PersonAction extends ActionSupport { //private Person person; private List persons = new ArrayList(); private Log _logger = LogFactory.getLog(PersonAction.class); public List getPersons() { return persons; } public void setPersons(List persons) { this.persons = persons; } @SuppressWarnings("unchecked") public String save() { EntityManager e = SfmsEntityManagerFactory.getEntityManager(); EntityTransaction txn =e.getTransaction(); txn.begin(); try{ _logger.error("Person ::"); _logger.error("Person ::"); for (Object object :persons) { Person person = (Person) object; _logger.error("Person ::" + person); e.persist(person); } _logger.error("Person ::"); _logger.error("Person ::"); txn.commit(); addActionMessage("Record Added"); read(e); }catch(ConstraintViolationException e1) { addActionError("Record Already There"); }catch(IllegalStateException e1){ }catch(Exception e1) { addActionError("Error Inserting"); txn.rollback(); } return SUCCESS; } private void read(EntityManager e) { persons = e.createQuery("From Person").getResultList(); } } -Inline Attachment Follows- package test.examples; import static javax.persistence.FetchType.LAZY; import javax.persistence.Basic; import javax.persistence.Entity; import javax.persistence.Id; @Entity public class Person implements Persister{ @Id private String name; @Basic(fetch=LAZY) private int age; public String getName() { return name; } public int getAge() { return age; } public void setName(String name) { this.name = name; } public void setAge(int age) { this.age = age; } @Override public String toString() { return name + "" + age; } } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [ActionServlet] /WEB-INF/web.xml was not found
Hey, what version of the jboss-web.dtd are you using, see here for the types: http://www.jboss.org/j2ee/dtd/ I see that the context-root element is not in the http://www.jboss.org/j2ee/dtd/jboss-web.dtd, it is until http://www.jboss.org/j2ee/dtd/jboss-web_3_0.dtd that this element is present. HTH -Cesar - Original Message From: "ROWLAND, CLAY, ATTSI" <[EMAIL PROTECTED]> To: user@struts.apache.org Sent: Thursday, October 4, 2007 3:37:48 PM Subject: [ActionServlet] /WEB-INF/web.xml was not found hi. i'm trying to deploy my first struts 1.3.8 web app on jboss-4.2.1 on windows and am getting an exception when i deploy my .war file. 18:15:43,744 ERROR [ActionServlet] The /WEB-INF/web.xml was not found. (please let me know if you'd like to see the full exception text) however, web.xml exists inside my .war file in the WEB-INF dir (and as ActionServlet is only init'ed because it exists in the web.xml, i'm dumbfounded). the struts .jar files are in the WEB-INF/lib directory within the .war. here are my config files, all of which are in the WEB-INF dir: web.xml http://java.sun.com/j2ee/dtds/web-app_2_2.dtd";;> action org.apache.struts.action.ActionServlet config /WEB-INF/struts-config.xml 2 action *.do /WEB-INF/struts-bean.tld /WEB-INF/struts-bean.tld /WEB-INF/struts-html.tld /WEB-INF/struts-html.tld /WEB-INF/struts-logic.tld /WEB-INF/struts-logic.tld struts-config.xml http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd";;> jboss-web.xml Ticket i feel like i'm missing a simple configuration detail. if anyone has encountered this issue before, i'd love to hear how you resolved it. thanks. - 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]
Re: Struts validation error on Jdeveloper 10.1.3.3
These pages help you: http://www.penguin-soft.com/penguin/developer/struts/userGuide/dev_validator.html http://wiki.apache.org/jakarta-commons/ValidatorXmlFile The error is telling you that the 'arg0' should not be put there, maybe there is something wrong, hope those pages help you. -Cesar PS Found those pages while googling for "struts validatior dtd" - Original Message From: rapsy <[EMAIL PROTECTED]> To: user@struts.apache.org Sent: Thursday, October 4, 2007 12:02:11 PM Subject: Re: Struts validation error on Jdeveloper 10.1.3.3 I don't think that matters but I gave a try just in case. The error message is now changed to: (Error) Invalid element 'arg0' in content of 'field', expected elements '[msg, arg, var]'. Thanks for your reply! Cesar Arevalo wrote: > > Hey Rapsy, > > just a quick thought, shouldn't the arguments start at index 0? this > meaning that you should have > > > > > ?? > > -Cesar > > > - Original Message > From: rapsy <[EMAIL PROTECTED]> > To: user@struts.apache.org > Sent: Thursday, October 4, 2007 11:27:27 AM > Subject: Struts validation error on Jdeveloper 10.1.3.3 > > > > Hi, > > I am using struts 1.3.8 for my application. I am using Oracle Jdeveloper > IDE > ver 10.1.3.3.0. > I have created the following validation in validation.xml file. > > > > > > min0 > > max9 > > > When I run my application on JDeveloper I get the following list of > errors. > (Error) Invalid element 'arg1' in content of 'field', expected elements > '[msg, arg, var]'. > (Error) Element 'arg1' used but not declared. > XML-20137: (Error) Attribute 'name' used but not declared. > > Can someone tell me why I am getting these errors? Thank you! > > > > -- > View this message in context: > http://www.nabble.com/Struts-validation-error-on-Jdeveloper-10.1.3.3-tf4570539.html#a13045841 > Sent from the Struts - User mailing list archive at Nabble.com. > > > - > 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] > > > -- View this message in context: http://www.nabble.com/Struts-validation-error-on-Jdeveloper-10.1.3.3-tf4570539.html#a13046682 Sent from the Struts - User mailing list archive at Nabble.com. - 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]
Re: Struts validation error on Jdeveloper 10.1.3.3
Hey Rapsy, just a quick thought, shouldn't the arguments start at index 0? this meaning that you should have ?? -Cesar - Original Message From: rapsy <[EMAIL PROTECTED]> To: user@struts.apache.org Sent: Thursday, October 4, 2007 11:27:27 AM Subject: Struts validation error on Jdeveloper 10.1.3.3 Hi, I am using struts 1.3.8 for my application. I am using Oracle Jdeveloper IDE ver 10.1.3.3.0. I have created the following validation in validation.xml file. min0 max9 When I run my application on JDeveloper I get the following list of errors. (Error) Invalid element 'arg1' in content of 'field', expected elements '[msg, arg, var]'. (Error) Element 'arg1' used but not declared. XML-20137: (Error) Attribute 'name' used but not declared. Can someone tell me why I am getting these errors? Thank you! -- View this message in context: http://www.nabble.com/Struts-validation-error-on-Jdeveloper-10.1.3.3-tf4570539.html#a13045841 Sent from the Struts - User mailing list archive at Nabble.com. - 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]
[OT] Re: A try catch and return question
The blocks you mention achieve different results. In the FIRST block you will have to add a return statement for when an exception is thrown, this allows you to set the theReturnedObject to a value for when an exception is thrown. In the SECOND block if you are modifying theReturnedObject in the try block then you will have to take into account that an exception might occur and that this exception might affect the value of theReturnedObject. Oh and by the way, this is a struts mailing list :-) HTH -Cesar - Original Message From: "Zhang, Larry (L.)" <[EMAIL PROTECTED]> To: Struts Users Mailing List Sent: Monday, October 1, 2007 1:01:23 PM Subject: A try catch and return question I have a method having the following structure: public Object myMethod() { try { // some code return theReturnedObject, }catch{ // some code } finally { // some code } } Please let me know if the following version of code better than the above? public Object myMethod() { try { // some code }catch{ // some code } finally { // some code } return theReturnedObject, } The only difference is that the bottom one put the return down to the bottom of the method and take the return out of the try. Please let me know. - 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]
Re: Where are the logic: tags?
Oh and by the way, the logic tag is gone, IMO the struts2 guys did not want to invent the wheel again. And also IMO the struts2 tags are more concise to the framework and overlap less with what is already out there, like jstl. -Cesar - Original Message From: Cesar Arevalo <[EMAIL PROTECTED]> To: Struts Users Mailing List Sent: Monday, October 1, 2007 12:32:10 AM Subject: Re: Where are the logic: tags? For iterating over a value you can use the struts2 tag s:iterator: http://struts.apache.org/2.x/docs/iterator.html , however if you want a foreach loop you could use fmtl tag c:forEach: http://java.sun.com/javaee/5/docs/tutorial/doc/bnakh.html#bnakk HTH -Cesar - Original Message From: Marcos Hernandez <[EMAIL PROTECTED]> To: Struts Users Mailing List Sent: Monday, October 1, 2007 12:14:07 AM Subject: Where are the logic: tags? Hi guys Just today I found out that I miss them... Is there a way to create a for loop in Struts2? because I think a block of jsp code will not work there, what is required is a framework tag. Is the logic tag library gone? -- - Marcos H. You must be the change you wish to see in the world ~ Gandhi - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Where are the logic: tags?
For iterating over a value you can use the struts2 tag s:iterator: http://struts.apache.org/2.x/docs/iterator.html , however if you want a foreach loop you could use fmtl tag c:forEach: http://java.sun.com/javaee/5/docs/tutorial/doc/bnakh.html#bnakk HTH -Cesar - Original Message From: Marcos Hernandez <[EMAIL PROTECTED]> To: Struts Users Mailing List Sent: Monday, October 1, 2007 12:14:07 AM Subject: Where are the logic: tags? Hi guys Just today I found out that I miss them... Is there a way to create a for loop in Struts2? because I think a block of jsp code will not work there, what is required is a framework tag. Is the logic tag library gone? -- - Marcos H. You must be the change you wish to see in the world ~ Gandhi - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Plug in for Eclipse 3.2 to run struts applications
There is a very good eclipse plugin here http://www.jamesholmes.com/struts/console/ it might fit your needs. -Cesar www.arevalos.org - Original Message From: Arunkumar Balasubramanian <[EMAIL PROTECTED]> To: Struts Users Mailing List Sent: Sunday, September 30, 2007 12:47:49 AM Subject: Plug in for Eclipse 3.2 to run struts applications Hi Do any one have link where I can download plug in for eclipse 3.2 for running struts applications. I tried Easy Struts and it works only with eclipse 2.x and not with eclipse 3.2. I am running a application in my PC and need this plug in. If any one have link to download the plug in, that would be great. Thanks _ Explore the seven wonders of the world http://search.msn.com/results.aspx?q=7+wonders+world&mkt=en-US&form=QBRE - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How can I access a collection of object using struts tags?
Maybe it is a typo, shouldn't it say: "nested:write" I do them all the time. Regards -Cesar -Original Message- From: hk [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 22, 2007 6:47 PM To: user@struts.apache.org Subject: Re: How can I access a collection of object using struts tags? Thank you for the greate information. By the way, my Netbeans gives me an error message saying "netsted:write is not defined". nuwan chandrasoma-2 wrote: > > Hi, > > if you are using struts 1.x you can use nested tags, look at this link for > a > sample > > http://www.laliluna.de/struts-nested-iteration-tutorial.html > > Thanks, > > Nuwan > > > - Original Message - > From: "hk" <[EMAIL PROTECTED]> > To: > Sent: Tuesday, May 22, 2007 12:57 AM > Subject: How can I access a collection of object using struts tags? > > >> >> I have a bean, which has a class that contains a ArrayList of another >> class. >> In this case, how can I access the property of the last class in a JSP >> page. >> >> For example, the business object Movie has a class TitleStores that >> contains >> a property of titlestores, which is a conllection of a class store. And, >> I >> want to access and ourput a property of a store, such as storeID, name, >> etc >> by using struts tags, such as bean:write. >> >> >> public class Movie >> { >>private String studio = null; >>private Genres genres = null; // ArrayList >>private TitleStores titleStores = null; >>private String rating = null; >>private String language = null; >>private int availableStock = -1; // For test >>private CastMembers castMembers = null;// ArrayList >> >> } >> >> public class TitleStores { >> >>private ArrayList titleStores; >> >>private int storeID; >>private String name; >>private String phone; >>private String street; >>private String city; >>private String state; >>private String owner; >>private String zipCode; >>private String policy; >> } >> >> public class Store { >>private int storeID; >>private String name; >>private String phone; >>private String street; >>private String city; >>private String state; >>private String owner; >>private String zipCode; >>private String policy; >>//private Policies policies; >> ... >> } >> -- >> View this message in context: >> http://www.nabble.com/How-can-I-access-a-collection-of-object-using-struts-t ags--tf3793680.html#a10729836 >> Sent from the Struts - User mailing list archive at Nabble.com. >> >> >> - >> 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] > > > -- View this message in context: http://www.nabble.com/How-can-I-access-a-collection-of-object-using-struts-t ags--tf3793680.html#a10754952 Sent from the Struts - User mailing list archive at Nabble.com. - 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]
RE: [S2] Problem setting radio to default value from a Collection
Worked around this, putting this piece of code before the end of my body tag in the jsp page: document.getElementById('answer<s:property value="answer"/>').checked=true; However I don't like it. According to the documentation the radio should check the default to the answer value, because it has the same name as the property in my action, but it is not working this way. How can you set a default value for a radio tag if my list is a Collection? Thanks -Cesar -----Original Message- From: Cesar Arevalo [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 22, 2007 2:00 PM To: 'Struts Users Mailing List' Subject: [S2] Problem setting radio to default value from a Collection Hi All, I have a jsp with a radio tag setup like so: < /s:radio> What I display in the radio buttons are answers, once the userclicks on an answer the form is submitted, my action retrieves the correctanswer and puts it in both an id and an answer property defined in the sameaction. Now, what I want to show to the user is the correct answer after heselects any answer, even if it’s the correct one. However even though I havesetup my action with an id and answer property, the radio button does notdefault to the value I am putting in those properties. The documentationspecifies that this works for maps, so does radio buttons work the same way fora Collection? Or how do they work for setting checked options using a Collection?Can anyone help me? Thanks -Cesar - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[S2] Problem setting radio to default value from a Collection
Hi All, I have a jsp with a radio tag setup like so: < /s:radio> What I display in the radio buttons are answers, once the userclicks on an answer the form is submitted, my action retrieves the correctanswer and puts it in both an id and an answer property defined in the sameaction. Now, what I want to show to the user is the correct answer after heselects any answer, even if it’s the correct one. However even though I havesetup my action with an id and answer property, the radio button does notdefault to the value I am putting in those properties. The documentationspecifies that this works for maps, so does radio buttons work the same way fora Collection? Or how do they work for setting checked options using a Collection?Can anyone help me? Thanks -Cesar