Oh, I'm glad to be back to Wicket. I've been off on a Struts project for several months, and am so happy to be using simple Wicket again!

But I'm having a problem with my brain. This should be easy to figure out, but I keep getting stuck. Maybe it's the late nights... I'm trying to add a drop-down list, something I've done plenty often. And it ain't working! I've got a simple test case. Code is below.

Any suggestions (including one for more coffee) would be much appreciated.

Thanks,

  -- Scott


I'm getting a Wicket Runtime Exception:
======================================================================
wicket.WicketRuntimeException: Error getting id value of: ABC for property: name at wicket.markup.html.form.ChoiceRenderer.getIdValue(ChoiceRenderer.java:154)
[ ... ]
Caused by: ognl.NoSuchPropertyException: java.lang.String.name
at ognl.ObjectPropertyAccessor.getProperty(ObjectPropertyAccessor.java:123)
[ ... ]
======================================================================


Component Tree
======================================================================
#       Path    Type    Model Object
1       _body           wicket.markup.html.BodyOnLoadContainer          
2 theForm wicket.markup.html.form.Form OGNL Exception: expression='theForm'; path='0:theForm'
3       theForm:choose          wicket.markup.html.form.DropDownChoice          
ABC
======================================================================


HTML
======================================================================
<html>
<head>
<title>Wicket Application</title>
<link rel="stylesheet" type="text/css" href="css/default.css"/>
<script type="text/javascript" language="JavaScript" src="js/test.js"></script>
</head>
<body>
<h1>Wicket Test Application</h1>
<p>This is a simple test of a Wicket Application.</p>
<form wicket:id="theForm">
<select wicket:id="choose">
<option value="test">Test Choice</option>
</select>
</form>
</body>
</html>
======================================================================


Java
======================================================================
package com.example.view;

import java.util.ArrayList;
import java.util.List;
import wicket.markup.html.form.ChoiceRenderer;
import wicket.markup.html.form.DropDownChoice;
import wicket.markup.html.form.Form;
import wicket.markup.html.WebPage;
import wicket.model.CompoundPropertyModel;

public class Main extends WebPage {

    public static List theList = getTheList();

    public Main() {
        super();
        add(new InputForm("theForm", new MyModel()));
    }

    public static class InputForm extends Form {
        public InputForm(String name, MyModel model) {
            super(name,  new CompoundPropertyModel(model));
add(new DropDownChoice("choose", theList, new ChoiceRenderer("description", "name")));
        }
    }

    private static List getTheList() {
        List items = new ArrayList();
        items.add(new Item("ABC", "First"));
        items.add(new Item("DEF", "Second"));
        items.add(new Item("XYZ", "Last"));
        return items;
    }

    public static class MyModel {
        private String choose ="ABC";
        public String getChoose() {return choose;}
        public void setChoose(String newChoose) {choose = newChoose;}
    }

    public static class Item {
        public Item(String name, String description) {
            this.name = name;
            this.description = description;
        }

        public String toString() {
            return description + " [" + name + "]";
        }

        private String name;
        public String getName() {return name;}
        public void setName(String newName) {name = newName;}

        private String description;
        public String getDescription() {return description;}
public void setDescription(String newDescription) {description = newDescription;}
    }
}======================================================================




-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to