Re: FormComponent markup

2013-02-03 Thread Andrea Del Bene

To clarify a bit more, you should end up writing something like:

form  wicket:id=form
  input type=text   wicket:id=formcomponentA /
  textarea  wicket:id=formcomponentB.../textarea
/form

 and Java code

Form form = new Form(form);

form.add(new FormComponentA(formcomponentA));
form.add(new FormComponentB(formcomponentB));


In data sabato 2 febbraio 2013 22:28:11, Lucio Crusca ha scritto:

Does that mean I'll have A.html like

form
   input type=text ... /
   textarea.../textarea
/form

and then add my FormComponentA and FormComponentB instances directly to
that Form? And that I won't have any FormComponentA.html /
FormComponentB.html?

Probably not, I suspect I haven't understood. I tried doing like stated above,
but the FormComponent constructor wants an id, so now I assume that each
FormComponent subclass instance has to provide a different id. That makes me
wonder again how should I write the html files.

I'm not able to explain why, but the following solutions seems wrong to me:

form
   div wicket:id=formcomponentA
 input type=text ... /
   /div
   div wicket:id=formcomponentB
 textarea.../textarea
   /div
form





-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: FormComponent markup

2013-02-03 Thread Lucio Crusca
In data domenica 3 febbraio 2013 13:17:13, Andrea Del Bene ha scritto:
 To clarify a bit more, you should end up writing something like:
 
 form  wicket:id=form
input type=text   wicket:id=formcomponentA /
textarea  wicket:id=formcomponentB.../textarea
 /form
 
   and Java code
 
 Form form = new Form(form);
 
 form.add(new FormComponentA(formcomponentA));
 form.add(new FormComponentB(formcomponentB));

Thanks, now it seems clear. Last doubt, what if I have two or more texts in 
either FormComponent? Shouls I repeat wicket:id=FormComponentA for each one?



Re: FormComponent markup

2013-02-03 Thread Lucio Crusca
In data domenica 3 febbraio 2013 14:57:46, Lucio Crusca ha scritto:
 In data domenica 3 febbraio 2013 13:17:13, Andrea Del Bene ha scritto:
  To clarify a bit more, you should end up writing something like:
  
  form  wicket:id=form
  
 input type=text   wicket:id=formcomponentA /
 textarea  wicket:id=formcomponentB.../textarea
  
  /form
  
and Java code
  
  Form form = new Form(form);
  
  form.add(new FormComponentA(formcomponentA));
  form.add(new FormComponentB(formcomponentB));
 
 Thanks, now it seems clear. Last doubt, what if I have two or more texts in
 either FormComponent? Shouls I repeat wicket:id=FormComponentA for each
 one?

No, it's not clear to me once again, sorry, but the above suggestion does not 
fit the real case.

Let's make a more concrete example.

class Person
{
  String firstname;
  String lastname;
}

class PhoneNumber
{
  Person person;
  String dial;
  boolean mobile;
}

class PersonFormComponent extends FormComponentPerson
{
  PersonFormComponent(Person p)
  {
super(personFormComponent, new CompoundPropertyModel(p));
add(new TextField(firstname));
add(new TextField(lastname));
  }
}

class PhoneNumberComponent extends FormComponentModelPhoneNumber
{
  PhoneNumberComponent(PhoneNumber n)
  {
super(phoneNumberFormComponent, new CompoundPropertyModel(n));
add(new TextField(dial));
add(new CheckBox(mobile));
  }
}

