I have populated a form with values representing several different
objects. This is what my markup looks like:


            <form wicket:id = "moviesForm" id = "moviesForm">
                <span wicket:id = "movies" id = "movies">
                    <a wicket:id = "removeLink">(remove)</a>
                    <input type="text" wicket:id="name" class="nospam"/>
                    <select wicket:id="category"/>
                    <span wicket:id="rating">rating</span>
                    <br />
                </span>
                <input type = "submit" value = "Update Movies" id="formsubmit"/>
            </form>

The span is reproduced for each object that I pull from a database.
There is a different identifier for each span, as you can see here:
http://screencast.com/t/l8pLGZnJVn8

I want to be able to access these objects when I click submit the
form, but I'm not sure how to get access to them. This is what I have
tried so far:


        Form moviesForm = new Form<ValueMap>("moviesForm") {
            /**
             * Show the resulting valid new movie
             */
            @Override
            public final void onSubmit() {
                ValueMap values = getModelObject();

                // perform validation and security here
                if (StringUtils.isBlank((String) values.get("name"))) {
                    error("Received bad input!!!");
                    return;
                }

                Session session =
HibernateUtil.getSessionFactory().getCurrentSession();
                session.beginTransaction();

                Movie movie = new Movie();
                movie.setName((String) values.get("name"));
                movie.setCategory((Category) values.get("category"));
                session.save(movie);
                session.getTransaction().commit();
            }

        };

The ValueMap values comes back null from getModelObject(). Any
pointers for me to get these objects back in a way that I can easily
update them?

Thanks.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to