On 15/08/05, Dariusz Wojtas <[EMAIL PROTECTED]> wrote:
> I have some data loaded into my form's model.
> The model:
>     String id
>     String propB
>     String propC
> 
> I want to display for editing propB and propC.
> Do I have to save/send 'id' in a hidden field to preserve its value on
> next submit?
> Or Wicket does some magic with session/request scoping here?
> What are the options at all here? Is it configurable? How?
> 
> Darek

It's magic! :-)  Just to add to what Jon & Phil posted, the following
is a fully functional page (using the 1.1b2) - try it in the
QuickStart app, for instance.

/Gwyn
---- Start FormDemo.html ----
<html>
<body>
      <form wicket:id="form">
          <input type=text wicket:id="propB" />
          <input type=text wicket:id="propC" />
          <input type=submit  value="OK"/>
      </form>
    <hr>
    <span wicket:id="feedback"/>
</body>
</html>
---- End FormDemo.html ----
---- Start FormDemo.java ----
package wicket.quickstart;

import wicket.PageParameters;
import wicket.IFeedback;
import wicket.markup.html.WebPage;
import wicket.markup.html.form.Form;
import wicket.markup.html.form.TextField;
import wicket.markup.html.panel.FeedbackPanel;
import wicket.model.CompoundPropertyModel;

public class FormDemo extends WebPage {
    public FormDemo(final PageParameters parameters) {
        FeedbackPanel feedback = new FeedbackPanel("feedback");
        add(feedback);
        add(new MyForm("form", feedback));
    }

    private static class MyForm extends Form {
        public MyForm(String name, IFeedback feedback) {
            super(name, new CompoundPropertyModel(new MyModel()), feedback);
            add(new TextField("propB"));
            add(new TextField("propC"));
        }
        public void onSubmit() { info("Model = " + getModelObject()); }
    }

    private static class MyModel {
        String id = "Some id";
        String propB = "Property B";
        String propC = "Property C";

        public void setPropB(String propB) { this.propB = propB; }
        public void setPropC(String propC) { this.propC = propC; }

        public String getPropB() { return propB; }
        public String getPropC() { return propC; }

        public String toString() {
            return "MyModel{" + "id='" + id + "'" + ", propB='" +
propB + "'" + ", propC='" + propC + "'" + "}";
        }
    }
}
---- End FormDemo.java ----


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to