class PersonForm
{
  PersonForm(Person p)
  { 
   super(personForm);
   add(new PersonFormComponent(personFormComponent, 
new CompoundPropertyModel(model));
   PhoneNumber pn = findOrCreatePhoneNumber(p);
   add(new PhoneNumberFormComponent(phoneNumberComponent, pn);
  }
}

PersonForm.html:
form wicket:id=personForm
  First Name:input type=text size=20 wicket:id=/
  Last Name:input type=text size=20 wicket:id=/
  ...
  Phone Number:input type=text size=20 wicket:id= /
  Mobile?input type=checkbox wicket:id= /
/form

What should I write in place of  ? If I put the FormComponents IDs then 
the CompoundPropertyModels won't find the fields to bind. If I put the beans 
fields names, then the PersonForm constructor won't find the IDs to bind the 
whole FormComponent subclasses.

Can you please show me the markup needed for the above example?


Re: FormComponent markup

2013-02-03 Thread Andrea Del Bene
ok, I think I've figured out what you need. If you want to group two or 
more form fields in your custom form component you should extend class 
FormComponentPanel instead of FormComponent. This class combines the 
features of both a Panel (it has it's own markup file) and a 
FormComponent (it is a subclass of FormComponent). So for example 
PersonFormComponent will have the following code and markup:


class PersonFormComponent extends FormComponentPanelPerson
{
  PersonFormComponent(Person p)
  {
super(personFormComponent, new CompoundPropertyModel(p));
add(new TextField(firstname));
add(new TextField(lastname));
  }
}

markup:

html

wicket:panel
First Name:input type=text size=20 wicket:id=firstname/
Last Name:input type=text size=20 wicket:id=lastname/
/wicket:panel

/html

Now you can attach you custom component in your form as if it was a 
Panel. You can use a div or a span tag to attach it:



Form form = new Form(form);

form.add(new PersonFormComponent(personFormComponent));

markup:

form wicket:id=form
  div wicket:id=personFormComponent
  /div
form

Remember that if you don't like to have a div or a span in you final 
markup you can always call setRenderBodyOnly(true) on your custom component.

No, it's not clear to me once again, sorry, but the above suggestion does not
fit the real case.

Let's make a more concrete example.

class Person
{
   String firstname;
   String lastname;
}

class PhoneNumber
{
   Person person;
   String dial;
   boolean mobile;
}

class PersonFormComponent extends FormComponentPerson
{
   PersonFormComponent(Person p)
   {
 super(personFormComponent, new CompoundPropertyModel(p));
 add(new TextField(firstname));
 add(new TextField(lastname));
   }
}

class PhoneNumberComponent extends FormComponentModelPhoneNumber
{
   PhoneNumberComponent(PhoneNumber n)
   {
 super(phoneNumberFormComponent, new CompoundPropertyModel(n));
 add(new TextField(dial));
 add(new CheckBox(mobile));
   }
}

class PersonForm
{
   PersonForm(Person p)
   {
super(personForm);
add(new PersonFormComponent(personFormComponent,
new CompoundPropertyModel(model));
PhoneNumber pn = findOrCreatePhoneNumber(p);
add(new PhoneNumberFormComponent(phoneNumberComponent, pn);
   }
}

PersonForm.html:
form wicket:id=personForm
   First Name:input type=text size=20 wicket:id=/
   Last Name:input type=text size=20 wicket:id=/
   ...
   Phone Number:input type=text size=20 wicket:id= /
   Mobile?input type=checkbox wicket:id= /
/form

What should I write in place of  ? If I put the FormComponents IDs then
the CompoundPropertyModels won't find the fields to bind. If I put the beans
fields names, then the PersonForm constructor won't find the IDs to bind the
whole FormComponent subclasses.

Can you please show me the markup needed for the above example?




-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: FormComponent markup

2013-02-02 Thread Andrea Del Bene

Hi,

if you are planning to subclass a FormComponent (let's say a TextField 
for the id and a TextArea for the description) you don't need to use 
panels and you will bind your custom components to standard form's tags 
input type=text/ and texarea.../textarea
IMHO the second component should uses both models: IModelB as main 
model and IModelA to retrieve the A object to assign to manyBToOneA.

Hello *,

I have two classes, along the lines of:

class A
{
   String id;
}

class B
{
   A manyBToOneA;
   String description;
}

I want to provide a single form such as:

Id: 
Default description: 
[Submit]

I plan to use two subclasses of FormComponent, so that one uses IModelA, the
other usaes IModelB and they are reusable in other forms.

What would be the HTML markup for the main form? Should I use two
wicket:panel also if FormComponent is not a Panel? Should I use two div
wicket:id=...? What if I prefer to avoid div-ing the different fields of
the form?

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org




-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: FormComponent markup

2013-02-02 Thread Lucio Crusca
In data sabato 2 febbraio 2013 14:54:41, Andrea Del Bene ha scritto:
 Hi,
 
 if you are planning to subclass a FormComponent (let's say a TextField
 for the id and a TextArea for the description) you don't need to use
 panels and you will bind your custom components to standard form's tags
 input type=text/ and texarea.../textarea

Does that mean I'll have A.html like

form
  input type=text ... /
  textarea.../textarea
/form

and then add my FormComponentA and FormComponentB instances directly to that 
Form? And that I won't have any FormComponentA.html / FormComponentB.html?


 IMHO the second component should uses both models: IModelB as main
 model and IModelA to retrieve the A object to assign to manyBToOneA.

Makes sense.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: FormComponent markup

2013-02-02 Thread Lucio Crusca
In data sabato 2 febbraio 2013 22:28:11, Lucio Crusca ha scritto:
 
 Does that mean I'll have A.html like
 
 form
   input type=text ... /
   textarea.../textarea
 /form
 
 and then add my FormComponentA and FormComponentB instances directly to
 that Form? And that I won't have any FormComponentA.html /
 FormComponentB.html?

Probably not, I suspect I haven't understood. I tried doing like stated above, 
but the FormComponent constructor wants an id, so now I assume that each 
FormComponent subclass instance has to provide a different id. That makes me 
wonder again how should I write the html files.

I'm not able to explain why, but the following solutions seems wrong to me:

form
  div wicket:id=formcomponentA
input type=text ... /
  /div
  div wicket:id=formcomponentB
textarea.../textarea
  /div
form