Re: ListViews in a form question

2008-06-11 Thread Martin Makundi
Hi!

I have come up with a work-around not to loose the form components
when having to rebuild a ListView (after .removeAll).

I built a hashmaper for reusing the formComponents and it works ;)

However, I wonder if this could/should be incorporated within the
repeaters - what do you think? Furthermore, into which repeater should
it be incorporated? Any design ideas?

Here is the separate tool and its usage:

populateItem(...) {...
TextArea descriptionField = new
TextArea(DESCRIPTION_EDITOR, ...);
descriptionField = (TextArea)
reuseManager.rememberOrReuse(task, DESCRIPTION_EDITOR,
descriptionField);
form.add(descriptionField);
}

And the reuseManager itself is simple as follows:

public class FormComponentReuseManager {
  private final Map>> idMapRow =
new HashMap>>();

  public FormComponent rememberOrReuse(Object rowId, String
componentId, FormComponent newComponent) {
Map> rowMap = createOrReuse(rowId);

FormComponent existingComponent = rowMap.get(componentId);

if (existingComponent == null) {
  rowMap.put(componentId, newComponent);
  return newComponent;
}

// else
return existingComponent;
  }

  private Map> createOrReuse(Object rowId) {
Map> rowMap = idMapRow.get(rowId);
if (rowMap == null) {
  rowMap = new HashMap>();
  idMapRow.put(rowId, rowMap);
}

return rowMap;
  }
}




**
Martin



> Hi!
>
> What is the main difference between repeatingView and listView from
> this point of view?
>
> I can see ListView has many features I do not use such a s moving the
> rows up and down...
>
> **
> Martin
>
> 2008/6/11 Al Maw <[EMAIL PROTECTED]>:
>> This sort of stuff is definitely possible - people certainly have it working
>> elsewhere.
>>
>> If you use setReuseItems(true) you need to call removeAll() if you change
>> the backing model object.
>>
>> Timo is probably right that a RepeatingView may be easier to use in this
>> kind of situation.
>>
>> Alastair
>>
>> 2008/6/11 Martin Makundi <[EMAIL PROTECTED]>:
>>
>>> Hi!
>>>
>>> I have nested listviews which draw a complex tabular form having
>>> variable colspans and rowspans depending on the state of the form.
>>>
>>> I have an Add button to add elements into one of the inner listviews.
>>>
>>> Problem:
>>> 1. If I have "setReuseItems" true, the HTML table is not rendered
>>> properly (somehow the old table structure remains which should be
>>> restructured).
>>> 2. If I have "setReuseItems" false, the form components loose their
>>> state (unsubmitted entries) whenever I press the button.
>>>
>>> So. In my understanding, I need to both a) redraw the html table (at
>>> least update the colspan and rowspan attributes) and still b) preserve
>>> the form component state :) Is there an "out-of-the-box" solution for
>>> this?
>>>
>>> **
>>> Martin
>>>
>>> -
>>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>>> For additional commands, e-mail: [EMAIL PROTECTED]
>>>
>>>
>>
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: ListViews in a form question

2008-06-11 Thread Martin Makundi
Hi!

What is the main difference between repeatingView and listView from
this point of view?

I can see ListView has many features I do not use such a s moving the
rows up and down...

**
Martin

2008/6/11 Al Maw <[EMAIL PROTECTED]>:
> This sort of stuff is definitely possible - people certainly have it working
> elsewhere.
>
> If you use setReuseItems(true) you need to call removeAll() if you change
> the backing model object.
>
> Timo is probably right that a RepeatingView may be easier to use in this
> kind of situation.
>
> Alastair
>
> 2008/6/11 Martin Makundi <[EMAIL PROTECTED]>:
>
>> Hi!
>>
>> I have nested listviews which draw a complex tabular form having
>> variable colspans and rowspans depending on the state of the form.
>>
>> I have an Add button to add elements into one of the inner listviews.
>>
>> Problem:
>> 1. If I have "setReuseItems" true, the HTML table is not rendered
>> properly (somehow the old table structure remains which should be
>> restructured).
>> 2. If I have "setReuseItems" false, the form components loose their
>> state (unsubmitted entries) whenever I press the button.
>>
>> So. In my understanding, I need to both a) redraw the html table (at
>> least update the colspan and rowspan attributes) and still b) preserve
>> the form component state :) Is there an "out-of-the-box" solution for
>> this?
>>
>> **
>> Martin
>>
>> -
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: ListViews in a form question

