|
View:
New views
9 Messages
—
Rating Filter:
Alert me
|
|
|
Property Mapping in a iteratorhello,
I have been looking at Struts2 for a couple of days now, it seems nice and easy to work with. I have a problem that I don't really understand, maybe I'm missing some config settings or something. Let's say that I want to display a list of persons, and for each person I want to see the name. This is very straightforward: <s:iterator value="people" var="p"> <div id="row_<s:property value="id"/>"> <s:property value="name" /> </div> </s:iterator> Easy enough, but if I miss-spell the property name, I get no error, only a blank value. Is there a struts way to prevent these kinds of things from happening - like get some sort of error message. By the way, I am using Struts 2.1.6 and I'm not sure if this is the proper mailing list for this framework. Are you guys dealing with both Struts and Struts2 issues? As I've seen so far, Struts2 is pretty different than Struts. If I'm not in the proper place, please point me in the right direction. thanks, alex --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
Re: Property Mapping in a iteratorHi Alex,
I think you might need to add <constant name="struts.devMode" value="true" /> in your struts.xml file. Quoting Alex Parvulescu <alex.parvulescu@...>: > hello, > > I have been looking at Struts2 for a couple of days now, it seems nice > and easy to work with. > > I have a problem that I don't really understand, maybe I'm missing > some config settings or something. > > Let's say that I want to display a list of persons, and for each > person I want to see the name. > This is very straightforward: > > <s:iterator value="people" var="p"> > <div id="row_<s:property value="id"/>"> > <s:property value="name" /> > </div> > </s:iterator> > > Easy enough, but if I miss-spell the property name, I get no error, > only a blank value. > Is there a struts way to prevent these kinds of things from happening > - like get some sort of error message. > > By the way, I am using Struts 2.1.6 and I'm not sure if this is the > proper mailing list for this framework. Are you guys dealing with both > Struts and Struts2 issues? As I've seen so far, Struts2 is pretty > different than Struts. > > If I'm not in the proper place, please point me in the right direction. > > thanks, > alex > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@... > For additional commands, e-mail: user-help@... > > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
<sx:tree> and <sx:treenode> tag not working in IEHi all,
I am new to struts2. I am using struts2's <sx:tree> and <sx:treenode> for generation of tree components. It works fine in Mozilla firefox. But when I open same URL in Internet explorer and clicks on any tree node it throws javascript error: Message: Unspecified error. Line: 3546 Char: 1 Code: 0 URI: http://localhost:8081/Struts-sample/struts/dojo/struts_dojo.js What could be the reason? I am using version 2.1.8. Thanks, Rupesh Mankar DISCLAIMER ========== This e-mail may contain privileged and confidential information which is the property of Persistent Systems Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Ltd. does not accept any liability for virus infected mails. --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
Re: Property Mapping in a iteratorhello,
I did it and got nothing :) This is from the logs INFO : 2009-11-12 13:39:55,290: CommonsLogger: Parsing configuration file [struts-default.xml] INFO : 2009-11-12 13:39:55,385: CommonsLogger: Parsing configuration file [struts.xml] INFO : 2009-11-12 13:39:55,388: CommonsLogger: Overriding property struts.i18n.reload - old value: false new value: true INFO : 2009-11-12 13:39:55,388: CommonsLogger: Overriding property struts.configuration.xml.reload - old value: false new value: true INFO : 2009-11-12 13:39:55,465: CommonsLogger: Initializing Struts-Spring integration... INFO : 2009-11-12 13:39:55,466: CommonsLogger: Setting autowire strategy to name INFO : 2009-11-12 13:39:55,466: CommonsLogger: ... initialized Struts-Spring integration successfully 2009-11-12 13:39:55.212::INFO: Started SocketConnector@...:8080 -- here comes the page load: WARN : 2009-11-12 13:40:11,597: CommonsLogger: Could not find property [struts.valueStack] WARN : 2009-11-12 13:40:13,703: CommonsLogger: Could not find property [org.apache.catalina.jsp_file] Can you explain a bit what this property does? On Thu, Nov 12, 2009 at 1:16 PM, carl ballantyne <carl.ballantyne@...> wrote: > Hi Alex, > > I think you might need to add <constant name="struts.devMode" value="true" > /> in your struts.xml file. > > > > Quoting Alex Parvulescu <alex.parvulescu@...>: > >> hello, >> >> I have been looking at Struts2 for a couple of days now, it seems nice >> and easy to work with. >> >> I have a problem that I don't really understand, maybe I'm missing >> some config settings or something. >> >> Let's say that I want to display a list of persons, and for each >> person I want to see the name. >> This is very straightforward: >> >> <s:iterator value="people" var="p"> >> <div id="row_<s:property value="id"/>"> >> <s:property value="name" /> >> </div> >> </s:iterator> >> >> Easy enough, but if I miss-spell the property name, I get no error, >> only a blank value. >> Is there a struts way to prevent these kinds of things from happening >> - like get some sort of error message. >> >> By the way, I am using Struts 2.1.6 and I'm not sure if this is the >> proper mailing list for this framework. Are you guys dealing with both >> Struts and Struts2 issues? As I've seen so far, Struts2 is pretty >> different than Struts. >> >> If I'm not in the proper place, please point me in the right direction. >> >> thanks, >> alex >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: user-unsubscribe@... >> For additional commands, e-mail: user-help@... >> >> > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@... > For additional commands, e-mail: user-help@... > > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
RE: Property Mapping in a iteratorHow are the person objects being populated? here is the sample configuration from showcase: <action name="enterPersonsInfo" method="input" class="org.apache.struts2.showcase.conversion.PersonAction"> <result>enterPersonInfo.jsp</result> </action> <action name="submitPersonInfo" method="submit" class="org.apache.struts2.showcase.conversion.PersonAction"> <result>showPersonInfo.jsp</result> <result name="input">enterPersonInfo.jsp</result> </action> <action name="showPersonJspCode"> <result type="plainText">/conversion/enterPersonInfo.jsp</result> </action> <action name="showPersonActionJavaCode"> <result type="plainText">/conversion/PersonAction.java.txt</result> </action> <action name="showPersonJavaCode"> <result type="plainText">/conversion/Person.java.txt</result> </action> here is enterPersonInfo.jsp which is used for all results to/fro enterPersonsInfo action input method <%@taglib prefix="s" uri="/struts-tags" %> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Showcase - Conversion - Populate Object into Struts' action List</title> </head> <body> <p/> An example populating a list of object (Person.java) into Struts' action (PersonAction.java) <p/> See the jsp code <s:url var="url" action="showPersonJspCode" namespace="/conversion" /><s:a href="%{#url}">here.</s:a><br/> See the code for PersonAction.java <s:url var="url" action="showPersonActionJavaCode" namespace="/conversion" /><s:a href="%{#url}">here.</s:a><br/> See the code for Person.java <s:url var="url" action="showPersonJavaCode" namespace="/conversion" /><s:a href="%{#url}">here.</s:a><br/> <p/> <s:actionerror /> <s:fielderror /> <s:form action="submitPersonInfo" namespace="/conversion" method="post"> <%-- The following is done Dynamically --%> <s:iterator value="new int[3]" status="stat"> <s:textfield label="%{'Person '+#stat.index+' Name'}" name="%{'persons['+#stat.index+'].name'}" /> <s:textfield label="%{'Person '+#stat.index+' Age'}" name="%{'persons['+#stat.index+'].age'}" /> </s:iterator> <%-- The following is done statically:- --%> <%-- <s:textfield label="Person 1 Name" name="persons[0].name" /> <s:textfield label="Person 1 Age" name="persons[0].age" /> <s:textfield label="Person 2 Name" name="persons[1].name" /> <s:textfield label="Person 2 Age" name="persons[1].age" /> <s:textfield label="Person 3 Name" name="persons[2].name" /> <s:textfield label="Person 3 Age" name="persons[2].age" /> --%> <s:submit /> </s:form> </body> </html> //here is the PersonAction.java used in showcase webapp /* * $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 org.apache.struts2.showcase.conversion; import java.util.List; import com.opensymphony.xwork2.ActionSupport; /** * */ public class PersonAction extends ActionSupport { private List persons; public List getPersons() { return persons; } public void setPersons(List persons) { this.persons = persons; } public String input() throws Exception { return SUCCESS; } public String submit() throws Exception { return SUCCESS; } } the important bits are jsp reference to persons list here <s:iterator value="new int[3]" status="stat"> <s:textfield label="%{'Person '+#stat.index+' Name'}" name="%{'persons['+#stat.index+'].name'}" /> <s:textfield label="%{'Person '+#stat.index+' Age'}" name="%{'persons['+#stat.index+'].age'}" /> </s:iterator> which references and iterates thru the List of persons from PersonAction private List persons; Action class does push its attributes on to OGNLstack so a reference such as "%{'persons['+#stat.index+'].name'}" works provided you have set stat to be the 'status' index Martin Gainty ______________________________________________ Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen. Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni. > Date: Thu, 12 Nov 2009 13:16:08 +0100 > From: carl.ballantyne@... > To: user@... > Subject: Re: Property Mapping in a iterator > > Hi Alex, > > I think you might need to add <constant name="struts.devMode" > value="true" /> in your struts.xml file. > > > > Quoting Alex Parvulescu <alex.parvulescu@...>: > > > hello, > > > > I have been looking at Struts2 for a couple of days now, it seems nice > > and easy to work with. > > > > I have a problem that I don't really understand, maybe I'm missing > > some config settings or something. > > > > Let's say that I want to display a list of persons, and for each > > person I want to see the name. > > This is very straightforward: > > > > <s:iterator value="people" var="p"> > > <div id="row_<s:property value="id"/>"> > > <s:property value="name" /> > > </div> > > </s:iterator> > > > > Easy enough, but if I miss-spell the property name, I get no error, > > only a blank value. > > Is there a struts way to prevent these kinds of things from happening > > - like get some sort of error message. > > > > By the way, I am using Struts 2.1.6 and I'm not sure if this is the > > proper mailing list for this framework. Are you guys dealing with both > > Struts and Struts2 issues? As I've seen so far, Struts2 is pretty > > different than Struts. > > > > If I'm not in the proper place, please point me in the right direction. > > > > thanks, > > alex > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: user-unsubscribe@... > > For additional commands, e-mail: user-help@... > > > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@... > For additional commands, e-mail: user-help@... > _________________________________________________________________ Hotmail: Trusted email with Microsoft's powerful SPAM protection. http://clk.atdmt.com/GBL/go/177141664/direct/01/ http://clk.atdmt.com/GBL/go/177141664/direct/01/ |
|
|
Re: Property Mapping in a iteratorhello Martin and thanks for you reply
the code works if I put in the 'name' property. However, if I put there 'pname' , or I miss spell by mistake, I get no error (or maybe a warning) saying that the property does not exist, and I should really check that code. I don't think this is related to the way the list is populated, as it refers to a non-existent property on the Person bean. And mapping on a non-existent property should be at least flagged in the logs. The question is, is there any way I can enable that check, even if in dev mode, as suggested by Carl, so I can make sure that things like these don't just fly by. thanks, alex On Thu, Nov 12, 2009 at 1:48 PM, Martin Gainty <mgainty@...> wrote: > > How are the person objects being populated? > > here is the sample configuration from showcase: > > <action name="enterPersonsInfo" method="input" > class="org.apache.struts2.showcase.conversion.PersonAction"> > <result>enterPersonInfo.jsp</result> > </action> > <action name="submitPersonInfo" method="submit" > class="org.apache.struts2.showcase.conversion.PersonAction"> > <result>showPersonInfo.jsp</result> > <result name="input">enterPersonInfo.jsp</result> > </action> > <action name="showPersonJspCode"> > <result type="plainText">/conversion/enterPersonInfo.jsp</result> > </action> > <action name="showPersonActionJavaCode"> > <result type="plainText">/conversion/PersonAction.java.txt</result> > </action> > <action name="showPersonJavaCode"> > <result type="plainText">/conversion/Person.java.txt</result> > </action> > > here is enterPersonInfo.jsp which is used for all results to/fro enterPersonsInfo action input method > > <%@taglib prefix="s" uri="/struts-tags" %> > <html> > <head> > <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> > <title>Showcase - Conversion - Populate Object into Struts' action List</title> > </head> > <body> > > <p/> > An example populating a list of object (Person.java) into Struts' action (PersonAction.java) > > <p/> > See the jsp code <s:url var="url" action="showPersonJspCode" namespace="/conversion" /><s:a href="%{#url}">here.</s:a><br/> > See the code for PersonAction.java <s:url var="url" action="showPersonActionJavaCode" namespace="/conversion" /><s:a href="%{#url}">here.</s:a><br/> > See the code for Person.java <s:url var="url" action="showPersonJavaCode" namespace="/conversion" /><s:a href="%{#url}">here.</s:a><br/> > <p/> > > <s:actionerror /> > <s:fielderror /> > > <s:form action="submitPersonInfo" namespace="/conversion" method="post"> > <%-- > The following is done Dynamically > --%> > <s:iterator value="new int[3]" status="stat"> > <s:textfield label="%{'Person '+#stat.index+' Name'}" > name="%{'persons['+#stat.index+'].name'}" /> > <s:textfield label="%{'Person '+#stat.index+' Age'}" > name="%{'persons['+#stat.index+'].age'}" /> > </s:iterator> > > <%-- > The following is done statically:- > --%> > <%-- > <s:textfield label="Person 1 Name" > name="persons[0].name" /> > <s:textfield label="Person 1 Age" > name="persons[0].age" /> > <s:textfield label="Person 2 Name" > name="persons[1].name" /> > <s:textfield label="Person 2 Age" > name="persons[1].age" /> > <s:textfield label="Person 3 Name" > name="persons[2].name" /> > <s:textfield label="Person 3 Age" > name="persons[2].age" /> > --%> > > <s:submit /> > </s:form> > </body> > </html> > > > //here is the PersonAction.java used in showcase webapp > /* > * $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 org.apache.struts2.showcase.conversion; > > import java.util.List; > > import com.opensymphony.xwork2.ActionSupport; > > /** > * > */ > public class PersonAction extends ActionSupport { > > private List persons; > > public List getPersons() { return persons; } > public void setPersons(List persons) { this.persons = persons; } > > > > public String input() throws Exception { > return SUCCESS; > } > > public String submit() throws Exception { > return SUCCESS; > } > } > > the important bits are jsp reference to persons list here > <s:iterator value="new int[3]" status="stat"> > > <s:textfield label="%{'Person '+#stat.index+' Name'}" > > name="%{'persons['+#stat.index+'].name'}" /> > > <s:textfield label="%{'Person '+#stat.index+' Age'}" > > name="%{'persons['+#stat.index+'].age'}" /> > > </s:iterator> > > which references and iterates thru the List of persons from PersonAction > private List persons; > > Action class does push its attributes on to OGNLstack so a reference such as > "%{'persons['+#stat.index+'].name'}" > works > provided you have set stat to be the 'status' index > > Martin Gainty > ______________________________________________ > Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité > > Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen. > Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni. > > > > >> Date: Thu, 12 Nov 2009 13:16:08 +0100 >> From: carl.ballantyne@... >> To: user@... >> Subject: Re: Property Mapping in a iterator >> >> Hi Alex, >> >> I think you might need to add <constant name="struts.devMode" >> value="true" /> in your struts.xml file. >> >> >> >> Quoting Alex Parvulescu <alex.parvulescu@...>: >> >> > hello, >> > >> > I have been looking at Struts2 for a couple of days now, it seems nice >> > and easy to work with. >> > >> > I have a problem that I don't really understand, maybe I'm missing >> > some config settings or something. >> > >> > Let's say that I want to display a list of persons, and for each >> > person I want to see the name. >> > This is very straightforward: >> > >> > <s:iterator value="people" var="p"> >> > <div id="row_<s:property value="id"/>"> >> > <s:property value="name" /> >> > </div> >> > </s:iterator> >> > >> > Easy enough, but if I miss-spell the property name, I get no error, >> > only a blank value. >> > Is there a struts way to prevent these kinds of things from happening >> > - like get some sort of error message. >> > >> > By the way, I am using Struts 2.1.6 and I'm not sure if this is the >> > proper mailing list for this framework. Are you guys dealing with both >> > Struts and Struts2 issues? As I've seen so far, Struts2 is pretty >> > different than Struts. >> > >> > If I'm not in the proper place, please point me in the right direction. >> > >> > thanks, >> > alex >> > >> > --------------------------------------------------------------------- >> > To unsubscribe, e-mail: user-unsubscribe@... >> > For additional commands, e-mail: user-help@... >> > >> > >> >> >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: user-unsubscribe@... >> For additional commands, e-mail: user-help@... >> > > _________________________________________________________________ > Hotmail: Trusted email with Microsoft's powerful SPAM protection. > http://clk.atdmt.com/GBL/go/177141664/direct/01/ > http://clk.atdmt.com/GBL/go/177141664/direct/01/ > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
Re: Property Mapping in a iteratorHi Alex,
I thought it was supposed to give you more debug information including when the property does not exist. Looks like I might be wrong then. Cheers, Carl. Quoting Alex Parvulescu <alex.parvulescu@...>: > hello, > > I did it and got nothing :) > > > Can you explain a bit what this property does? > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
Re: Property Mapping in a iteratorYou need a couple of things:
1. set devMode to true <constant name="struts.devMode" value="true"/> if you want to get a log of the missing property, then 2. set <constant name="struts.ognl.logMissingProperties" value="true" /> if you want to get an exception (the page will break), then: 2. set <constant name="struts.el.throwExceptionOnFailure" value="true" /> musachy On Thu, Nov 12, 2009 at 5:58 AM, carl ballantyne <carl.ballantyne@...> wrote: > Hi Alex, > > I thought it was supposed to give you more debug information including when > the property does not exist. Looks like I might be wrong then. > > Cheers, Carl. > > Quoting Alex Parvulescu <alex.parvulescu@...>: > >> hello, >> >> I did it and got nothing :) >> >> >> Can you explain a bit what this property does? >> > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@... > For additional commands, e-mail: user-help@... > > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
Re: Property Mapping in a iteratorFAQ added for it:
http://cwiki.apache.org/confluence/display/WW/Make+Struts+throw+exceptions+on+missing+properties%2C+or+log+them On Thu, Nov 12, 2009 at 8:49 AM, Musachy Barroso <musachy@...> wrote: > You need a couple of things: > > 1. set devMode to true <constant name="struts.devMode" value="true"/> > > if you want to get a log of the missing property, then > > 2. set <constant name="struts.ognl.logMissingProperties" value="true" /> > > if you want to get an exception (the page will break), then: > > 2. set <constant name="struts.el.throwExceptionOnFailure" value="true" /> > > musachy > > On Thu, Nov 12, 2009 at 5:58 AM, carl ballantyne > <carl.ballantyne@...> wrote: >> Hi Alex, >> >> I thought it was supposed to give you more debug information including when >> the property does not exist. Looks like I might be wrong then. >> >> Cheers, Carl. >> >> Quoting Alex Parvulescu <alex.parvulescu@...>: >> >>> hello, >>> >>> I did it and got nothing :) >>> >>> >>> Can you explain a bit what this property does? >>> >> >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: user-unsubscribe@... >> For additional commands, e-mail: user-help@... >> >> > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
| Free embeddable forum powered by Nabble | Forum Help |