Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Working with Maps and html:options - newbie question

843838Aug 23 2005 — edited Aug 23 2005
Ok, this is a totally newbie question...

What I'm trying to do is totally simple: I wanna load a map with values, and then load a html:options with this map. The problem is I just don't know how to refer to the properties.

Here's what I'm doing... I load my map:
    public Map getAtributosColecao(){
       Map mapa = new HashMap();
       
       mapa.put("colecao","Cole��o");
       mapa.put("descricao","Descri��o");
       
       return mapa;
    }
and then I call it from an action, setting it as a request parameter:
public class MontaBuscaColecaoAction extends Action {

    public ActionForward execute (
		ActionMapping mapping,
		ActionForm form,
		HttpServletRequest request,
		HttpServletResponse response) throws Exception {
            
                ColecaoGerenciador colecaoGer = new ColecaoGerenciador();
                Map mapa = colecaoGer.getAtributosColecao();
                
 		request.setAttribute("mapaColecao", mapa);
                return mapping.findForward("success");
	}           
and the last thing to do is to put it in the html:select. If it was a bean, I'd do like:
            <html:select property="myBean" size="1">
                <html:options collection="myBean" property="key" labelProperty="lblProperty"/>
            </html:select>
But with a map... my values have no name, how will I refer to them? Must I create a bean? Do they have like native names? What should I do?

Thanks and sorry
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 20 2005
Added on Aug 23 2005
3 comments
198 views