Sorry, I accidently pressed send somehow before I finished writing down the
relevant code. Here is what I meant to write:
// package and import statments...
public class MyPage extends BasePage {
// some fields
public MyPage() {
super();
MyModelObj pojo = new MyModelObj();
CompoundPropertyModel model = new CompoundPropertyModel(pojo);
Form regForm = new RegisterForm("registerForm", model);
FeedbackPanel feedback = new FeedbackPanel("feedback");
TextField name = new TextField("name");
name.setRequired(true);
DateTimeField startTime = new DateTimeField("startTime");
startTime.setRequired(true);
regForm.add(name);
regForm.add(startTime);
add(regForm);
add(feedback);
}
class RegisterForm extends Form {
private static final long serialVersionUID = 1L;
public ExperimentRegisterForm(String id, CompoundPropertyModel
model) {
super(id, model);
}
@Override
protected void onSubmit() {
RecruitSession session = getRecruitSession();
MyModelObj pojo = (MyModelObj) getModelObject();
//Then persist the pojo object with a hibernate DAO etc etc...
}
}
}
Here is the model object code:
public class MyModelObj implements Serializable {
private String name;
private Date startTime;
public Experiment() {
}
//The getters and setters
}
And then last but not least the html:
<wicket:extend>
<span wicket:id="feedback"> Feedback messages go here </span>
<form class="RegisterForm" wicket:id="registerForm" action="">
<fieldset><legend>Registration</legend>
<ol>
<li>Name <input wicket:id="name" /></li>
<li>Start Time <span wicket:id="startTime"/></li>
</ol>
<input type="submit" value="Register" /></fieldset>
</form>
</wicket:extend>
So why doesn't the datetimefield bind to the Date obj in MyModelObj? Why
does the feedback panel tell me it was never filled in?
Thanks for any help you can give.
-Alex Pine
[EMAIL PROTECTED]
On 8/9/07, Alex Pine <[EMAIL PROTECTED]> wrote:
>
> Hi all,
> I am trying to use the DateTimeField from the
> org.apache.wicket.extensions.yui.calendar package, and i have run into a
> snafu that I can't figure out. When I submit the form, my feedback panel
> reacts as if I had not filled it in when I have. I can't figure out why this
> happens. Here is what my code looks like:
>
> // package and import statments...
>
> public class MyPage extends BasePage {
>
> // some fields
>
> public MyPage() {
> super();
>
> MyModelObj pojo = new MyModelObj();
>
> CompoundPropertyModel model = new CompoundPropertyModel(pojo);
> Form regForm = new RegisterForm("registerForm", model);
> FeedbackPanel feedback = new FeedbackPanel("feedback");
>
> TextField name = new TextField("name");
> name.setRequired(true);
>
> DateTimeField startTime = new DateTimeField("startTime");
> startTime.setRequired(true);
>
> regForm.add(name);
> regForm.add(startTime);
>
> add(regForm);
> add(feedback);
> }
>
> class RegisterForm extends Form {
>
> private static final long serialVersionUID = 1L;
>
> public ExperimentRegisterForm(String id, CompoundPropertyModel
> model) {
> super(id, model);
> }
>
> @Override
> protected void onSubmit() {
>
> RecruitSession session = getRecruitSession();
> Experimenter experimenter = (Experimenter) session.getUser();
> MyModelObj pojo = (MyModelObj) session.getPojo();
> Experiment experiment = (Experiment) getModelObject();
> experiment.setExperimenter(experimenter);
> experiment.setValid (true);
> experimenter.addExperiment(experiment);
> /**
> * make a detachable model so that the user can use the "back"
> * button without losing everything in the form.
> */
> expModel = new DetachableExperimentModel(experiment,
> experimentDAO);
>
> log.info("Attempting to persist newly created experiment: " +
> experiment);
>
> experimentDAO.persistExperiment(experiment);
> setResponsePage(new ExperimenterHome());
> }
> }
>
>
>
> }
>