Repeating form on a page

2010-04-16 Thread David Hamilton
I am new to Wicket (and have had great help from this community so far -
thank you). My question here is that I'm trying to setup a simple
contact form where a person may have zero or more contacts. My solution
is to make the contact info a form within a panel. However, I need to
repeat the panel form on the page for each contact (represented by a
POJO I can bind to the form elements).  I will provide and add button
at the bottom of the list to allow them to re-submit the page and add a
new empty object bound to a new form element. 

 

  So my question is really two questions.

 

1)  Is this best approach for this situation?

2)  If it is, how do I bind each POJO on the list to a unique form
instance? 

 

The goal is to allow each contact to be individually edited  and saved. 

 

Any help is greatly appreciated.

 

Thanks, 

 

David Hamilton

Web Coordinator 

(615) 843-3337

Hermitage Lighting Gallery

www.hermitagelighting.com

 



Keep it Green! To help protect the environment, please
only print this email if necessary. 
Printing email can cost more than you think. 
Learn more on our website: http://www.hermitagelighting.com/printing_email.php

The information transmitted in this email is 
intended solely for the individual or entity 
to which it is addressed and may contain 
confidential and/or privileged material. 
Any review, retransmission, dissemination or
other use of or taking action in reliance 
upon this information by persons or entities 
other than the intended recipient is prohibited. 
If you have received this email in error please 
immediately notify us by reply email to the sender. 
You must destroy the original material and its contents from any computer. 
 



RE: Repeating form on a page

2010-04-16 Thread David Hamilton
Thanks for the great response! I will look at RefreshingView, but right now I'm 
considering yet another possibility. 
I'm think of using a display-only ListView for existing items with an edit 
button to populate a modal dialog. I have yet to get to the Modal dialog part 
so I'll have to report back on how well that works :).

Thanks,

David 

-Original Message-
From: Xavier López [mailto:xavil...@gmail.com] 
Sent: Friday, April 16, 2010 9:33 AM
To: users@wicket.apache.org
Subject: Re: Repeating form on a page

Hi,

I've been through a similar issue recently, also with a 'remove' button to
delete elements from the list. I ended up using RefreshingView (that's the
one I'd reccomend), and it worked nicely.

However I'll expose the various solutions I've gone through, hoping to
provide some background on the subject. I'd also be grateful on observations
and comments on these, because I'm sure I'm missing something and there are
still some aspects of these repeaters that I don't understand, so probably
part of these thoughts are wrong :)

In the first place, I used a ListView repeater. When clicking the 'add new'
button, however, I found that all unsaved input entered on the other list
elements was lost. That's because ListView refreshes the entire List with
the backing Model objects in it's ModelList, and models were not being
updated, as forms were not being submitted. So, I had to make the 'add new'
link a submit button (skipping default form processing in order to avoid
validation errors on incomplete data). However, to my surprise, same thing
keeped happening (same for the delete button). Later on, I found about
'ListView#setReuseItems(boolean)', which solved the problem. But to my
despair, the delete button always deleted the last element from the List. I
still do not understand why, and still don't know what is 'reuseItems'
really doing. (Any hints on that one?)

Then, I was advised to use RefreshingView, and things were moreover the
same, only that instead of having a ModelList given to the repeater, an
IteratorModel had to be provided in an overriden method. In this case, a
ModelsEqual ReuseItemStrategy had to be provided in order to keep the
unsaved inputs in the forms when adding/removing.


As a last appreciation, I have to say I hoped there was a specific component
addressing this behavior, being it a fairly common arrangement... If one day
I fully understand this I'd be happy to implement one myself, even if only
for the sake of clarity in my code ;)

Thanks,
Xavier

2010/4/16 David Hamilton dhamil...@hermitagelighting.com

 I am new to Wicket (and have had great help from this community so far -
 thank you). My question here is that I'm trying to setup a simple
 contact form where a person may have zero or more contacts. My solution
 is to make the contact info a form within a panel. However, I need to
 repeat the panel form on the page for each contact (represented by a
 POJO I can bind to the form elements).  I will provide and add button
 at the bottom of the list to allow them to re-submit the page and add a
 new empty object bound to a new form element.



  So my question is really two questions.



 1)  Is this best approach for this situation?

 2)  If it is, how do I bind each POJO on the list to a unique form
 instance?



 The goal is to allow each contact to be individually edited  and saved.



 Any help is greatly appreciated.



 Thanks,



 David Hamilton

 Web Coordinator

 (615) 843-3337

 Hermitage Lighting Gallery

 www.hermitagelighting.com




 
 Keep it Green! To help protect the environment, please
 only print this email if necessary.
 Printing email can cost more than you think.
 Learn more on our website:
 http://www.hermitagelighting.com/printing_email.php

 The information transmitted in this email is
 intended solely for the individual or entity
 to which it is addressed and may contain
 confidential and/or privileged material.
 Any review, retransmission, dissemination or
 other use of or taking action in reliance
 upon this information by persons or entities
 other than the intended recipient is prohibited.
 If you have received this email in error please
 immediately notify us by reply email to the sender.
 You must destroy the original material and its contents from any computer.
 




-- 
Klein bottle for rent--inquire within.


Keep it Green! To help protect the environment, please
only print this email if necessary. 
Printing email can cost more than you think. 
Learn more on our website: http://www.hermitagelighting.com/printing_email.php

The information transmitted in this email is 
intended solely for the individual or entity 
to which it is addressed and may contain 
confidential and/or privileged material. 
Any review, retransmission, dissemination or
other use of or taking action in reliance 
upon

Newbie Question about populating form values

2010-04-14 Thread David Hamilton

I'm a new Wicket using trying to figure out how to populate a form's
initial value with data from a bean (that is in the session already).
I've actually got it working, but I don't think I'm doing the best way.
public final class EmployeeMain extends BasePage {
public EmployeeMain() {
super ();
Form employeeForm=new Form(employeeContactForm);
Contact contact=getEmployeeSession().getEmployee().getEmpInfo();
employeeForm.setModel(new CompoundPropertyModel(contact));
add(new TextField(firstName,new
Model(contact.getFirstName(;
add(new TextField(lastName));

}

My issue is with this line:
add(new TextField(firstName,new Model(contact.getFirstName(;
Should I have to set the model even though I'm binding the form to a
bean has this property?
What is the correct way to handle setting the initial form value from a
bean?

Thanks,

David


Keep it Green! To help protect the environment, please
only print this email if necessary. 
Printing email can cost more than you think. 
Learn more on our website: http://www.hermitagelighting.com/printing_email.php

The information transmitted in this email is 
intended solely for the individual or entity 
to which it is addressed and may contain 
confidential and/or privileged material. 
Any review, retransmission, dissemination or
other use of or taking action in reliance 
upon this information by persons or entities 
other than the intended recipient is prohibited. 
If you have received this email in error please 
immediately notify us by reply email to the sender. 
You must destroy the original material and its contents from any computer. 
 


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