OK, I'll try to explain.
1. I have a page that has a list of links.
2. The list is taken from the database the sageDal.getPreference(..) method
that I showed.
3. This list can be configured by the user.
4. I made a Modal window that shows the user all available links (also taken
from the DB).
5. When he selects the links he wants, he presses OK.
6. Then I update the DB. The sageDal.setPreference(...) method.
As for passing Objects.
I pass the model to the LinksPanel.
LinksPanel ha a ListView that uses a different AbstarctReadOnlyModel.
So my problem is that when I set the DB with new values, I need to inform
the Model (in the original panel) somehow that the DB was changed.
Eyal
On Mon, Jun 23, 2008 at 3:26 PM, Martin Makundi <
[EMAIL PROTECTED]> wrote:
> I did not quite follow nor grasp what you are trying to do...
>
> my only question is, are you using the same object instance on two
> different pages? That does not work (serialization breaks the
> connection).
>
> **
> Martin
>
> 2008/6/23 egolan74 <[EMAIL PROTECTED]>:
> >
> > Thanks Martin,
> > That really helped. Though I did something else and now I have a new
> > problem.
> > It's an Ajax problem now.
> >
> > Here's what I did:
> > In the constructor:
> > idsModel = new LoadableDetachableModel() {
> > private static final long serialVersionUID = 1L;
> >
> > @Override
> > protected Object load() {
> > List<String> ids = new
> ArrayList<String>();
> > List<Property> properties =
> >
> sageDal.getPreference(userId, SETTINGS_GROUP,
> >
> HomePageSectionPanel.this.sectionId);
> > for (Property property : properties) {
> > ids.add(property.getValue());
> > }
> > return ids;
> > }
> >
> > };
> >
> > linksPanel = new LinksPanel("links", idsModel);
> >
> > I am adding the ListView in LinksPanel:
> > private void init(final List<LinkContainer> links) {
> > add(new LinksListView("listview", new
> AbstractReadOnlyModel() {
> > private static final long serialVersionUID = 1L;
> >
> > @Override
> > public Object getObject() {
> > return links;
> > }
> >
> > }));
> > }
> > (I have a method that changes the String ids to the LinkContainer).
> >
> > My problem is when setting new list.
> > Here is my code:
> > public void setLinksIds(List<String> linksIds) {
> > sageDal.setPreference(userId, SETTINGS_GROUP, sectionId,
> > linksIds.toArray(new String[0]));
> > }
> >
> > It works and I actually see the change in the database. When refreshing
> (or
> > checking in the DB) I see changes.
> >
> > BUT, it doesn't change automatically.
> > I use a ModalWindow and here's where I add my panel to the modal:
> > setWindowClosedCallback(new
> ModalWindow.WindowClosedCallback() {
> > private static final long serialVersionUID = 1L;
> >
> > public void onClose(AjaxRequestTarget target) {
> > target.addComponent(homePageSectionPanel);
> > }
> > });
> >
> > I'm sure I need to add something else somewhere.
> > But what? and where ?
> >
> > Thanks,
> >
> > Eyal
> >
> > Martin Makundi wrote:
> >>
> >> Hi!
> >>
> >> Here is a good example of a list model:
> >>
> >> public abstract class AbstractListChoiceModel<S> extends
> >> AbstractReadOnlyModel<List<? extends S>> {
> >> @Override
> >> public final List<S> getObject() {
> >> return getChoices();
> >> }
> >>
> >> public abstract List<S> getChoices();
> >> }
> >>
> >> Now change your code as follows:
> >>
> >> linksPanel = new LinksPanel("links", new
> AbstractListChoiceModel<String>()
> >> {
> >> @Override
> >> public List<String> getChoices() {
> >> // Where did you get your choices in the first place?
> >> }
> >> } );
> >>
> >>
> >
> >
> > -----
> > Eyal Golan
> > [EMAIL PROTECTED]
> >
> > Visit: http://jvdrums.sourceforge.net/ http://jvdrums.sourceforge.net/
> > LinkedIn: http://www.linkedin.com/in/egolan74
> > href=http://www.linkedin.com/in/egolan74
> > --
> > View this message in context:
> http://www.nabble.com/Confused-tp18064846p18066913.html
> > Sent from the Wicket - User mailing list archive at Nabble.com.
> >
> >
> > ---------------------------------------------------------------------
> > 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]
>
>
--
Eyal Golan
[EMAIL PROTECTED]
Visit: http://jvdrums.sourceforge.net/
LinkedIn: http://www.linkedin.com/in/egolan74