struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dirk Behrendt" <schno...@web.de>
Subject AW: AW: Error Using select tag To Create Drop-Down Menu
Date Tue, 22 Jul 2003 13:36:57 GMT
Hello!

Maybe anybody can help me....


I also want to use an ArrayList form a DropDown Menu.

I have added the list to my session succsessfully.


But how can I use the session attribute "LANG" within my <html:options
tag>???

<jsp:useBean id="LangBean" scope="request" class="sample.LanguageBean" >

<%session.setAttribute("LANG",LangBean.getLanguageArrayList());%>
</jsp:useBean>

</html:form>
<html:form action="/language" method = "GET" >
<html:select property="language" onchange="javascript: submit ()">
</html:select>

<html:options collection ...>

</html:form>


the bean:
public class LanguageBean {

    private ArrayList languageArrayList;

    public LanguageBean() {

        this.languageArrayList = new ArrayList();
           this.languageArrayList.add("Deutsch");
        this.languageArrayList.add("Englisch");
        System.out.println(languageArrayList);

    }


    public void setLanguageArrayList(String str) {

        this.languageArrayList.add(str);


    }

    public ArrayList getLanguageArrayList() {

        return this.languageArrayList;

    }

}







I looked at your example, but I dont understand all things.


Dirk



-----Urspr√ľngliche Nachricht-----
Von: Caroline Jen [mailto:jiapei_jen@yahoo.com] 
Gesendet: Dienstag, 22. Juli 2003 01:20
An: Struts Users Mailing List
Betreff: Re: AW: Error Using select tag To Create Drop-Down Menu

Hi, Dirk:  Thanks for your help.  My code works now. 
I am able to see the drop-down menu in the browser.

--- Dirk Behrendt <schnoerk@web.de> wrote:
> Hello!
>  
> I had the same problem...
>  
> You have to include the <html:select> tag into
> <html:form> tags.  Look:
>  
>  
> <html:form action="/language" method = "GET" >
>  
> <html:select property="language"
> onchange="javascript: submit ()">
> <html:option value="Deutsch"/> <html:option
> value="Englisch"/>
> </html:select>
>  
> </html:form>  
>  
> I have an ActionBean and a FormBean for the action
> "/language".
>  
> Without that you will get the exception 
> "Cannot find bean under name
> org.apache.struts.taglib.html.BEAN" 
>  
> Hope, that will help!
>  
> Dirk
>  
>  
> -----Urspr√ľngliche Nachricht-----
> Von: Caroline Jen [mailto:jiapei_jen@yahoo.com] 
> Gesendet: Montag, 21. Juli 2003 21:18
> An: struts-user@jakarta.apache.org
> Betreff: Error Using select tag To Create Drop-Down
> Menu
>  
> I am doing testings step by step. I simply want to
> add
> a drop-down menu feature to something that works
> OKay.
> I am a newbie to struts. I do not know where to look
> for my mistakes when I encounter problems. 
> Something is wrong in my .jsp page. This .jsp page
> had
> worked fine before <html:select>...</html:select>
> tags were added. The error message is:
>  
>  
> code:
>
------------------------------------------------------
>  
> 2003-07-21 01:24:51
> StandardWrapperValve[action]:Servlet.service() for
> servlet action threw
> exceptionorg.apache.jasper.JasperException: Cannot
> find bean under name
> org.apache.struts.taglib.html.BEAN
>  
>
-------------------------------------------------------
>  
> Here is the source code of my MainMenu.jsp:
>  
>  
> code:
>
-------------------------------------------------------
>  
> <%@ taglib uri="/WEB-INF/struts-html.tld"
> prefix="html" %>
> <%@ taglib uri="/WEB-INF/struts-bean.tld"
> prefix="bean" %>
> <jsp:useBean id="LogonBean" scope="request"
> class="resources.version1.LogonBean" /> <HTML>
> <HEAD>
> <TITLE><bean:message key="title.mainmenu" />
> </TITLE> </HEAD> <BODY>
>       <bean:message key="heading.mainmenu" />  <p>
> <bean:message key="label.userType" />:
> <b><jsp:getProperty name="LogonBean"
> property="userType" /></b>
> <br>
>         <B>State: </B>
>         <html:select property="state">              
>  
>         <html:options collection="STATES"        
>                        property="value"   
>                        labelProperty="label" />     
>  
>       
>         </html:select>
> </BODY>
> </HTML>
>  
>
-------------------------------------------------------
>  
>  
> In the LogonBean.java, I inserted in the
> setParameters(....) method the following code:
>  
>  
> code:
>
-------------------------------------------------------
>  
> public void setParameters( HttpServletRequest
> request
> ){   userID = request.getParameter("userID");  
> password = request.getParameter("password");  
> ArrayList states = new ArrayList();   states.add(new
> LabelValueBean("Virginia", "VA"));   states.add(new
> LabelValueBean("Maryland", "MD"));   states.add(new
> LabelValueBean("Ohio", "OH"));   states.add(new
> LabelValueBean("Rode Island", "RI"));  
> states.add(new
> LabelValueBean("New York", "NY"));  
> request.setAttribute("STATES", states);}
>  
>
------------------------------------------------------
>  
> I would appreciate if anybody could point out my
> mistakes.
>  
>  
>  
> __________________________________
> Do you Yahoo!?
> SBC Yahoo! DSL - Now only $29.95 per month!
> http://sbc.yahoo.com
> <http://sbc.yahoo.com/> 
>  
> 


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message