2008-06-11 Thread Al Maw
This sort of stuff is definitely possible - people certainly have it working
elsewhere.

If you use setReuseItems(true) you need to call removeAll() if you change
the backing model object.

Timo is probably right that a RepeatingView may be easier to use in this
kind of situation.

Alastair

2008/6/11 Martin Makundi <[EMAIL PROTECTED]>:

> Hi!
>
> I have nested listviews which draw a complex tabular form having
> variable colspans and rowspans depending on the state of the form.
>
> I have an Add button to add elements into one of the inner listviews.
>
> Problem:
> 1. If I have "setReuseItems" true, the HTML table is not rendered
> properly (somehow the old table structure remains which should be
> restructured).
> 2. If I have "setReuseItems" false, the form components loose their
> state (unsubmitted entries) whenever I press the button.
>
> So. In my understanding, I need to both a) redraw the html table (at
> least update the colspan and rowspan attributes) and still b) preserve
> the form component state :) Is there an "out-of-the-box" solution for
> this?
>
> **
> Martin
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


Re: ListViews in a form question

2008-06-11 Thread Martin Makundi
> For some reason, I have often succeeded better with other
> repeaters than ListView (e.g. RefreshingView, DataView) in
> complex situations.

I have postponed studying these, I suspect problems with varying
column counts on rows.

> I think that in a normal submit the same applies -- you have
> to store all the data (in models for example) to the server
> so that you can display it again when the page is refreshed.

One solution could probably be to require the form to pass validation
when these buttons are pressed. But the intuitivity of this solution
is not perfect ;)

**
Martin

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: ListViews in a form question

2008-06-11 Thread Timo Rantalaiho
On Wed, 11 Jun 2008, Martin Makundi wrote:
> I have nested listviews which draw a complex tabular form having
> variable colspans and rowspans depending on the state of the form.

For some reason, I have often succeeded better with other 
repeaters than ListView (e.g. RefreshingView, DataView) in 
complex situations. 

> 1. If I have "setReuseItems" true, the HTML table is not rendered
> properly (somehow the old table structure remains which should be
> restructured).

If the old Items are left there, the old structure remains, 
so this seems to make sense.

> 2. If I have "setReuseItems" false, the form components loose their
> state (unsubmitted entries) whenever I press the button.

Yeah I think that this is what it always does; new Items
don't have any idea of the input fed to the old Items
(except if they share the same model, and the data was
updated all the way to the model).

> So. In my understanding, I need to both a) redraw the html table (at
> least update the colspan and rowspan attributes) and still b) preserve
> the form component state :) Is there an "out-of-the-box" solution for
> this?

If you repaint the component via ajax, with HTML that comes
from the server, you must have sent the data to the server
with a suitable ajax behavior so that it can be in the ajax
reponse. 

I think that in a normal submit the same applies -- you have
to store all the data (in models for example) to the server
so that you can display it again when the page is refreshed.
When conversion or validation errors occur, Wicket returns
the original raw input to form components, but also in that
case the data made the trip to the server and back.

Best wishes,
Timo

-- 
Timo Rantalaiho   
Reaktor Innovations Oyhttp://www.ri.fi/ >

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



ListViews in a form question

2008-06-11 Thread Martin Makundi
Hi!

I have nested listviews which draw a complex tabular form having
variable colspans and rowspans depending on the state of the form.

I have an Add button to add elements into one of the inner listviews.

Problem:
1. If I have "setReuseItems" true, the HTML table is not rendered
properly (somehow the old table structure remains which should be
restructured).
2. If I have "setReuseItems" false, the form components loose their
state (unsubmitted entries) whenever I press the button.

So. In my understanding, I need to both a) redraw the html table (at
least update the colspan and rowspan attributes) and still b) preserve
the form component state :) Is there an "out-of-the-box" solution for
this?

**
Martin

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]