I tried everything but still can't figure out The code in the AdvertEditAction.java AdvertsForm advertForm=new AdvertsForm(); advertForm.setLocation(advert.getLocation()); request.setAttribute("advertsForm",advertForm); request.setAttribute("advert",advert);
In the jsp file <html:select styleClass="input" property="location"> <html:option value="0">All</html:option> <html:optionsCollection name="advertsForm" property="locations" label="locationDesc" value="locationId" /> </html:select> The code in the struts-config.xml <action path="/advertEdit" type="com.actions.AdvertEditAction" name = "advertsForm" scope = "request" > <forward name="success" path="/admin/advertsAdmin.jsp" /> <forward name="noAccess" path="/notAuthorized.jsp" /> </action> Then also the location is not selected Can you please help me regarding this Thanks in advance CSJakharia --- Nuwan Chandrasoma <[EMAIL PROTECTED]> wrote: > Hi, > > The scope of the ActionForm is based on the scope > you have specified in the > action-mapping in the struts-config.xml , hard code > the value attribute of > the tag to the one you want to select by default > > http://struts.apache.org/1.2.9/userGuide/struts-html.html#select > > Thanks, > > Nuwan > > > > > ----- Original Message ----- > From: "Chirag" <[EMAIL PROTECTED]> > To: "Nuwan Chandrasoma" <[EMAIL PROTECTED]>; > <user@struts.apache.org> > Sent: Sunday, May 06, 2007 10:11 AM > Subject: Re: How to set default value in the > html:select which is populated > with html:optionsCollection tag? > > > >I got that I have to type something like > > <%advertForm.setLocation(3);%> > > > > But can you please specify the code for the same > i.e. > > the taglib that is to be used and in what scope is > the > > ActionForm available > > > > Can you please post me an example of the code > > > > Thanks in advance > > > > CSJakharia > > > > > > --- Nuwan Chandrasoma <[EMAIL PROTECTED]> wrote: > > > >> Hi, > >> > >> according to your code you have used the property > >> location with the > >> <html:select> tag. , so i am refering to that > >> ActionForm which has this > >> location property. so in that ActionForm, if you > set > >> location property to a > >> value that you have in those options, it will be > >> automaticaly selected. > >> > >> eg:- if you set the location to 0 in the > ActionForm > >> the option 'All' will be > >> selected default > >> > >> Thanks, > >> > >> Nuwan > >> > >> > >> ----- Original Message ----- > >> From: "Chirag" <[EMAIL PROTECTED]> > >> To: "Nuwan Chandrasoma" <[EMAIL PROTECTED]>; > >> <user@struts.apache.org> > >> Sent: Sunday, May 06, 2007 9:45 AM > >> Subject: Re: How to set default value in the > >> html:select which is populated > >> with html:optionsCollection tag? > >> > >> > >> > Can you please explain me in detail which form > >> > > >> > I am sorry I am a little newbie type to Struts > and > >> so > >> > could not understand what are you conveying? > >> > > >> > Thanks in advance > >> > > >> > CSJakharia > >> > > >> > --- Nuwan Chandrasoma <[EMAIL PROTECTED]> > wrote: > >> > > >> >> Hi, > >> >> > >> >> Set the location property in your from to the > >> >> default value you wan to > >> >> select, then the tag will automatically select > >> the > >> >> option that matches this > >> >> value > >> >> > >> >> Thanks, > >> >> > >> >> Nuwan > >> >> > >> >> > >> >> ----- Original Message ----- > >> >> From: "Chirag" <[EMAIL PROTECTED]> > >> >> To: <user@struts.apache.org> > >> >> Sent: Sunday, May 06, 2007 9:23 AM > >> >> Subject: How to set default value in the > >> html:select > >> >> which is populated with > >> >> html:optionsCollection tag? > >> >> > >> >> > >> >> >I am a little newbie type in Struts > >> >> > > >> >> > I already have the following code > >> >> > <html:select styleClass="input" > >> >> property="location"> > >> >> > <html:option value="0">All</html:option> > >> >> > <html:optionsCollection name="advertsForm" > >> >> > property="locations" label="locationDesc" > >> >> > value="locationId" /> > >> >> > </html:select> > >> >> > > >> >> > Now I want to modify this code in such a way > >> that > >> >> it > >> >> > selects a default value . > >> >> > > >> >> > How to do that > >> >> > > >> >> > Thanks in advance > >> >> > > >> >> > CSJakharia > >> >> > > >> >> > Subscribe to bermudaEmail: [input] [input] > >> >> Browse Archives at > >> >> > groups.google.com > >> >> > > >> >> > > >> >> > > >> >> > > >> >> > >> > > >> > > > ____________________________________________________________________________________ > >> >> > Food fight? Enjoy some healthy debate > >> >> > in the Yahoo! Answers Food & Drink Q&A. > >> >> > > >> >> > >> > > >> > > > http://answers.yahoo.com/dir/?link=list&sid=396545367 > >> >> > > >> >> > > >> >> > >> > > >> > > > --------------------------------------------------------------------- > >> >> > To unsubscribe, e-mail: > >> >> [EMAIL PROTECTED] > >> >> > For additional commands, e-mail: > >> >> [EMAIL PROTECTED] > >> >> > > >> >> > >> >> > >> > > >> > > >> > Subscribe to bermudaEmail: [input] [input] > >> Browse Archives at > >> > groups.google.com > >> > > >> > > >> > > >> > > >> > > > ____________________________________________________________________________________ > >> > Get your own web address. > >> > Have a HUGE year through Yahoo! Small Business. > >> > > http://smallbusiness.yahoo.com/domains/?p=BESTDEAL > >> > >> > >> > > > > > > Subscribe to bermudaEmail: [input] [input] > Browse Archives at > > groups.google.com > > > > > > > > > ____________________________________________________________________________________ > > We won't tell. Get more on shows you hate to love > === message truncated === Subscribe to bermudaEmail: [input] [input] Browse Archives at groups.google.com ____________________________________________________________________________________ Don't pick lemons. See all the new 2007 cars at Yahoo! Autos. http://autos.yahoo.com/new_cars.html --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]