RE: Tag iterator and my object container
Hi, Thank you. I implements the iterator interface, and now it is working. public class SearchResults implements Iterator { private Set keySet = null; private Iterator iterator = null; private Set keySet() { if (this.keySet == null) { this.keySet = this.results.keySet(); } return this.keySet; } private Iterator iterator() { if (this.iterator == null){ this.iterator = this.keySet().iterator(); } return this.iterator; } public SearchResult get(String key) { return this.results.get(key); } @Override public boolean hasNext() { return this.iterator().hasNext(); } @Override public SearchResult next() { String next = this.iterator().next(); return this.get(next); } } Calls (hasNext() and next()) are done in org.apache.struts2.components. IteratorComponent Thanks Matthieu MARC -Message d'origine- De : Steven Yang [mailto:kenshin...@gmail.com] Envoyé : mardi 10 mai 2011 15:16 À : Struts Users Mailing List Objet : Re: Tag iterator and my object container you need to implement the Iterator interface On Tue, May 10, 2011 at 4:14 PM, wrote: > Hi everybody, > > I have a container object SearchResults which contains a treeMap of > simple object SearchResult. > > I want to iterate over SearchResults in order to display properties of > all SearchResult object > >Class SearchResult { >//getter and setter >getDescription(); >} > >Class SearchResults { > treeMap resultats; > >public Set keyset(); >public Iterator iterator(); >public SearchResult get(String key); >} > > My Action class have this getter : > >getResultats(){ return (SearchResults)object; }; > > And my JSP look like : > > > > > > > But it is not working, s:iterator tag is not iterating over my > SearchResults object using the iterator() method (not called). > > How must I construct my SearchResults object in order to make the > s:iterator tag iterate over it ? > > Thanks. > > Matthieu MARC > > --- > Matthieu MARC > Responsable du Service Informatique du Centre d'Angers Arts et Métiers > ParisTech Tél : 02 41 20 73 61 > > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > > - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Tag iterator and my object container
You could possibly get away with just implementing Iterable instead of Iterator. It's a much simpler interface to implement. (*Chris*) On Thu, May 12, 2011 at 12:17 AM, wrote: > Hi, > > Thank you. I implements the iterator interface, and now it is working. > > public class SearchResults implements Iterator { > >private Set keySet = null; >private Iterator iterator = null; > >private Set keySet() { > >if (this.keySet == null) { >this.keySet = this.results.keySet(); >} >return this.keySet; >} > >private Iterator iterator() { > >if (this.iterator == null){ >this.iterator = this.keySet().iterator(); >} >return this.iterator; >} > >public SearchResult get(String key) { >return this.results.get(key); >} > >@Override >public boolean hasNext() { >return this.iterator().hasNext(); >} > >@Override >public SearchResult next() { >String next = this.iterator().next(); >return this.get(next); >} > } > > > Calls (hasNext() and next()) are done in org.apache.struts2.components. > IteratorComponent > > > Thanks > > Matthieu MARC > > > -Message d'origine- > De : Steven Yang [mailto:kenshin...@gmail.com] > Envoyé : mardi 10 mai 2011 15:16 > À : Struts Users Mailing List > Objet : Re: Tag iterator and my object container > > you need to implement the Iterator interface > > On Tue, May 10, 2011 at 4:14 PM, wrote: > > > Hi everybody, > > > > I have a container object SearchResults which contains a treeMap of > > simple object SearchResult. > > > > I want to iterate over SearchResults in order to display properties of > > all SearchResult object > > > >Class SearchResult { > >//getter and setter > >getDescription(); > >} > > > >Class SearchResults { > > treeMap resultats; > > > >public Set keyset(); > >public Iterator iterator(); > >public SearchResult get(String key); > >} > > > > My Action class have this getter : > > > >getResultats(){ return (SearchResults)object; }; > > > > And my JSP look like : > > > > > > > > > > > > > > But it is not working, s:iterator tag is not iterating over my > > SearchResults object using the iterator() method (not called). > > > > How must I construct my SearchResults object in order to make the > > s:iterator tag iterate over it ? > > > > Thanks. > > > > Matthieu MARC > > > > --- > > Matthieu MARC > > Responsable du Service Informatique du Centre d'Angers Arts et Métiers > > ParisTech Tél : 02 41 20 73 61 > > > > > > - > > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > > For additional commands, e-mail: user-h...@struts.apache.org > > > > > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > >
Iterator tag and enumeration
Hi, I have an enumeration 'Localization' : public enum Localization { AIX("Aix-en-provence"), ANGERS("Angers") ; } And I want to put a form select in a jsp using s:select tag with all Localization items, like : But I don't know what to put in the list parameter. In my Localization enum, I wrote a function to retrieve Localization item through a sorted map : public Map getListLocalization() { [...] } So that my select will be like : Aix-en-provence My question is finally : how to put an enumeration in a s:select tag ? Thanks, Matthieu MARC --- Matthieu MARC Responsable du Service Informatique du Centre d'Angers Arts et Métiers ParisTech Tél : 02 41 20 73 61 - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Iterator tag and enumeration
try On Thu, May 12, 2011 at 3:33 PM, wrote: > Hi, > > I have an enumeration 'Localization' : > > public enum Localization { > >AIX("Aix-en-provence"), >ANGERS("Angers") ; > } > > And I want to put a form select in a jsp using s:select tag with all > Localization items, like : > > > > But I don't know what to put in the list parameter. > > In my Localization enum, I wrote a function to retrieve Localization item > through a sorted map : > >public Map getListLocalization() { >[...] >} > > So that my select will be like : value="aix">Aix-en-provence > > My question is finally : how to put an enumeration in a s:select tag ? > > Thanks, > > Matthieu MARC > > --- > Matthieu MARC > Responsable du Service Informatique du Centre d'Angers > Arts et Métiers ParisTech > Tél : 02 41 20 73 61 > > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > >
RE: Iterator tag and enumeration
This code is working : This one is not working : Neither this one : And neither this one : I would be great to make the getListLocalization() work because I will be able to have a nice display of select element. Thank Matthieu MARC -Message d'origine- De : Steven Yang [mailto:kenshin...@gmail.com] Envoyé : jeudi 12 mai 2011 12:34 À : Struts Users Mailing List Objet : Re: Iterator tag and enumeration try On Thu, May 12, 2011 at 3:33 PM, wrote: > Hi, > > I have an enumeration 'Localization' : > > public enum Localization { > >AIX("Aix-en-provence"), >ANGERS("Angers") ; > } > > And I want to put a form select in a jsp using s:select tag with all > Localization items, like : > > > > But I don't know what to put in the list parameter. > > In my Localization enum, I wrote a function to retrieve Localization > item through a sorted map : > >public Map getListLocalization() { >[...] >} > > So that my select will be like : value="aix">Aix-en-provence > > My question is finally : how to put an enumeration in a s:select tag ? > > Thanks, > > Matthieu MARC > > --- > Matthieu MARC > Responsable du Service Informatique du Centre d'Angers Arts et Métiers > ParisTech Tél : 02 41 20 73 61 > > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > > - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Tag iterator and my object container
You could probably get away with just exposing the map. Dave On May 12, 2011 3:26 AM, "Chris Pratt" wrote: > You could possibly get away with just implementing Iterable instead of > Iterator. It's a much simpler interface to implement. > (*Chris*) > > On Thu, May 12, 2011 at 12:17 AM, wrote: > >> Hi, >> >> Thank you. I implements the iterator interface, and now it is working. >> >> public class SearchResults implements Iterator { >> >> private Set keySet = null; >> private Iterator iterator = null; >> >> private Set keySet() { >> >> if (this.keySet == null) { >> this.keySet = this.results.keySet(); >> } >> return this.keySet; >> } >> >> private Iterator iterator() { >> >> if (this.iterator == null){ >> this.iterator = this.keySet().iterator(); >> } >> return this.iterator; >> } >> >> public SearchResult get(String key) { >> return this.results.get(key); >> } >> >> @Override >> public boolean hasNext() { >> return this.iterator().hasNext(); >> } >> >> @Override >> public SearchResult next() { >> String next = this.iterator().next(); >> return this.get(next); >> } >> } >> >> >> Calls (hasNext() and next()) are done in org.apache.struts2.components. >> IteratorComponent >> >> >> Thanks >> >> Matthieu MARC >> >> >> -Message d'origine- >> De : Steven Yang [mailto:kenshin...@gmail.com] >> Envoyé : mardi 10 mai 2011 15:16 >> À : Struts Users Mailing List >> Objet : Re: Tag iterator and my object container >> >> you need to implement the Iterator interface >> >> On Tue, May 10, 2011 at 4:14 PM, wrote: >> >> > Hi everybody, >> > >> > I have a container object SearchResults which contains a treeMap of >> > simple object SearchResult. >> > >> > I want to iterate over SearchResults in order to display properties of >> > all SearchResult object >> > >> > Class SearchResult { >> > //getter and setter >> > getDescription(); >> > } >> > >> > Class SearchResults { >> > treeMap resultats; >> > >> > public Set keyset(); >> > public Iterator iterator(); >> > public SearchResult get(String key); >> > } >> > >> > My Action class have this getter : >> > >> > getResultats(){ return (SearchResults)object; }; >> > >> > And my JSP look like : >> > >> > >> > >> > >> > >> > >> > But it is not working, s:iterator tag is not iterating over my >> > SearchResults object using the iterator() method (not called). >> > >> > How must I construct my SearchResults object in order to make the >> > s:iterator tag iterate over it ? >> > >> > Thanks. >> > >> > Matthieu MARC >> > >> > --- >> > Matthieu MARC >> > Responsable du Service Informatique du Centre d'Angers Arts et Métiers >> > ParisTech Tél : 02 41 20 73 61 >> > >> > >> > - >> > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org >> > For additional commands, e-mail: user-h...@struts.apache.org >> > >> > >> >> - >> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org >> For additional commands, e-mail: user-h...@struts.apache.org >> >>
Re: Re: RedirectAction Help!
Jeff, I am running struts 2.2.1 I also created this with Spring 3.0, although I am not sure I need spring. Teresa On May 11, 2011 11:32pm, Jeffrey Black wrote: Teresa, FWIW, I have apps that utilize redirectAction (ie ServletActionRedirectResult) without issue. Just curious, what version of Struts2 are you running and what container are you using? Best, jb From: Teresa McGinley tdmcgin...@gmail.com> To: user@struts.apache.org Sent: Tuesday, May 10, 2011 6:01 PM Subject: RedirectAction Help! I am trying to send an id from one action to another and it seems to be sending a null. Please assist and I am really at my wits end with this. How do I get the formId from the Listing to the QuestionListing? startInformation has a yourForm=41, when I click the Begin button I get the redirect to Questions.action with a null formId as shown... http://localhost:8080/IUNSurvey/survey/Questions.action?formId= startInformation.jsp has a button that calls redirect: ... struts.xml "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd";> prod --> method="display"> /views/survey/Listing.jsp name="success">/views/survey/startInformation.jsp method="beginQuestions"> Questions true ${yourForm} /views/survey/Questions.jsp exerpt from Listing.java public String execute() { selectedForm = services.getFormsById(yourForm); return SUCCESS; } public String display() { forms = services.getForms(); return NONE; } public String beginQuestions() { return "redirect"; } /** * @return the yourForm */ public Long getYourForm() { return yourForm; } exerpt from QuestionListing.java I have a getter/setter for formId public String execute() { currentQuestion = (services.getQuestionsByForm(getFormId())); return SUCCESS; } public String display() { setCurrentQuestion(services.getQuestionsByForm(getFormId())); return NONE; } public void setFormId(Long formId) { this.formId = formId; } public Long getFormId() { return formId; }
Re: Separate Java Bean Class for Getter/Setter method.
I dont know if its a bug or functinoality. I am passing 3 param from a page. I am only able to receive the 1st one in the next page... Dont know why. Page one :- Page two :- Description Enable this Allergy ? Any feed back ? -- View this message in context: http://struts.1045723.n5.nabble.com/Separate-Java-Bean-Class-for-Getter-Setter-method-tp4385274p4390648.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: Separate Java Bean Class for Getter/Setter method.
On Thu, May 12, 2011 at 11:59 AM, arin_12 wrote: > I am passing three parameters via URL from one page to another. > I only see one available on the second page; don't know why. > > Page one > > > > > > > > Page two > > value="%{#parameters.alDescription}"/> > > > > Any feed back ? Sure. * Is it "al", or "all"? You show both. IMO that's a bad idea--too similar if they're supposed to be different. * You say you pass three, get one. Which one? * You say you pass three, get one; I only see two references to parameters. * Is the URL being constructed properly? Check the HTML source. Dave - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Iterator tag and enumeration
I dont quite get what exactly you want if your getListLocalization has all the information of you Enum then you probably just do list="listLocalization.entrySet" but then you still need to provide the listValue and listKey attribute On Thu, May 12, 2011 at 6:56 PM, wrote: > This code is working : > /> > > This one is not working : > list="@org.ensam.annuaire.enumeration.Localization@getListLocalization ()" /> > Neither this one : > list="@org.ensam.annuaire.enumeration.Localization@listLocalization ()" /> > And neither this one : > list="@org.ensam.annuaire.enumeration.Localization@listLocalization " /> > > I would be great to make the getListLocalization() work because I will be > able to have a nice display of select element. > > Thank > > Matthieu MARC > > > -Message d'origine- > De : Steven Yang [mailto:kenshin...@gmail.com] > Envoyé : jeudi 12 mai 2011 12:34 > À : Struts Users Mailing List > Objet : Re: Iterator tag and enumeration > > try > > > On Thu, May 12, 2011 at 3:33 PM, wrote: > > > Hi, > > > > I have an enumeration 'Localization' : > > > > public enum Localization { > > > >AIX("Aix-en-provence"), > >ANGERS("Angers") ; > > } > > > > And I want to put a form select in a jsp using s:select tag with all > > Localization items, like : > > > > > > > > But I don't know what to put in the list parameter. > > > > In my Localization enum, I wrote a function to retrieve Localization > > item through a sorted map : > > > >public Map getListLocalization() { > >[...] > >} > > > > So that my select will be like : > value="aix">Aix-en-provence > > > > My question is finally : how to put an enumeration in a s:select tag ? > > > > Thanks, > > > > Matthieu MARC > > > > --- > > Matthieu MARC > > Responsable du Service Informatique du Centre d'Angers Arts et Métiers > > ParisTech Tél : 02 41 20 73 61 > > > > > > - > > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > > For additional commands, e-mail: user-h...@struts.apache.org > > > > > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > >
RE: Iterator tag and enumeration
getListLocalization() is a method of my Enum, not of my Action class. Matthieu MARC -Message d'origine- De : Steven Yang [mailto:kenshin...@gmail.com] Envoyé : vendredi 13 mai 2011 03:03 À : Struts Users Mailing List Objet : Re: Iterator tag and enumeration I dont quite get what exactly you want if your getListLocalization has all the information of you Enum then you probably just do list="listLocalization.entrySet" but then you still need to provide the listValue and listKey attribute On Thu, May 12, 2011 at 6:56 PM, wrote: > This code is working : > /> > > This one is not working : > list="@org.ensam.annuaire.enumeration.Localization@getListLocalization ()" /> > Neither this one : > list="@org.ensam.annuaire.enumeration.Localization@listLocalization ()" /> > And neither this one : > list="@org.ensam.annuaire.enumeration.Localization@listLocalization " > /> > > I would be great to make the getListLocalization() work because I will > be able to have a nice display of select element. > > Thank > > Matthieu MARC > > > -Message d'origine- > De : Steven Yang [mailto:kenshin...@gmail.com] Envoyé : jeudi 12 mai > 2011 12:34 À : Struts Users Mailing List Objet : Re: Iterator tag and > enumeration > > try > > > On Thu, May 12, 2011 at 3:33 PM, wrote: > > > Hi, > > > > I have an enumeration 'Localization' : > > > > public enum Localization { > > > >AIX("Aix-en-provence"), > >ANGERS("Angers") ; > > } > > > > And I want to put a form select in a jsp using s:select tag with all > > Localization items, like : > > > > > > > > But I don't know what to put in the list parameter. > > > > In my Localization enum, I wrote a function to retrieve Localization > > item through a sorted map : > > > >public Map getListLocalization() { > >[...] > >} > > > > So that my select will be like : > value="aix">Aix-en-provence > > > > My question is finally : how to put an enumeration in a s:select tag ? > > > > Thanks, > > > > Matthieu MARC > > > > --- > > Matthieu MARC > > Responsable du Service Informatique du Centre d'Angers Arts et > > Métiers ParisTech Tél : 02 41 20 73 61 > > > > > > > > - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > > For additional commands, e-mail: user-h...@struts.apache.org > > > > > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > > - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org