You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Peter Ertl (JIRA)" <ji...@apache.org> on 2007/12/14 13:33:46 UTC
[jira] Created: (WICKET-1227) Provide easier access to items of
RefreshingView
Provide easier access to items of RefreshingView
------------------------------------------------
Key: WICKET-1227
URL: https://issues.apache.org/jira/browse/WICKET-1227
Project: Wicket
Issue Type: Improvement
Components: wicket
Reporter: Peter Ertl
Attachments: AccessItemsOfRefreshingView.patch
When trying to directly access items of a RefreshingView (or subclasses of it) everything gets really complicated.
For Example:
When inserting a new, blank post into a guestbook the input focus should be set to the input field 'author'.
public void onClick(final AjaxRequestTarget target)
{
// add new, blank entry to the guestbook posts model
posts.add(new Post());
//
// code that gets us the last item of the repeating view.
// however, the view first has to be rendered in order to contain the new item
// as it's only in the model but will not appear in the RefreshingView unless
// RefreshingView#onBeforeRender() is called
Item lastItem = ...???...
target.addComponent(/* container that contains the refreshing view */);
target.focusComponent(lastItem.get("author"));
}
Now what I did is attach a patch to provide methods for updating and getting the items of the RefreshingView.
the above example would look like this:
public void onClick(final AjaxRequestTarget target)
{
posts.add(new Post());
guestbookView.refresh();
Item[] items = guestbookView.items();
Item lastItem = items[items.length() - 1];
target.addComponent(/* container that contains the refreshing view */);
target.focusComponent(lastItem.get("author")); // put focus on "author" component where user can enter his name
}
Basically it works like this:
the refresh() method will invoke onBeforeRender() to populate the items of the view (based on the current model). That way you can access the items before the actual render occurs (using the iterator function MarkupContainer#getItems() ). Once the render occurs it would be just too late...
In order to prevent unnecessary subsequent calls of onBeforeRender() a flag will remember if the view needs refreshing, so onBeforeRender() is only called once per render (unless you call refresh() for another time).
items() is a convenience method that collects the current items using MarkupContainer#getItems() and returns a handy array of items and avoids cumbersome code.
I also added firstItem() and lastItem() as I think these will be quite common use cases for accessing that array.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Resolved: (WICKET-1227) Provide easier access to items of
RefreshingView
Posted by "Igor Vaynberg (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-1227?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Igor Vaynberg resolved WICKET-1227.
-----------------------------------
Resolution: Won't Fix
Fix Version/s: 1.3.0-rc3
the whole point of the class hieararchy of refreshingview and down is that you dont manage the items yourself, the view manages the items for you. if you want to have access to items then use the low level repeatingview.
> Provide easier access to items of RefreshingView
> ------------------------------------------------
>
> Key: WICKET-1227
> URL: https://issues.apache.org/jira/browse/WICKET-1227
> Project: Wicket
> Issue Type: Improvement
> Components: wicket
> Reporter: Peter Ertl
> Assignee: Igor Vaynberg
> Fix For: 1.3.0-rc3
>
> Attachments: AccessItemsOfRefreshingView.patch
>
>
> When trying to directly access items of a RefreshingView (or subclasses of it) everything gets really complicated.
> For Example:
> When inserting a new, blank post into a guestbook the input focus should be set to the input field 'author'.
> public void onClick(final AjaxRequestTarget target)
> {
> // add new, blank entry to the guestbook posts model
> posts.add(new Post());
> //
> // code that gets us the last item of the repeating view.
> // however, the view first has to be rendered in order to contain the new item
> // as it's only in the model but will not appear in the RefreshingView unless
> // RefreshingView#onBeforeRender() is called
> Item lastItem = ...???...
> target.addComponent(/* container that contains the refreshing view */);
> target.focusComponent(lastItem.get("author"));
> }
> Now what I did is attach a patch to provide methods for updating and getting the items of the RefreshingView.
> the above example would look like this:
> public void onClick(final AjaxRequestTarget target)
> {
> posts.add(new Post());
> guestbookView.refresh();
> Item[] items = guestbookView.items();
> Item lastItem = items[items.length() - 1];
> target.addComponent(/* container that contains the refreshing view */);
> target.focusComponent(lastItem.get("author")); // put focus on "author" component where user can enter his name
> }
> Basically it works like this:
> the refresh() method will invoke onBeforeRender() to populate the items of the view (based on the current model). That way you can access the items before the actual render occurs (using the iterator function MarkupContainer#getItems() ). Once the render occurs it would be just too late...
> In order to prevent unnecessary subsequent calls of onBeforeRender() a flag will remember if the view needs refreshing, so onBeforeRender() is only called once per render (unless you call refresh() for another time).
> items() is a convenience method that collects the current items using MarkupContainer#getItems() and returns a handy array of items and avoids cumbersome code.
> I also added firstItem() and lastItem() as I think these will be quite common use cases for accessing that array.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (WICKET-1227) Provide easier access to items of
RefreshingView
Posted by "Frank Bille Jensen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-1227?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Frank Bille Jensen updated WICKET-1227:
---------------------------------------
Fix Version/s: (was: 1.3.1)
> Provide easier access to items of RefreshingView
> ------------------------------------------------
>
> Key: WICKET-1227
> URL: https://issues.apache.org/jira/browse/WICKET-1227
> Project: Wicket
> Issue Type: Improvement
> Components: wicket
> Reporter: Peter Ertl
> Assignee: Igor Vaynberg
> Attachments: AccessItemsOfRefreshingView.patch
>
>
> When trying to directly access items of a RefreshingView (or subclasses of it) everything gets really complicated.
> For Example:
> When inserting a new, blank post into a guestbook the input focus should be set to the input field 'author'.
> public void onClick(final AjaxRequestTarget target)
> {
> // add new, blank entry to the guestbook posts model
> posts.add(new Post());
> //
> // code that gets us the last item of the repeating view.
> // however, the view first has to be rendered in order to contain the new item
> // as it's only in the model but will not appear in the RefreshingView unless
> // RefreshingView#onBeforeRender() is called
> Item lastItem = ...???...
> target.addComponent(/* container that contains the refreshing view */);
> target.focusComponent(lastItem.get("author"));
> }
> Now what I did is attach a patch to provide methods for updating and getting the items of the RefreshingView.
> the above example would look like this:
> public void onClick(final AjaxRequestTarget target)
> {
> posts.add(new Post());
> guestbookView.refresh();
> Item[] items = guestbookView.items();
> Item lastItem = items[items.length() - 1];
> target.addComponent(/* container that contains the refreshing view */);
> target.focusComponent(lastItem.get("author")); // put focus on "author" component where user can enter his name
> }
> Basically it works like this:
> the refresh() method will invoke onBeforeRender() to populate the items of the view (based on the current model). That way you can access the items before the actual render occurs (using the iterator function MarkupContainer#getItems() ). Once the render occurs it would be just too late...
> In order to prevent unnecessary subsequent calls of onBeforeRender() a flag will remember if the view needs refreshing, so onBeforeRender() is only called once per render (unless you call refresh() for another time).
> items() is a convenience method that collects the current items using MarkupContainer#getItems() and returns a handy array of items and avoids cumbersome code.
> I also added firstItem() and lastItem() as I think these will be quite common use cases for accessing that array.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Reopened: (WICKET-1227) Provide easier access to items of
RefreshingView
Posted by "Peter Ertl (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-1227?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Peter Ertl reopened WICKET-1227:
--------------------------------
Sorry for reopening but...
the methods are only giving you access to the items, not manipulating them.
I don't want to manage the items but access them for getting the markup id of the item and of the children. this is required to use javascript on them (I think so). How else would you do that (like the focus thing described previously) ?
If you think this is wrong feel free to close the issue again.
> Provide easier access to items of RefreshingView
> ------------------------------------------------
>
> Key: WICKET-1227
> URL: https://issues.apache.org/jira/browse/WICKET-1227
> Project: Wicket
> Issue Type: Improvement
> Components: wicket
> Reporter: Peter Ertl
> Assignee: Igor Vaynberg
> Fix For: 1.3.0-rc3
>
> Attachments: AccessItemsOfRefreshingView.patch
>
>
> When trying to directly access items of a RefreshingView (or subclasses of it) everything gets really complicated.
> For Example:
> When inserting a new, blank post into a guestbook the input focus should be set to the input field 'author'.
> public void onClick(final AjaxRequestTarget target)
> {
> // add new, blank entry to the guestbook posts model
> posts.add(new Post());
> //
> // code that gets us the last item of the repeating view.
> // however, the view first has to be rendered in order to contain the new item
> // as it's only in the model but will not appear in the RefreshingView unless
> // RefreshingView#onBeforeRender() is called
> Item lastItem = ...???...
> target.addComponent(/* container that contains the refreshing view */);
> target.focusComponent(lastItem.get("author"));
> }
> Now what I did is attach a patch to provide methods for updating and getting the items of the RefreshingView.
> the above example would look like this:
> public void onClick(final AjaxRequestTarget target)
> {
> posts.add(new Post());
> guestbookView.refresh();
> Item[] items = guestbookView.items();
> Item lastItem = items[items.length() - 1];
> target.addComponent(/* container that contains the refreshing view */);
> target.focusComponent(lastItem.get("author")); // put focus on "author" component where user can enter his name
> }
> Basically it works like this:
> the refresh() method will invoke onBeforeRender() to populate the items of the view (based on the current model). That way you can access the items before the actual render occurs (using the iterator function MarkupContainer#getItems() ). Once the render occurs it would be just too late...
> In order to prevent unnecessary subsequent calls of onBeforeRender() a flag will remember if the view needs refreshing, so onBeforeRender() is only called once per render (unless you call refresh() for another time).
> items() is a convenience method that collects the current items using MarkupContainer#getItems() and returns a handy array of items and avoids cumbersome code.
> I also added firstItem() and lastItem() as I think these will be quite common use cases for accessing that array.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (WICKET-1227) Provide easier access to items of
RefreshingView
Posted by "Peter Ertl (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-1227?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12552066 ]
Peter Ertl commented on WICKET-1227:
------------------------------------
Using newItem() is pretty smart :-) in that focus case but I still think this is not solving the problem in general.
The 'setting focus' issue is just a very simple example. I want to provide a general purpose way of applying javascript related stuff to parts of the data view depending on any kind of complex logic, not just 'adding an item'. For that you will virtually always need the markupId of components located inside the RefreshingView's items.
Providing access to the items is not counteracting the philosophy of not managing the items yourself but let RefreshingView do it. I see it more as an extension. Giving you an array of Item[] will _not_ enable you to add, delete or change order of the items. It just gives you access to the properties of item and its children.
> Provide easier access to items of RefreshingView
> ------------------------------------------------
>
> Key: WICKET-1227
> URL: https://issues.apache.org/jira/browse/WICKET-1227
> Project: Wicket
> Issue Type: Improvement
> Components: wicket
> Reporter: Peter Ertl
> Assignee: Igor Vaynberg
> Fix For: 1.3.0-rc3
>
> Attachments: AccessItemsOfRefreshingView.patch
>
>
> When trying to directly access items of a RefreshingView (or subclasses of it) everything gets really complicated.
> For Example:
> When inserting a new, blank post into a guestbook the input focus should be set to the input field 'author'.
> public void onClick(final AjaxRequestTarget target)
> {
> // add new, blank entry to the guestbook posts model
> posts.add(new Post());
> //
> // code that gets us the last item of the repeating view.
> // however, the view first has to be rendered in order to contain the new item
> // as it's only in the model but will not appear in the RefreshingView unless
> // RefreshingView#onBeforeRender() is called
> Item lastItem = ...???...
> target.addComponent(/* container that contains the refreshing view */);
> target.focusComponent(lastItem.get("author"));
> }
> Now what I did is attach a patch to provide methods for updating and getting the items of the RefreshingView.
> the above example would look like this:
> public void onClick(final AjaxRequestTarget target)
> {
> posts.add(new Post());
> guestbookView.refresh();
> Item[] items = guestbookView.items();
> Item lastItem = items[items.length() - 1];
> target.addComponent(/* container that contains the refreshing view */);
> target.focusComponent(lastItem.get("author")); // put focus on "author" component where user can enter his name
> }
> Basically it works like this:
> the refresh() method will invoke onBeforeRender() to populate the items of the view (based on the current model). That way you can access the items before the actual render occurs (using the iterator function MarkupContainer#getItems() ). Once the render occurs it would be just too late...
> In order to prevent unnecessary subsequent calls of onBeforeRender() a flag will remember if the view needs refreshing, so onBeforeRender() is only called once per render (unless you call refresh() for another time).
> items() is a convenience method that collects the current items using MarkupContainer#getItems() and returns a handy array of items and avoids cumbersome code.
> I also added firstItem() and lastItem() as I think these will be quite common use cases for accessing that array.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (WICKET-1227) Provide easier access to items of
RefreshingView
Posted by "Frank Bille Jensen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-1227?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Frank Bille Jensen updated WICKET-1227:
---------------------------------------
Fix Version/s: (was: 1.3.0-rc3)
1.3.1
> Provide easier access to items of RefreshingView
> ------------------------------------------------
>
> Key: WICKET-1227
> URL: https://issues.apache.org/jira/browse/WICKET-1227
> Project: Wicket
> Issue Type: Improvement
> Components: wicket
> Reporter: Peter Ertl
> Assignee: Igor Vaynberg
> Fix For: 1.3.1
>
> Attachments: AccessItemsOfRefreshingView.patch
>
>
> When trying to directly access items of a RefreshingView (or subclasses of it) everything gets really complicated.
> For Example:
> When inserting a new, blank post into a guestbook the input focus should be set to the input field 'author'.
> public void onClick(final AjaxRequestTarget target)
> {
> // add new, blank entry to the guestbook posts model
> posts.add(new Post());
> //
> // code that gets us the last item of the repeating view.
> // however, the view first has to be rendered in order to contain the new item
> // as it's only in the model but will not appear in the RefreshingView unless
> // RefreshingView#onBeforeRender() is called
> Item lastItem = ...???...
> target.addComponent(/* container that contains the refreshing view */);
> target.focusComponent(lastItem.get("author"));
> }
> Now what I did is attach a patch to provide methods for updating and getting the items of the RefreshingView.
> the above example would look like this:
> public void onClick(final AjaxRequestTarget target)
> {
> posts.add(new Post());
> guestbookView.refresh();
> Item[] items = guestbookView.items();
> Item lastItem = items[items.length() - 1];
> target.addComponent(/* container that contains the refreshing view */);
> target.focusComponent(lastItem.get("author")); // put focus on "author" component where user can enter his name
> }
> Basically it works like this:
> the refresh() method will invoke onBeforeRender() to populate the items of the view (based on the current model). That way you can access the items before the actual render occurs (using the iterator function MarkupContainer#getItems() ). Once the render occurs it would be just too late...
> In order to prevent unnecessary subsequent calls of onBeforeRender() a flag will remember if the view needs refreshing, so onBeforeRender() is only called once per render (unless you call refresh() for another time).
> items() is a convenience method that collects the current items using MarkupContainer#getItems() and returns a handy array of items and avoids cumbersome code.
> I also added firstItem() and lastItem() as I think these will be quite common use cases for accessing that array.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (WICKET-1227) Provide easier access to items of
RefreshingView
Posted by "Peter Ertl (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-1227?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Peter Ertl updated WICKET-1227:
-------------------------------
Attachment: AccessItemsOfRefreshingView.patch
> Provide easier access to items of RefreshingView
> ------------------------------------------------
>
> Key: WICKET-1227
> URL: https://issues.apache.org/jira/browse/WICKET-1227
> Project: Wicket
> Issue Type: Improvement
> Components: wicket
> Reporter: Peter Ertl
> Attachments: AccessItemsOfRefreshingView.patch
>
>
> When trying to directly access items of a RefreshingView (or subclasses of it) everything gets really complicated.
> For Example:
> When inserting a new, blank post into a guestbook the input focus should be set to the input field 'author'.
> public void onClick(final AjaxRequestTarget target)
> {
> // add new, blank entry to the guestbook posts model
> posts.add(new Post());
> //
> // code that gets us the last item of the repeating view.
> // however, the view first has to be rendered in order to contain the new item
> // as it's only in the model but will not appear in the RefreshingView unless
> // RefreshingView#onBeforeRender() is called
> Item lastItem = ...???...
> target.addComponent(/* container that contains the refreshing view */);
> target.focusComponent(lastItem.get("author"));
> }
> Now what I did is attach a patch to provide methods for updating and getting the items of the RefreshingView.
> the above example would look like this:
> public void onClick(final AjaxRequestTarget target)
> {
> posts.add(new Post());
> guestbookView.refresh();
> Item[] items = guestbookView.items();
> Item lastItem = items[items.length() - 1];
> target.addComponent(/* container that contains the refreshing view */);
> target.focusComponent(lastItem.get("author")); // put focus on "author" component where user can enter his name
> }
> Basically it works like this:
> the refresh() method will invoke onBeforeRender() to populate the items of the view (based on the current model). That way you can access the items before the actual render occurs (using the iterator function MarkupContainer#getItems() ). Once the render occurs it would be just too late...
> In order to prevent unnecessary subsequent calls of onBeforeRender() a flag will remember if the view needs refreshing, so onBeforeRender() is only called once per render (unless you call refresh() for another time).
> items() is a convenience method that collects the current items using MarkupContainer#getItems() and returns a handy array of items and avoids cumbersome code.
> I also added firstItem() and lastItem() as I think these will be quite common use cases for accessing that array.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Closed: (WICKET-1227) Provide easier access to items of
RefreshingView
Posted by "Peter Ertl (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-1227?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Peter Ertl closed WICKET-1227.
------------------------------
> Provide easier access to items of RefreshingView
> ------------------------------------------------
>
> Key: WICKET-1227
> URL: https://issues.apache.org/jira/browse/WICKET-1227
> Project: Wicket
> Issue Type: Improvement
> Components: wicket
> Reporter: Peter Ertl
> Assignee: Igor Vaynberg
> Attachments: AccessItemsOfRefreshingView.patch
>
>
> When trying to directly access items of a RefreshingView (or subclasses of it) everything gets really complicated.
> For Example:
> When inserting a new, blank post into a guestbook the input focus should be set to the input field 'author'.
> public void onClick(final AjaxRequestTarget target)
> {
> // add new, blank entry to the guestbook posts model
> posts.add(new Post());
> //
> // code that gets us the last item of the repeating view.
> // however, the view first has to be rendered in order to contain the new item
> // as it's only in the model but will not appear in the RefreshingView unless
> // RefreshingView#onBeforeRender() is called
> Item lastItem = ...???...
> target.addComponent(/* container that contains the refreshing view */);
> target.focusComponent(lastItem.get("author"));
> }
> Now what I did is attach a patch to provide methods for updating and getting the items of the RefreshingView.
> the above example would look like this:
> public void onClick(final AjaxRequestTarget target)
> {
> posts.add(new Post());
> guestbookView.refresh();
> Item[] items = guestbookView.items();
> Item lastItem = items[items.length() - 1];
> target.addComponent(/* container that contains the refreshing view */);
> target.focusComponent(lastItem.get("author")); // put focus on "author" component where user can enter his name
> }
> Basically it works like this:
> the refresh() method will invoke onBeforeRender() to populate the items of the view (based on the current model). That way you can access the items before the actual render occurs (using the iterator function MarkupContainer#getItems() ). Once the render occurs it would be just too late...
> In order to prevent unnecessary subsequent calls of onBeforeRender() a flag will remember if the view needs refreshing, so onBeforeRender() is only called once per render (unless you call refresh() for another time).
> items() is a convenience method that collects the current items using MarkupContainer#getItems() and returns a handy array of items and avoids cumbersome code.
> I also added firstItem() and lastItem() as I think these will be quite common use cases for accessing that array.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Assigned: (WICKET-1227) Provide easier access to items of
RefreshingView
Posted by "Igor Vaynberg (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-1227?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Igor Vaynberg reassigned WICKET-1227:
-------------------------------------
Assignee: Igor Vaynberg
> Provide easier access to items of RefreshingView
> ------------------------------------------------
>
> Key: WICKET-1227
> URL: https://issues.apache.org/jira/browse/WICKET-1227
> Project: Wicket
> Issue Type: Improvement
> Components: wicket
> Reporter: Peter Ertl
> Assignee: Igor Vaynberg
> Attachments: AccessItemsOfRefreshingView.patch
>
>
> When trying to directly access items of a RefreshingView (or subclasses of it) everything gets really complicated.
> For Example:
> When inserting a new, blank post into a guestbook the input focus should be set to the input field 'author'.
> public void onClick(final AjaxRequestTarget target)
> {
> // add new, blank entry to the guestbook posts model
> posts.add(new Post());
> //
> // code that gets us the last item of the repeating view.
> // however, the view first has to be rendered in order to contain the new item
> // as it's only in the model but will not appear in the RefreshingView unless
> // RefreshingView#onBeforeRender() is called
> Item lastItem = ...???...
> target.addComponent(/* container that contains the refreshing view */);
> target.focusComponent(lastItem.get("author"));
> }
> Now what I did is attach a patch to provide methods for updating and getting the items of the RefreshingView.
> the above example would look like this:
> public void onClick(final AjaxRequestTarget target)
> {
> posts.add(new Post());
> guestbookView.refresh();
> Item[] items = guestbookView.items();
> Item lastItem = items[items.length() - 1];
> target.addComponent(/* container that contains the refreshing view */);
> target.focusComponent(lastItem.get("author")); // put focus on "author" component where user can enter his name
> }
> Basically it works like this:
> the refresh() method will invoke onBeforeRender() to populate the items of the view (based on the current model). That way you can access the items before the actual render occurs (using the iterator function MarkupContainer#getItems() ). Once the render occurs it would be just too late...
> In order to prevent unnecessary subsequent calls of onBeforeRender() a flag will remember if the view needs refreshing, so onBeforeRender() is only called once per render (unless you call refresh() for another time).
> items() is a convenience method that collects the current items using MarkupContainer#getItems() and returns a handy array of items and avoids cumbersome code.
> I also added firstItem() and lastItem() as I think these will be quite common use cases for accessing that array.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (WICKET-1227) Provide easier access to items of
RefreshingView
Posted by "Peter Ertl (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-1227?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12551894 ]
Peter Ertl commented on WICKET-1227:
------------------------------------
Also, using the RepeatingView doesn't sound like a viable solution as the behavior of RefreshingView (or subclasses) is still needed.
> Provide easier access to items of RefreshingView
> ------------------------------------------------
>
> Key: WICKET-1227
> URL: https://issues.apache.org/jira/browse/WICKET-1227
> Project: Wicket
> Issue Type: Improvement
> Components: wicket
> Reporter: Peter Ertl
> Assignee: Igor Vaynberg
> Fix For: 1.3.0-rc3
>
> Attachments: AccessItemsOfRefreshingView.patch
>
>
> When trying to directly access items of a RefreshingView (or subclasses of it) everything gets really complicated.
> For Example:
> When inserting a new, blank post into a guestbook the input focus should be set to the input field 'author'.
> public void onClick(final AjaxRequestTarget target)
> {
> // add new, blank entry to the guestbook posts model
> posts.add(new Post());
> //
> // code that gets us the last item of the repeating view.
> // however, the view first has to be rendered in order to contain the new item
> // as it's only in the model but will not appear in the RefreshingView unless
> // RefreshingView#onBeforeRender() is called
> Item lastItem = ...???...
> target.addComponent(/* container that contains the refreshing view */);
> target.focusComponent(lastItem.get("author"));
> }
> Now what I did is attach a patch to provide methods for updating and getting the items of the RefreshingView.
> the above example would look like this:
> public void onClick(final AjaxRequestTarget target)
> {
> posts.add(new Post());
> guestbookView.refresh();
> Item[] items = guestbookView.items();
> Item lastItem = items[items.length() - 1];
> target.addComponent(/* container that contains the refreshing view */);
> target.focusComponent(lastItem.get("author")); // put focus on "author" component where user can enter his name
> }
> Basically it works like this:
> the refresh() method will invoke onBeforeRender() to populate the items of the view (based on the current model). That way you can access the items before the actual render occurs (using the iterator function MarkupContainer#getItems() ). Once the render occurs it would be just too late...
> In order to prevent unnecessary subsequent calls of onBeforeRender() a flag will remember if the view needs refreshing, so onBeforeRender() is only called once per render (unless you call refresh() for another time).
> items() is a convenience method that collects the current items using MarkupContainer#getItems() and returns a handy array of items and avoids cumbersome code.
> I also added firstItem() and lastItem() as I think these will be quite common use cases for accessing that array.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (WICKET-1227) Provide easier access to items of
RefreshingView
Posted by "Igor Vaynberg (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-1227?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12552110 ]
Igor Vaynberg commented on WICKET-1227:
---------------------------------------
fine, you can do that, but it doesnt need to be part of refreshing view, it can be part of your own subclass
class myrefreshingview extends refreshingview {
private item[] items;
public void onbeforerender() {
super.onbeforerender();
items=new item[size()];
Iterator i=renderiterator(); int idx=0;
while (i.hasNext()) { items[idx++]=i.next(); }
}
public void detach() { items=null; super.detach(); }
public item[] getitems() { return items; }
}
works? yes you might have to create your own subclasses of refreshing view and dataview, but thats life. having this as part of core bloats the api, adds an extra storage slot to all refreshingview subclasses that will only be used seldomly.
> Provide easier access to items of RefreshingView
> ------------------------------------------------
>
> Key: WICKET-1227
> URL: https://issues.apache.org/jira/browse/WICKET-1227
> Project: Wicket
> Issue Type: Improvement
> Components: wicket
> Reporter: Peter Ertl
> Assignee: Igor Vaynberg
> Fix For: 1.3.0-rc3
>
> Attachments: AccessItemsOfRefreshingView.patch
>
>
> When trying to directly access items of a RefreshingView (or subclasses of it) everything gets really complicated.
> For Example:
> When inserting a new, blank post into a guestbook the input focus should be set to the input field 'author'.
> public void onClick(final AjaxRequestTarget target)
> {
> // add new, blank entry to the guestbook posts model
> posts.add(new Post());
> //
> // code that gets us the last item of the repeating view.
> // however, the view first has to be rendered in order to contain the new item
> // as it's only in the model but will not appear in the RefreshingView unless
> // RefreshingView#onBeforeRender() is called
> Item lastItem = ...???...
> target.addComponent(/* container that contains the refreshing view */);
> target.focusComponent(lastItem.get("author"));
> }
> Now what I did is attach a patch to provide methods for updating and getting the items of the RefreshingView.
> the above example would look like this:
> public void onClick(final AjaxRequestTarget target)
> {
> posts.add(new Post());
> guestbookView.refresh();
> Item[] items = guestbookView.items();
> Item lastItem = items[items.length() - 1];
> target.addComponent(/* container that contains the refreshing view */);
> target.focusComponent(lastItem.get("author")); // put focus on "author" component where user can enter his name
> }
> Basically it works like this:
> the refresh() method will invoke onBeforeRender() to populate the items of the view (based on the current model). That way you can access the items before the actual render occurs (using the iterator function MarkupContainer#getItems() ). Once the render occurs it would be just too late...
> In order to prevent unnecessary subsequent calls of onBeforeRender() a flag will remember if the view needs refreshing, so onBeforeRender() is only called once per render (unless you call refresh() for another time).
> items() is a convenience method that collects the current items using MarkupContainer#getItems() and returns a handy array of items and avoids cumbersome code.
> I also added firstItem() and lastItem() as I think these will be quite common use cases for accessing that array.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (WICKET-1227) Provide easier access to items of
RefreshingView
Posted by "Igor Vaynberg (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-1227?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12551895 ]
Igor Vaynberg commented on WICKET-1227:
---------------------------------------
so you are trying to focus on the newly added post. how about something like
new refreshingview() { Item newItem(...) { return new Item(..) { renderhead(response r) { if (getmodelobject().getauthorname()==null) { r.renderonloadjavascript("window.getelementbyid(...).focus();"); }}
> Provide easier access to items of RefreshingView
> ------------------------------------------------
>
> Key: WICKET-1227
> URL: https://issues.apache.org/jira/browse/WICKET-1227
> Project: Wicket
> Issue Type: Improvement
> Components: wicket
> Reporter: Peter Ertl
> Assignee: Igor Vaynberg
> Fix For: 1.3.0-rc3
>
> Attachments: AccessItemsOfRefreshingView.patch
>
>
> When trying to directly access items of a RefreshingView (or subclasses of it) everything gets really complicated.
> For Example:
> When inserting a new, blank post into a guestbook the input focus should be set to the input field 'author'.
> public void onClick(final AjaxRequestTarget target)
> {
> // add new, blank entry to the guestbook posts model
> posts.add(new Post());
> //
> // code that gets us the last item of the repeating view.
> // however, the view first has to be rendered in order to contain the new item
> // as it's only in the model but will not appear in the RefreshingView unless
> // RefreshingView#onBeforeRender() is called
> Item lastItem = ...???...
> target.addComponent(/* container that contains the refreshing view */);
> target.focusComponent(lastItem.get("author"));
> }
> Now what I did is attach a patch to provide methods for updating and getting the items of the RefreshingView.
> the above example would look like this:
> public void onClick(final AjaxRequestTarget target)
> {
> posts.add(new Post());
> guestbookView.refresh();
> Item[] items = guestbookView.items();
> Item lastItem = items[items.length() - 1];
> target.addComponent(/* container that contains the refreshing view */);
> target.focusComponent(lastItem.get("author")); // put focus on "author" component where user can enter his name
> }
> Basically it works like this:
> the refresh() method will invoke onBeforeRender() to populate the items of the view (based on the current model). That way you can access the items before the actual render occurs (using the iterator function MarkupContainer#getItems() ). Once the render occurs it would be just too late...
> In order to prevent unnecessary subsequent calls of onBeforeRender() a flag will remember if the view needs refreshing, so onBeforeRender() is only called once per render (unless you call refresh() for another time).
> items() is a convenience method that collects the current items using MarkupContainer#getItems() and returns a handy array of items and avoids cumbersome code.
> I also added firstItem() and lastItem() as I think these will be quite common use cases for accessing that array.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Resolved: (WICKET-1227) Provide easier access to items of
RefreshingView
Posted by "Igor Vaynberg (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-1227?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Igor Vaynberg resolved WICKET-1227.
-----------------------------------
Resolution: Won't Fix
> Provide easier access to items of RefreshingView
> ------------------------------------------------
>
> Key: WICKET-1227
> URL: https://issues.apache.org/jira/browse/WICKET-1227
> Project: Wicket
> Issue Type: Improvement
> Components: wicket
> Reporter: Peter Ertl
> Assignee: Igor Vaynberg
> Fix For: 1.3.1
>
> Attachments: AccessItemsOfRefreshingView.patch
>
>
> When trying to directly access items of a RefreshingView (or subclasses of it) everything gets really complicated.
> For Example:
> When inserting a new, blank post into a guestbook the input focus should be set to the input field 'author'.
> public void onClick(final AjaxRequestTarget target)
> {
> // add new, blank entry to the guestbook posts model
> posts.add(new Post());
> //
> // code that gets us the last item of the repeating view.
> // however, the view first has to be rendered in order to contain the new item
> // as it's only in the model but will not appear in the RefreshingView unless
> // RefreshingView#onBeforeRender() is called
> Item lastItem = ...???...
> target.addComponent(/* container that contains the refreshing view */);
> target.focusComponent(lastItem.get("author"));
> }
> Now what I did is attach a patch to provide methods for updating and getting the items of the RefreshingView.
> the above example would look like this:
> public void onClick(final AjaxRequestTarget target)
> {
> posts.add(new Post());
> guestbookView.refresh();
> Item[] items = guestbookView.items();
> Item lastItem = items[items.length() - 1];
> target.addComponent(/* container that contains the refreshing view */);
> target.focusComponent(lastItem.get("author")); // put focus on "author" component where user can enter his name
> }
> Basically it works like this:
> the refresh() method will invoke onBeforeRender() to populate the items of the view (based on the current model). That way you can access the items before the actual render occurs (using the iterator function MarkupContainer#getItems() ). Once the render occurs it would be just too late...
> In order to prevent unnecessary subsequent calls of onBeforeRender() a flag will remember if the view needs refreshing, so onBeforeRender() is only called once per render (unless you call refresh() for another time).
> items() is a convenience method that collects the current items using MarkupContainer#getItems() and returns a handy array of items and avoids cumbersome code.
> I also added firstItem() and lastItem() as I think these will be quite common use cases for accessing that array.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.