You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Shelli Orton <Sh...@sjrb.ca> on 2010/10/04 23:51:58 UTC

DropDownChoice/Model Confusion

I am writing a (simple?) database CRUD app where I have multiple tab
panels that encapsulate the different tables in the database.  On a
panel there's a dropdownchoice which lists the existing records for that
table.  There's also create, delete and edit buttons (and and edit panel
with save and cancel buttons).  When I create, edit or delete any of the
records, the dropdownchoice list doesn't reflect the changes until I
open a new session.  So my question is how to reload the list after one
of these actions is done?

Currently my dropdownchoice model is set like this:

    MyRecord selectedRecord;
    ...
    form.add(new DropDownChoice<MyRecord>("records",
        new PropertyModel<MyRecord>(this, "selectedRecord"),
        getMyRecords(), // method that retrieves from the database (via
JPA)
        new MyRecordRenderer()).setNullValid(false)); // used to return
the display attribute of MyRecord

I am trying to understand if using a LoadableDetachableModel will do the
reload that I want. Also, I don't know how to set the selectedRecord
using that type of model or if it's even possible.

Any advice?

Thanks!

Shelli

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


Re: PropertyModel Not Refreshing

Posted by jcgarciam <jc...@gmail.com>.
Take a look at this, it may helps.

https://cwiki.apache.org/WICKET/lifecycle-of-a-wicket-application.html#LifecycleofaWicketApplication-ModelChanges

On Thu, Oct 7, 2010 at 2:15 PM, Shelli Orton [via Apache Wicket] <
ml-node+2967225-1123928259-65838@n4.nabble.com<ml...@n4.nabble.com>
> wrote:

> Does nobody have any suggestions?  If I can't get this fixed, I'm going
> to have to write the app in another framework (possibly GWT) and I'd
> really rather not have to do that.
>
> Shelli
>
> -----Original Message-----
> From: Shelli Orton
> Sent: Wednesday, October 06, 2010 3:52 PM
> To: [hidden email] <http://user/SendEmail.jtp?type=node&node=2967225&i=0>
> Subject: PropertyModel Not Refreshing
>
> Hi,
>
> First, thanks to all who have been helping me as I am new to Wicket.  I
> am splitting out two issues I am dealing with to try to keep things
> clear.
>
> I am trying to write a simple app that does CRUD operations on database
> records.  The goal is for the app to make use of a tab panel where each
> tab encapsulates one table from the database.  Each tab panel has two
> groups (WebMarkupContainer).  The first, selectGroup, displays a list
> (DDC) of the current items, and three buttons, add, edit and delete.
> The second, editGroup, is displayed when either the add or edit button
> was clicked on the select group, displays the record attributes and save
> and cancel buttons.  The tab panel has a "selectedRecord" which is used
> by both groups' components via PropertyModels. Very basic stuff.
>
> When I choose a record and click the edit button, the record is
> displayed in the edit group properly.  If I then choose cancel, the edit
> group is no longer displayed and the select group DDC selection is null
> as expected. I then choose another record from the list and click the
> edit button and the previous record information is displayed in the edit
> group even though the select group DDC shows the correct/selected
> record.
>
> This problem also occurs if I first choose to add a new record and then
> cancel the add and then choose to edit a different record.  The DDC
> shows the correct/selected record, but all the attributes in the edit
> group are null/defaults for a new record.
>
> If I remove the call to setDefaultFormProcessing(false) on the cancel
> button, selecting other records for edit works correctly, but I can't
> cancel a creating a new record if I use a RequiredTextField because the
> form validation fails.
>
> If I select a record for editing or save the newly created record, I can
> select a different record for edit or create another one correctly.  So
> I must be doing something wrong in the cancel logic. My editForm
> (created in the EditGroup constructor) looks like this:
>
>             Form editForm = new Form("editForm");
>
>             editForm.add(new Label("nameLabel", "Name"));
>
>             editForm.add(new Label("attributeLabel", "Attribute"));
>
>             editForm.add(new RequiredTextField<String>("recordNameText",
>                     new PropertyModel<String>(MyRecordPanel.this,
>                             "selectedRecord.name")));
>
>             editForm.add(new DropDownChoice<Lir>("attributes",
>                     new PropertyModel<Attribute>(MyRecordPanel.this,
>                             "selectedRecord.attribute"),
>                     RateCentrePanel.this.getAttributes(),
>                     new AttributeRenderer()));
>
>             ....
>
>             editForm.add(new Button("cancel")
>             {
>                 private static final long serialVersionUID = 1L;
>
>                 public void onSubmit()
>                 {
>                     MyRecordPanel.this.selectedRecord = null;
>                     editGroup.setVisible(false);
>                     selectGroup.setVisible(true);
>                 }
>             }.setDefaultFormProcessing(false));
>
>             add(editForm);
>
> Other than setting the selectedRecord to null, what should I be doing
> differently?
>
> Thanks in advance!
>
> Shelli
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=2967225&i=1>
> For additional commands, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=2967225&i=2>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=2967225&i=3>
> For additional commands, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=2967225&i=4>
>
>
>
> ------------------------------
>  View message @
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusion-tp2955144p2967225.html
> To start a new topic under Apache Wicket, email
> ml-node+1842946-398011874-65838@n4.nabble.com<ml...@n4.nabble.com>
> To unsubscribe from Apache Wicket, click here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxODQyOTQ2fDEyNTYxMzc3ODY=>.
>
>
>


-- 
Sincerely,
JC (http://www.linkedin.com/in/jcgarciam)
Work smarter, not harder!.

-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusion-tp2955144p2967255.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: PropertyModel Not Refreshing

Posted by nino martinez wael <ni...@gmail.com>.
got point igor.. The first thing I did with the project was copying over the
start.java..Having break points etc just gives it a better sense..

Shelli heres the start.java:



import org.mortbay.jetty.Connector;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.bio.SocketConnector;
import org.mortbay.jetty.webapp.WebAppContext;

public class Start {

    public static void main(String[] args) throws Exception {
        Server server = new Server();
        SocketConnector connector = new SocketConnector();
        // Set some timeout options to make debugging easier.
        connector.setMaxIdleTime(1000 * 60 * 60);
        connector.setSoLingerTime(-1);
        connector.setPort(8081);
        server.setConnectors(new Connector[] { connector });

        WebAppContext bb = new WebAppContext();
        bb.setServer(server);
        bb.setContextPath("/");
        bb.setWar("src/main/webapp");


        // START JMX SERVER
        // MBeanServer mBeanServer =
ManagementFactory.getPlatformMBeanServer();
        // MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer);
        // server.getContainer().addEventListener(mBeanContainer);
        // mBeanContainer.start();

        server.addHandler(bb);

        try {
            System.out.println(">>> STARTING EMBEDDED JETTY SERVER, PRESS
ANY KEY TO STOP");
            server.start();
            while (System.in.available() == 0) {
                Thread.sleep(5000);
            }
            server.stop();
            server.join();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(100);
        }
    }
}


Good night
- Nino

2010/10/12 Igor Vaynberg <ig...@gmail.com>

> you should first try and understand how models work. there is this
> page to help you:
>
> https://cwiki.apache.org/WICKET/working-with-wicket-models.html
>
> but nothing will be better then setting some breakpoints and seeing
> how things actually work.
>
> -igor
>
> On Tue, Oct 12, 2010 at 2:24 PM, Shelli Orton <Sh...@sjrb.ca>
> wrote:
> > I only explicitly set the selectedRecordA in two places, during the
> > cancel and add onSubmit methods (I removed the initialization in the
> > declaration in my code).  As you alluded to earlier, add is done via
> >
> >    setSelectedRecordA(new RecordA());
> >
> > and cancel is done via:
> >
> >    RecordAPanel.this.selectedRecordA = null;
> >
> > I changed cancel to be:
> >
> >    setSelectedRecordA(new RecordA());
> >
> > but it doesn't seem to make a difference, still get the issue when
> > cancelling.
> >
> > Should I be setting the selectedRecordA to null on cancel?  It makes
> > sense to me and it's what I've done in other applications/frameworks,
> > but perhaps it's not correct in Wicket...
> >
> > Shelli
> >
> > -----Original Message-----
> > From: nino martinez wael [mailto:nino.martinez.wael@gmail.com]
> > Sent: Tuesday, October 12, 2010 3:00 PM
> > To: users@wicket.apache.org
> > Subject: Re: PropertyModel Not Refreshing
> >
> > Think I was going in the wrong direction.. Looking at the error, seems
> > to
> > get triggered by pressing the cancel button only..
> >
> > 2010/10/12 Shelli Orton <Sh...@sjrb.ca>
> >
> >> This is where my confusion about models may be kicking in.  I thought
> >> that property models (PropertModel or CompoundPropertyModel)
> >> automatically checked if the model object changed.  How do I tell the
> >> model it has?
> >>
> >> Shelli
> >>
> >> -----Original Message-----
> >> From: nino martinez wael [mailto:nino.martinez.wael@gmail.com]
> >> Sent: Tuesday, October 12, 2010 12:10 PM
> >> To: users@wicket.apache.org
> >> Subject: Re: PropertyModel Not Refreshing
> >>
> >> in your add button you call setSelectedRecordA(new RecordA()) but
> > never
> >> notify the model that a change has occured...
> >>
> >> 2010/10/12 nino martinez wael <ni...@gmail.com>
> >>
> >> > hmm getting a lot of errors on the services not implementing
> >> > serialization...
> >> >
> >> > But does seem theres a difference between calling :
> >> >
> >> > selectedRecordAModel.getObject().getName() and
> >> > RecordAPanel.this.selectedRecordA
> >> >
> >> > 2010/10/12 nino martinez wael <ni...@gmail.com>
> >> >
> >> > sorry.. Did'nt see it attached.. So did igor provide you with an
> > fixed
> >> >> quickstart (working on his system).. That did not work on
> > glassfish?
> >> >>
> >> >>
> >> >> 2010/10/12 Shelli Orton <Sh...@sjrb.ca>
> >> >>
> >> >>> The quickstart was sent to the list this morning at 10:04 MST.
> > Does
> >> it
> >> >>> need to be resent?
> >> >>>
> >> >>> Shelli
> >> >>>
> >> >>> -----Original Message-----
> >> >>> From: nino martinez wael [mailto:nino.martinez.wael@gmail.com]
> >> >>> Sent: Tuesday, October 12, 2010 11:52 AM
> >> >>> To: users@wicket.apache.org
> >> >>> Subject: Re: PropertyModel Not Refreshing
> >> >>>
> >> >>> No dont think so.. Please provide a quickstart.. I have had
> > property
> >> >>> models
> >> >>> working in 1.2, 1.3, 1.4 and 1.5 so must be error 42:)
> >> >>>
> >> >>> 2010/10/12 Shelli Orton <Sh...@sjrb.ca>
> >> >>>
> >> >>> > Hi,
> >> >>> >
> >> >>> > Thanks for file.  Your first email was missing these changes:
> >> >>> >
> >> >>> >    IModel<RecordA> selectedRecordAModel;  (I had set mine to
> >> >>> > PropertyModel<RecordA> selectedRecordAModel;)
> >> >>> >    recordAs.setModel(selectedRecordAModel)
> >> >>> >
> >> >>> > However, even with those changes applied, I still get the same
> >> issue
> >> >>> of the
> >> >>> > selected record not updating in the edit group.
> >> >>> >
> >> >>> > I am deploying in Glassfish v3.  Could that have anything to do
> >> with
> >> >>> my
> >> >>> > problems?
> >> >>> >
> >> >>> > Shelli
> >> >>> >
> >> >>> > -----Original Message-----
> >> >>> > From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
> >> >>> > Sent: Tuesday, October 12, 2010 11:35 AM
> >> >>> > To: users@wicket.apache.org
> >> >>> > Subject: Re: PropertyModel Not Refreshing
> >> >>> >
> >> >>> > On Tue, Oct 12, 2010 at 10:30 AM, Shelli Orton
> >> <Sh...@sjrb.ca>
> >> >>> > wrote:
> >> >>> > > Thanks for the help.  Your changes got rid of the errors and I
> >> can
> >> >>> delete
> >> >>> > records now (and the list is updated).
> >> >>> > >
> >> >>> > > However, once a record has been selected for edit and either
> >> saved
> >> >>> or
> >> >>> > cancelled, that same record is always displayed in the edit
> > group
> >> when
> >> >>> I
> >> >>> > choose another record to edit or even when I try to create a new
> >> one.
> >> >>> I can
> >> >>> > even delete the chosen record and it still displays in the edit
> >> group.
> >> >>> >
> >> >>> > works fine here, meaning you did not completely/propery apply my
> >> >>> > changes. below is the complete file.
> >> >>> >
> >> >>> > -igor
> >> >>> >
> >> >>> > public class RecordAPanel extends Panel
> >> >>> > {
> >> >>> >    private static final long serialVersionUID = 1L;
> >> >>> >
> >> >>> >    RecordAService recordAService;
> >> >>> >    RecordBService recordBService;
> >> >>> >
> >> >>> >    RecordA selectedRecordA = new RecordA();
> >> >>> >    IModel<RecordA> selectedRecordAModel;
> >> >>> >    String unmodifiedRecordA;
> >> >>> >
> >> >>> >    boolean isNew = false;
> >> >>> >
> >> >>> >    WebMarkupContainer selectGroup;
> >> >>> >    WebMarkupContainer editGroup;
> >> >>> >
> >> >>> >    Form selectForm;
> >> >>> >    Form editForm;
> >> >>> >
> >> >>> >    DropDownChoice<RecordA> recordAs;
> >> >>> >    DropDownChoice<RecordB> recordBs;
> >> >>> >
> >> >>> >    Button add;
> >> >>> >    Button edit;
> >> >>> >    Button save;
> >> >>> >    Button delete;
> >> >>> >    Button cancel;
> >> >>> >
> >> >>> >    Label editLegendLabel;
> >> >>> >    String editLegend;
> >> >>> >    Label recordALabel;
> >> >>> >    Label recordBLabel;
> >> >>> >
> >> >>> >    RequiredTextField recordAText;
> >> >>> >
> >> >>> >    @SuppressWarnings({ "rawtypes", "unchecked" })
> >> >>> >    public RecordAPanel(String id)
> >> >>> >    {
> >> >>> >        super(id);
> >> >>> >
> >> >>> >        recordAService = ((Application)
> >> >>> > RequestCycle.get().getApplication()).getRecordAService();
> >> >>> >        recordBService = ((Application)
> >> >>> > RequestCycle.get().getApplication()).getRecordBService();
> >> >>> >
> >> >>> >        selectedRecordAModel = new PropertyModel<RecordA>(this,
> >> >>> > "selectedRecordA");
> >> >>> >        this.setDefaultModel(selectedRecordAModel);
> >> >>> >
> >> >>> >        // ************* Select  Group *************
> >> >>> >
> >> >>> >        selectGroup = new WebMarkupContainer("selectGroup");
> >> >>> >        selectForm = new Form("selectForm");
> >> >>> >
> >> >>> >        recordAs = new DropDownChoice<RecordA>("recordAs");
> >> >>> >        recordAs.setModel(selectedRecordAModel);
> >> >>> >        recordAs.setChoices(recordAsModel);
> >> >>> >        recordAs.setChoiceRenderer(new RecordARenderer());
> >> >>> >
> >> >>> >        //            recordAs = (DropDownChoice<RecordA>) new
> >> >>> > DropDownChoice<RecordA>("recordAs",
> >> >>> >        //                    new PropertyModel<RecordA>(this,
> >> >>> > "selectedRecordA"),
> >> >>> >        //                    recordAsModel,
> >> >>> >        //                    new RecordARenderer());
> >> >>> >
> >> >>> >        recordAs.setNullValid(false);
> >> >>> >
> >> >>> >        selectForm.add(recordAs);
> >> >>> >
> >> >>> >        add = new Button("add")
> >> >>> >        {
> >> >>> >            private static final long serialVersionUID = 1L;
> >> >>> >
> >> >>> >            public void onSubmit()
> >> >>> >            {
> >> >>> >                setSelectedRecordA(new RecordA());
> >> >>> >                isNew = true;
> >> >>> >                editLegend = "New";
> >> >>> >                editGroup.setVisible(true);
> >> >>> >                selectGroup.setVisible(false);
> >> >>> >            }
> >> >>> >        };
> >> >>> >
> >> >>> >        selectForm.add(add);
> >> >>> >
> >> >>> >        edit = new Button("edit")
> >> >>> >        {
> >> >>> >            private static final long serialVersionUID = 1L;
> >> >>> >
> >> >>> >            public void onSubmit()
> >> >>> >            {
> >> >>> >                if (selectedRecordA == null)
> >> >>> >                {
> >> >>> >                    info("You must select a record to edit.");
> >> >>> >                }
> >> >>> >                else
> >> >>> >                {
> >> >>> >                    unmodifiedRecordA =
> > selectedRecordA.getName();
> >> >>> >                    isNew = false;
> >> >>> >                    editLegend = "Edit";
> >> >>> >                    editGroup.setVisible(true);
> >> >>> >                    selectGroup.setVisible(false);
> >> >>> >                }
> >> >>> >            }
> >> >>> >        };
> >> >>> >
> >> >>> >        selectForm.add(edit);
> >> >>> >
> >> >>> >        delete = new Button("delete")
> >> >>> >        {
> >> >>> >            private static final long serialVersionUID = 1L;
> >> >>> >
> >> >>> >            public void onSubmit()
> >> >>> >            {
> >> >>> >                if (selectedRecordA == null)
> >> >>> >                {
> >> >>> >                    info("You must select a record to delete.");
> >> >>> >                }
> >> >>> >                else
> >> >>> >                {
> >> >>> >                    // Delete the selected record
> >> >>> >                    unmodifiedRecordA =
> > selectedRecordA.getName();
> >> >>> >
> >> recordAService.delete(selectedRecordA.getName());
> >> >>> >                    selectedRecordA = null;
> >> >>> >                    info("Deleted '" + unmodifiedRecordA + "'");
> >> >>> >
> >> >>> >                    // Force refresh of records list
> >> >>> >                    RecordAPanel.this.recordAsModel.detach();
> >> >>> >                }
> >> >>> >            }
> >> >>> >        };
> >> >>> >
> >> >>> >        // Add confirmation dialog box
> >> >>> >        delete.add(new SimpleAttributeModifier("onclick",
> >> >>> >                "if (!confirm('Please confirm you want to delete
> >> this
> >> >>> > record') ){ return false; }"));
> >> >>> >
> >> >>> >        selectForm.add(delete);
> >> >>> >        selectGroup.add(selectForm);
> >> >>> >
> >> >>> >        this.add(selectGroup);
> >> >>> >
> >> >>> >        // ************* Edit Group *************
> >> >>> >
> >> >>> >        editGroup = new WebMarkupContainer("editGroup");
> >> >>> >
> >> >>> >        editLegendLabel = new Label("editLegend", new
> >> >>> PropertyModel(this,
> >> >>> >                "editLegend"));
> >> >>> >
> >> >>> >        editGroup.add(editLegendLabel);
> >> >>> >
> >> >>> >        editForm = new Form("editForm");
> >> >>> >
> >> >>> >        recordALabel = new Label("recordALabel", "Record A");
> >> >>> >        editForm.add(recordALabel);
> >> >>> >
> >> >>> >        recordBLabel = new Label("recordBLabel", "Record B");
> >> >>> >        editForm.add(recordBLabel);
> >> >>> >
> >> >>> >        recordAText = new RequiredTextField("recordAText",
> >> >>> >                new PropertyModel(selectedRecordAModel, "name"));
> >> >>> >
> >> >>> >        editForm.add(recordAText);
> >> >>> >
> >> >>> >        recordBs = new DropDownChoice<RecordB>("recordBs");
> >> >>> >        recordBs.setModel(new PropertyModel(selectedRecordAModel,
> >> >>> > "recordB"));
> >> >>> >        recordBs.setChoices(RecordAPanel.this.getRecordBs());
> >> >>> >        recordBs.setChoiceRenderer(new RecordBRenderer());
> >> >>> >
> >> >>> >        editForm.add(recordBs);
> >> >>> >
> >> >>> >        save = new Button("save")
> >> >>> >        {
> >> >>> >            private static final long serialVersionUID = 1L;
> >> >>> >
> >> >>> >            @Override
> >> >>> >            public void onSubmit()
> >> >>> >            {
> >> >>> >                if (isNew)
> >> >>> >                {
> >> >>> >
> >> >>> > recordAService.create(RecordAPanel.this.selectedRecordA);
> >> >>> >                        info("Created '"
> >> >>> >                                +
> >> >>> > RecordAPanel.this.selectedRecordA.getName()
> >> >>> >                                + "'");
> >> >>> >                }
> >> >>> >                else
> >> >>> >                {
> >> >>> >                        recordAService.update(unmodifiedRecordA,
> >> >>> >
> > RecordAPanel.this.selectedRecordA);
> >> >>> >                        info("Updated '"
> >> >>> >                                +
> >> >>> > RecordAPanel.this.selectedRecordA.getName()
> >> >>> >                                + "'");
> >> >>> >                }
> >> >>> >
> >> >>> >                // TODO Update the dropdown list?
> >> >>> >
> >> >>> >                editGroup.setVisible(false);
> >> >>> >                selectGroup.setVisible(true);
> >> >>> >            }
> >> >>> >        };
> >> >>> >
> >> >>> >        editForm.add(save);
> >> >>> >
> >> >>> >        cancel = new Button("cancel")
> >> >>> >        {
> >> >>> >            private static final long serialVersionUID = 1L;
> >> >>> >
> >> >>> >            public void onSubmit()
> >> >>> >            {
> >> >>> >                RecordAPanel.this.selectedRecordA = null;
> >> >>> >                editGroup.setVisible(false);
> >> >>> >                selectGroup.setVisible(true);
> >> >>> >            }
> >> >>> >        };
> >> >>> >
> >> >>> >        cancel.setDefaultFormProcessing(false);
> >> >>> >        editForm.add(cancel);
> >> >>> >
> >> >>> >        editGroup.add(editForm);
> >> >>> >
> >> >>> >        editGroup.setVisible(false);
> >> >>> >        this.add(editGroup);
> >> >>> >    }
> >> >>> >
> >> >>> >    public RecordA getSelectedRecordA()
> >> >>> >    {
> >> >>> >        return selectedRecordA;
> >> >>> >    }
> >> >>> >
> >> >>> >    public void setSelectedRecordA(RecordA selectedRecordA)
> >> >>> >    {
> >> >>> >        this.selectedRecordA = selectedRecordA;
> >> >>> >    }
> >> >>> >
> >> >>> >    public LoadableDetachableModel<List<RecordA>> recordAsModel =
> >> new
> >> >>> > LoadableDetachableModel<List<RecordA>>()
> >> >>> >    {
> >> >>> >        private static final long serialVersionUID = 1L;
> >> >>> >
> >> >>> >        @Override
> >> >>> >        protected List<RecordA> load()
> >> >>> >        {
> >> >>> >            return recordAService.getList();
> >> >>> >        }
> >> >>> >
> >> >>> >        public void detach()
> >> >>> >        {
> >> >>> >            super.detach();
> >> >>> >        }
> >> >>> >    };
> >> >>> >
> >> >>> >    // TODO change this to LDM?
> >> >>> >    List<RecordB> getRecordBs()
> >> >>> >    {
> >> >>> >        return recordBService.getList();
> >> >>> >    }
> >> >>> >
> >> >>> >    class RecordARenderer implements IChoiceRenderer<RecordA>
> >> >>> >    {
> >> >>> >        private static final long serialVersionUID = 1L;
> >> >>> >
> >> >>> >        public Object getDisplayValue(RecordA recordA)
> >> >>> >        {
> >> >>> >            return recordA.getName();
> >> >>> >        }
> >> >>> >
> >> >>> >        public String getIdValue(RecordA recordA, int index)
> >> >>> >        {
> >> >>> >            return recordA.getName();
> >> >>> >        }
> >> >>> >    }
> >> >>> >
> >> >>> >    class RecordBRenderer implements IChoiceRenderer<RecordB>
> >> >>> >    {
> >> >>> >        private static final long serialVersionUID = 1L;
> >> >>> >
> >> >>> >        public Object getDisplayValue(RecordB recordB)
> >> >>> >        {
> >> >>> >            return recordB.getName();
> >> >>> >        }
> >> >>> >
> >> >>> >        public String getIdValue(RecordB recordB, int index)
> >> >>> >        {
> >> >>> >            return recordB.getName();
> >> >>> >        }
> >> >>> >    }
> >> >>> > }
> >> >>> >
> >> >>> > >
> >> >>> > > Shelli
> >> >>> > >
> >> >>> > > -----Original Message-----
> >> >>> > > From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
> >> >>> > > Sent: Tuesday, October 12, 2010 10:38 AM
> >> >>> > > To: users@wicket.apache.org
> >> >>> > > Subject: Re: PropertyModel Not Refreshing
> >> >>> > >
> >> >>> > > here are the tweaks you need to make this work:
> >> >>> > >
> >> >>> > > selectedRecordAModel = new PropertyModel<RecordA>(this,
> >> >>> > "selectedRecordA");
> >> >>> > >
> >> >>> > > recordAText = new RequiredTextField("recordAText",
> >> >>> > >                new PropertyModel(selectedRecordAModel,
> > "name"));
> >> >>> > >
> >> >>> > >  recordBs.setModel(new PropertyModel(selectedRecordAModel,
> >> >>> "recordB"));
> >> >>> > >
> >> >>> > > have fun
> >> >>> > >
> >> >>> > > -igor
> >> >>> > >
> >> >>> > > On Tue, Oct 12, 2010 at 9:03 AM, Shelli Orton
> >> <Sh...@sjrb.ca>
> >> >>> > wrote:
> >> >>> > >> I've been able to create a sample application that exhibits
> > the
> >> >>> > >> same/similar problems to mine.  The sample makes use of an
> >> >>> in-memory
> >> >>> > >> list for the data versus accessing a database and so there's
> >> some
> >> >>> > >> differences.  However, I believe the problems that this
> > sample
> >> >>> exhibits
> >> >>> > >> have the same root cause as my project (which I believe have
> >> >>> something
> >> >>> > >> to do with how my models are set up...).
> >> >>> > >>
> >> >>> > >> Issues this sample exhibits:
> >> >>> > >>
> >> >>> > >> 1. Choose to edit an existing record, then cancel the edit.
> >> Choose
> >> >>> > >> another/the same record to edit and the selected record is
> > null
> >> >>> (error
> >> >>> > >> message "You must select a record to edit" is displayed).
> > Must
> >> >>> > >> close/open session to reset.
> >> >>> > >>
> >> >>> > >> 2. Choose to edit an existing record and save the edit.
> > Choose
> >> >>> > >> another/the same record to edit and you get a NPE:
> >> >>> > >>
> >> >>> > >>    WicketMessage: Method onFormSubmitted of interface
> >> >>> > >> org.apache.wicket.markup.html.form.IFormSubmitListener
> > targeted
> >> at
> >> >>> > >> component [MarkupContainer [Component id = selectForm]] threw
> >> an
> >> >>> > >> exception
> >> >>> > >>
> >> >>> > >>    Root cause:
> >> >>> > >>
> >> >>> > >>    java.lang.NullPointerException
> >> >>> > >>    at
> >> >>> > >>
> >> >>>
> >>
> > org.apache.wicket.markup.html.form.AbstractSingleSelectChoice.convertCho
> >> >>> > >> iceIdToChoice(AbstractSingleSelectChoice.java:247)
> >> >>> > >>
> >> >>> > >> 3. Create a new record and try to save it and get
> >> >>> > >> WicketRuntimeException:
> >> >>> > >>
> >> >>> > >>    WicketMessage: Attempted to set property value on a null
> >> object.
> >> >>> > >> Property expression: name Value: New One
> >> >>> > >>
> >> >>> > >>    Root cause:
> >> >>> > >>
> >> >>> > >>    org.apache.wicket.WicketRuntimeException: Attempted to set
> >> >>> property
> >> >>> > >> value on a null object. Property expression: name Value: New
> >> One
> >> >>> > >>    at
> >> >>> > >>
> >> >>>
> >>
> > org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.j
> >> >>> > >> ava:125)
> >> >>> > >>
> >> >>> > >> 4. Create a new record and then cancel the add, Choose an
> >> existing
> >> >>> > >> record to edit and the selected record is null (error message
> >> "You
> >> >>> must
> >> >>> > >> select a record to edit" is displayed).  Must close/open
> >> session to
> >> >>> > >> reset.
> >> >>> > >>
> >> >>> > >> As always, all help is greatly appreciated as I am stumped.
> >> >>> > >>
> >> >>> > >> Thanks,
> >> >>> > >> Shelli
> >> >>> > >>
> >> >>> > >> -----Original Message-----
> >> >>> > >> From: jcgarciam [mailto:jcgarciam@gmail.com]
> >> >>> > >> Sent: Friday, October 08, 2010 1:41 PM
> >> >>> > >> To: users@wicket.apache.org
> >> >>> > >> Subject: Re: PropertyModel Not Refreshing
> >> >>> > >>
> >> >>> > >>
> >> >>> > >> The attachment didn't make it,
> >> >>> > >>
> >> >>> > >> Can you try to extract out the relevant part and creates a
> >> >>> quickstart
> >> >>> > >> project that actually reproduces your issue?
> >> >>> > >>
> >> >>> > >>
> >> >>> > >> On Fri, Oct 8, 2010 at 1:41 PM, Shelli Orton [via Apache
> >> Wicket] <
> >> >>> > >>
> >> >>>
> >>
> > ml-node+2968688-305091622-65838@n4.nabble.com<ml...@n4.nabble.com>
> <ml-node%2B2968688-30509162
> > 2-65838@n4.nabble.com>
> >> <ml-node%2B2968688-30509162
> >> 2-65838@n4.nabble.com>
> >> >>> <ml-node%2B2968688-30509162
> >> >>> 2-65838@n4.nabble.com>
> >> >>> > <ml-node%2B2968688-30509162
> >> >>> > >> 2-65838@n4.nabble.com>
> >> >>> > >>> wrote:
> >> >>> > >>
> >> >>> > >>> Hi,
> >> >>> > >>>
> >> >>> > >>> I have been trying different things to see if I could get my
> >> code
> >> >>> to
> >> >>> > >> work
> >> >>> > >>> (and understand Wicket models better), but am still stuck.
> > I
> >> have
> >> >>> a
> >> >>> > >>> attached the (latest) panel class code which I hope is
> >> sufficient
> >> >>> to
> >> >>> > >> help.
> >> >>> > >>>
> >> >>> > >>> I was reading about different models (both online and the
> >> Wicket
> >> >>> in
> >> >>> > >> Action
> >> >>> > >>> book) and thought that perhaps using a CompoundPropertyModel
> >> was
> >> >>> more
> >> >>> > >>> appropriate and may help with my issues.  Originally, I only
> >> >>> declared
> >> >>> > >>> selectedRecordA (line 40) but didn't instantiate it.  The
> >> select
> >> >>> group
> >> >>> > >>> displayed properly but when I chose a record from the list
> > and
> >> >>> tried
> >> >>> > >> to edit
> >> >>> > >>> it, this exception was thrown:
> >> >>> > >>>
> >> >>> > >>>     WicketMessage: Attempted to set property value on a null
> >> >>> object.
> >> >>> > >>> Property expression: recordA Value: Name=A-One
> >> >>> > >>>     Root cause:
> >> >>> > >>>
> >> >>> > >>>     org.apache.wicket.WicketRuntimeException: Attempted to
> > set
> >> >>> > >> property
> >> >>> > >>> value on a null object. Property expression: recordA Value:
> >> >>> Name=A-One
> >> >>> > >>>         at
> >> >>> > >>>
> >> >>> > >>
> >> >>>
> >>
> > org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.j
> >> >>> > >> ava:125)
> >> >>> > >>>
> >> >>> > >>>         at
> >> >>> > >>>
> >> >>> > >>
> >> >>>
> >>
> > org.apache.wicket.model.AbstractPropertyModel.setObject(AbstractProperty
> >> >>> > >> Model.java:169)
> >> >>> > >>>
> >> >>> > >>>         at
> >> >>> > >>>
> >> >>>
> >> org.apache.wicket.Component.setDefaultModelObject(Component.java:3125)
> >> >>> > >>>         ....
> >> >>> > >>>
> >> >>> > >>> I set breakpoints on the getSelectedRecordA and
> >> setSelectedRecordA
> >> >>> > >> methods,
> >> >>> > >>> but these aren't called when during the request cycle when
> > the
> >> >>> edit
> >> >>> > >> button
> >> >>> > >>> is clicked.
> >> >>> > >>>
> >> >>> > >>> I then changed the class so that selectedRecordA is
> >> initialized to
> >> >>> an
> >> >>> > >> empty
> >> >>> > >>> instance of RecordA. This got rid of the above error.
> >> However, I
> >> >>> > >> cannot
> >> >>> > >>> save the edit changes because the selectedRecordA is still
> > the
> >> >>> empty
> >> >>> > >>> instance that was created in the initialization and the
> >> >>> persistence
> >> >>> > >> layer
> >> >>> > >>> throws an exception.  This same problem exists if I try to
> > add
> >> a
> >> >>> new
> >> >>> > >> RecordA
> >> >>> > >>> or try to delete an existing one.
> >> >>> > >>>
> >> >>> > >>> If I choose to cancel the edit and then select another
> > record
> >> to
> >> >>> edit,
> >> >>> > >> I
> >> >>> > >>> get the message "You must select a record to edit" (line
> > 131).
> >> >>> This
> >> >>> > >> is
> >> >>> > >>> because the cancel onSubmit sets selectedRecordA to null and
> >> >>> choosing
> >> >>> > >> the
> >> >>> > >>> record from the DDC is not setting it to the chosen record.
> >> >>> > >>>
> >> >>> > >>> Clearly I am not setting up this CompoundPropertyModel
> >> properly so
> >> >>> > >> that the
> >> >>> > >>> selectedARecord is set by the model.  Can someone tell me
> > what
> >> I'm
> >> >>> > >> doing
> >> >>> > >>> wrong?
> >> >>> > >>>
> >> >>> > >>> All help is greatly appreciated,
> >> >>> > >>>
> >> >>> > >>> Shelli
> >> >>> > >>>
> >> >>> > >>>
> >> >>> > >>> -----Original Message-----
> >> >>> > >>> From: Igor Vaynberg [mailto:[hidden
> >> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=0>]
> >> >>> > >>>
> >> >>> > >>> Sent: Thursday, October 07, 2010 11:27 AM
> >> >>> > >>> To: [hidden email]
> >> >>> > >> <http://user/SendEmail.jtp?type=node&node=2968688&i=1>
> >> >>> > >>> Subject: Re: PropertyModel Not Refreshing
> >> >>> > >>>
> >> >>> > >>> you have posted an incomplete piece of code and somehow from
> >> that
> >> >>> we
> >> >>> > >>> are supposed to guess what is not working? create a
> > quickstart
> >> and
> >> >>> > >>> provide that.
> >> >>> > >>>
> >> >>> > >>> -igor
> >> >>> > >>>
> >> >>> > >>> On Thu, Oct 7, 2010 at 10:15 AM, Shelli Orton <[hidden
> >> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=2>>
> >> >>> > >>> wrote:
> >> >>> > >>>
> >> >>> > >>> > Does nobody have any suggestions?  If I can't get this
> >> fixed,
> >> >>> I'm
> >> >>> > >> going
> >> >>> > >>> > to have to write the app in another framework (possibly
> > GWT)
> >> and
> >> >>> I'd
> >> >>> > >>> > really rather not have to do that.
> >> >>> > >>> >
> >> >>> > >>> > Shelli
> >> >>> > >>> >
> >> >>> > >>> > -----Original Message-----
> >> >>> > >>> > From: Shelli Orton
> >> >>> > >>> > Sent: Wednesday, October 06, 2010 3:52 PM
> >> >>> > >>> > To: [hidden
> >> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=3>
> >> >>> > >>> > Subject: PropertyModel Not Refreshing
> >> >>> > >>> >
> >> >>> > >>> > Hi,
> >> >>> > >>> >
> >> >>> > >>> > First, thanks to all who have been helping me as I am new
> > to
> >> >>> Wicket.
> >> >>> > >> I
> >> >>> > >>> > am splitting out two issues I am dealing with to try to
> > keep
> >> >>> things
> >> >>> > >>> > clear.
> >> >>> > >>> >
> >> >>> > >>> > I am trying to write a simple app that does CRUD
> > operations
> >> on
> >> >>> > >> database
> >> >>> > >>> > records.  The goal is for the app to make use of a tab
> > panel
> >> >>> where
> >> >>> > >> each
> >> >>> > >>> > tab encapsulates one table from the database.  Each tab
> >> panel
> >> >>> has
> >> >>> > >> two
> >> >>> > >>> > groups (WebMarkupContainer).  The first, selectGroup,
> >> displays a
> >> >>> > >> list
> >> >>> > >>> > (DDC) of the current items, and three buttons, add, edit
> > and
> >> >>> delete.
> >> >>> > >>> > The second, editGroup, is displayed when either the add or
> >> edit
> >> >>> > >> button
> >> >>> > >>> > was clicked on the select group, displays the record
> >> attributes
> >> >>> and
> >> >>> > >> save
> >> >>> > >>> > and cancel buttons.  The tab panel has a "selectedRecord"
> >> which
> >> >>> is
> >> >>> > >> used
> >> >>> > >>> > by both groups' components via PropertyModels. Very basic
> >> stuff.
> >> >>> > >>> >
> >> >>> > >>> > When I choose a record and click the edit button, the
> > record
> >> is
> >> >>> > >>> > displayed in the edit group properly.  If I then choose
> >> cancel,
> >> >>> the
> >> >>> > >> edit
> >> >>> > >>> > group is no longer displayed and the select group DDC
> >> selection
> >> >>> is
> >> >>> > >> null
> >> >>> > >>> > as expected. I then choose another record from the list
> > and
> >> >>> click
> >> >>> > >> the
> >> >>> > >>> > edit button and the previous record information is
> > displayed
> >> in
> >> >>> the
> >> >>> > >> edit
> >> >>> > >>> > group even though the select group DDC shows the
> >> >>> correct/selected
> >> >>> > >>> > record.
> >> >>> > >>> >
> >> >>> > >>> > This problem also occurs if I first choose to add a new
> >> record
> >> >>> and
> >> >>> > >> then
> >> >>> > >>> > cancel the add and then choose to edit a different record.
> >> The
> >> >>> DDC
> >> >>> > >>> > shows the correct/selected record, but all the attributes
> > in
> >> the
> >> >>> > >> edit
> >> >>> > >>> > group are null/defaults for a new record.
> >> >>> > >>> >
> >> >>> > >>> > If I remove the call to setDefaultFormProcessing(false) on
> >> the
> >> >>> > >> cancel
> >> >>> > >>> > button, selecting other records for edit works correctly,
> >> but I
> >> >>> > >> can't
> >> >>> > >>> > cancel a creating a new record if I use a
> > RequiredTextField
> >> >>> because
> >> >>> > >> the
> >> >>> > >>> > form validation fails.
> >> >>> > >>> >
> >> >>> > >>> > If I select a record for editing or save the newly created
> >> >>> record, I
> >> >>> > >> can
> >> >>> > >>> > select a different record for edit or create another one
> >> >>> correctly.
> >> >>> > >> So
> >> >>> > >>> > I must be doing something wrong in the cancel logic. My
> >> editForm
> >> >>> > >>> > (created in the EditGroup constructor) looks like this:
> >> >>> > >>> >
> >> >>> > >>> >            Form editForm = new Form("editForm");
> >> >>> > >>> >
> >> >>> > >>> >            editForm.add(new Label("nameLabel", "Name"));
> >> >>> > >>> >
> >> >>> > >>> >            editForm.add(new Label("attributeLabel",
> >> >>> "Attribute"));
> >> >>> > >>> >
> >> >>> > >>> >            editForm.add(new
> >> >>> > >> RequiredTextField<String>("recordNameText",
> >> >>> > >>> >                    new
> >> PropertyModel<String>(MyRecordPanel.this,
> >> >>> > >>> >                            "selectedRecord.name")));
> >> >>> > >>> >
> >> >>> > >>> >            editForm.add(new
> >> DropDownChoice<Lir>("attributes",
> >> >>> > >>> >                    new
> >> >>> PropertyModel<Attribute>(MyRecordPanel.this,
> >> >>> > >>> >                            "selectedRecord.attribute"),
> >> >>> > >>> >                    RateCentrePanel.this.getAttributes(),
> >> >>> > >>> >                    new AttributeRenderer()));
> >> >>> > >>> >
> >> >>> > >>> >            ....
> >> >>> > >>> >
> >> >>> > >>> >            editForm.add(new Button("cancel")
> >> >>> > >>> >            {
> >> >>> > >>> >                private static final long serialVersionUID
> > =
> >> 1L;
> >> >>> > >>> >
> >> >>> > >>> >                public void onSubmit()
> >> >>> > >>> >                {
> >> >>> > >>> >                    MyRecordPanel.this.selectedRecord =
> > null;
> >> >>> > >>> >                    editGroup.setVisible(false);
> >> >>> > >>> >                    selectGroup.setVisible(true);
> >> >>> > >>> >                }
> >> >>> > >>> >            }.setDefaultFormProcessing(false));
> >> >>> > >>> >
> >> >>> > >>> >            add(editForm);
> >> >>> > >>> >
> >> >>> > >>> > Other than setting the selectedRecord to null, what should
> > I
> >> be
> >> >>> > >> doing
> >> >>> > >>> > differently?
> >> >>> > >>> >
> >> >>> > >>> > Thanks in advance!
> >> >>> > >>> >
> >> >>> > >>> > Shelli
> >> >>> > >>> >
> >> >>> > >>> >
> >> >>> > >>
> >> >>>
> >> ---------------------------------------------------------------------
> >> >>> > >>> > To unsubscribe, e-mail: [hidden
> >> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=4>
> >> >>> > >>> > For additional commands, e-mail: [hidden
> >> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=5>
> >> >>> > >>> >
> >> >>> > >>> >
> >> >>> > >>> >
> >> >>> > >>
> >> >>>
> >> ---------------------------------------------------------------------
> >> >>> > >>> > To unsubscribe, e-mail: [hidden
> >> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=6>
> >> >>> > >>> > For additional commands, e-mail: [hidden
> >> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=7>
> >> >>> > >>> >
> >> >>> > >>> >
> >> >>> > >>>
> >> >>>
> >> ---------------------------------------------------------------------
> >> >>> > >>> To unsubscribe, e-mail: [hidden
> >> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=8>
> >> >>> > >>> For additional commands, e-mail: [hidden
> >> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=9>
> >> >>> > >>>
> >> >>> > >>>
> >> >>> > >>>
> >> >>> > >>>
> >> >>> > >>>
> >> >>>
> >> ---------------------------------------------------------------------
> >> >>> > >>> To unsubscribe, e-mail: [hidden
> >> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=10>
> >> >>> > >>> For additional commands, e-mail: [hidden
> >> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=11>
> >> >>> > >>>
> >> >>> > >>> ------------------------------
> >> >>> > >>>  View message @
> >> >>> > >>>
> >> >>> > >>
> >> >>> >
> >> >>>
> >>
> > http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
> >> >>> > >> n-tp2955144p2968688.html
> >> >>> > >>> To start a new topic under Apache Wicket, email
> >> >>> > >>>
> >> >>> > >>
> >> >>>
> >>
> > ml-node+1842946-398011874-65838@n4.nabble.com<ml...@n4.nabble.com>
> <ml-node%2B1842946-39801187
> > 4-65838@n4.nabble.com>
> >> <ml-node%2B1842946-39801187
> >> 4-65838@n4.nabble.com>
> >> >>> <ml-node%2B1842946-39801187
> >> >>> 4-65838@n4.nabble.com>
> >> >>> > <ml-node%2B1842946-39801187
> >> >>> > >> 4-65838@n4.nabble.com>
> >> >>> > >>> To unsubscribe from Apache Wicket, click
> >> >>> > >>
> >> >>>
> >>
> > here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp
> >> >>> > ?
> >> >>> > >>
> >> >>>
> >>
> > tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
> >> >>> > >> QyOTQ2fDEyNTYxMzc3ODY=>.
> >> >>> > >>>
> >> >>> > >>>
> >> >>> > >>>
> >> >>> > >>
> >> >>> > >>
> >> >>> > >> --
> >> >>> > >> Sincerely,
> >> >>> > >> JC (http://www.linkedin.com/in/jcgarciam)
> >> >>> > >> Work smarter, not harder!.
> >> >>> > >>
> >> >>> > >> --
> >> >>> > >> View this message in context:
> >> >>> > >>
> >> >>> >
> >> >>>
> >>
> > http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
> >> >>> > >> n-tp2955144p2968936.html
> >> >>> > >> Sent from the Users forum mailing list archive at Nabble.com.
> >> >>> > >>
> >> >>> > >>
> >> >>>
> >> ---------------------------------------------------------------------
> >> >>> > >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> >>> > >> For additional commands, e-mail: users-help@wicket.apache.org
> >> >>> > >>
> >> >>> > >>
> >> >>> > >>
> >> >>> > >>
> >> >>>
> >> ---------------------------------------------------------------------
> >> >>> > >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> >>> > >> For additional commands, e-mail: users-help@wicket.apache.org
> >> >>> > >>
> >> >>> > >
> >> >>> > >
> >> >>>
> >> ---------------------------------------------------------------------
> >> >>> > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> >>> > > For additional commands, e-mail: users-help@wicket.apache.org
> >> >>> > >
> >> >>> > >
> >> >>> > >
> >> >>>
> >> ---------------------------------------------------------------------
> >> >>> > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> >>> > > For additional commands, e-mail: users-help@wicket.apache.org
> >> >>> > >
> >> >>> > >
> >> >>> >
> >> >>> >
> >> ---------------------------------------------------------------------
> >> >>> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> >>> > For additional commands, e-mail: users-help@wicket.apache.org
> >> >>> >
> >> >>> >
> >> >>> >
> >> ---------------------------------------------------------------------
> >> >>> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> >>> > For additional commands, e-mail: users-help@wicket.apache.org
> >> >>> >
> >> >>> >
> >> >>>
> >> >>>
> >> ---------------------------------------------------------------------
> >> >>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> >>> For additional commands, e-mail: users-help@wicket.apache.org
> >> >>>
> >> >>>
> >> >>
> >> >
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: PropertyModel Not Refreshing

Posted by Igor Vaynberg <ig...@gmail.com>.
you should first try and understand how models work. there is this
page to help you:

https://cwiki.apache.org/WICKET/working-with-wicket-models.html

but nothing will be better then setting some breakpoints and seeing
how things actually work.

-igor

On Tue, Oct 12, 2010 at 2:24 PM, Shelli Orton <Sh...@sjrb.ca> wrote:
> I only explicitly set the selectedRecordA in two places, during the
> cancel and add onSubmit methods (I removed the initialization in the
> declaration in my code).  As you alluded to earlier, add is done via
>
>    setSelectedRecordA(new RecordA());
>
> and cancel is done via:
>
>    RecordAPanel.this.selectedRecordA = null;
>
> I changed cancel to be:
>
>    setSelectedRecordA(new RecordA());
>
> but it doesn't seem to make a difference, still get the issue when
> cancelling.
>
> Should I be setting the selectedRecordA to null on cancel?  It makes
> sense to me and it's what I've done in other applications/frameworks,
> but perhaps it's not correct in Wicket...
>
> Shelli
>
> -----Original Message-----
> From: nino martinez wael [mailto:nino.martinez.wael@gmail.com]
> Sent: Tuesday, October 12, 2010 3:00 PM
> To: users@wicket.apache.org
> Subject: Re: PropertyModel Not Refreshing
>
> Think I was going in the wrong direction.. Looking at the error, seems
> to
> get triggered by pressing the cancel button only..
>
> 2010/10/12 Shelli Orton <Sh...@sjrb.ca>
>
>> This is where my confusion about models may be kicking in.  I thought
>> that property models (PropertModel or CompoundPropertyModel)
>> automatically checked if the model object changed.  How do I tell the
>> model it has?
>>
>> Shelli
>>
>> -----Original Message-----
>> From: nino martinez wael [mailto:nino.martinez.wael@gmail.com]
>> Sent: Tuesday, October 12, 2010 12:10 PM
>> To: users@wicket.apache.org
>> Subject: Re: PropertyModel Not Refreshing
>>
>> in your add button you call setSelectedRecordA(new RecordA()) but
> never
>> notify the model that a change has occured...
>>
>> 2010/10/12 nino martinez wael <ni...@gmail.com>
>>
>> > hmm getting a lot of errors on the services not implementing
>> > serialization...
>> >
>> > But does seem theres a difference between calling :
>> >
>> > selectedRecordAModel.getObject().getName() and
>> > RecordAPanel.this.selectedRecordA
>> >
>> > 2010/10/12 nino martinez wael <ni...@gmail.com>
>> >
>> > sorry.. Did'nt see it attached.. So did igor provide you with an
> fixed
>> >> quickstart (working on his system).. That did not work on
> glassfish?
>> >>
>> >>
>> >> 2010/10/12 Shelli Orton <Sh...@sjrb.ca>
>> >>
>> >>> The quickstart was sent to the list this morning at 10:04 MST.
> Does
>> it
>> >>> need to be resent?
>> >>>
>> >>> Shelli
>> >>>
>> >>> -----Original Message-----
>> >>> From: nino martinez wael [mailto:nino.martinez.wael@gmail.com]
>> >>> Sent: Tuesday, October 12, 2010 11:52 AM
>> >>> To: users@wicket.apache.org
>> >>> Subject: Re: PropertyModel Not Refreshing
>> >>>
>> >>> No dont think so.. Please provide a quickstart.. I have had
> property
>> >>> models
>> >>> working in 1.2, 1.3, 1.4 and 1.5 so must be error 42:)
>> >>>
>> >>> 2010/10/12 Shelli Orton <Sh...@sjrb.ca>
>> >>>
>> >>> > Hi,
>> >>> >
>> >>> > Thanks for file.  Your first email was missing these changes:
>> >>> >
>> >>> >    IModel<RecordA> selectedRecordAModel;  (I had set mine to
>> >>> > PropertyModel<RecordA> selectedRecordAModel;)
>> >>> >    recordAs.setModel(selectedRecordAModel)
>> >>> >
>> >>> > However, even with those changes applied, I still get the same
>> issue
>> >>> of the
>> >>> > selected record not updating in the edit group.
>> >>> >
>> >>> > I am deploying in Glassfish v3.  Could that have anything to do
>> with
>> >>> my
>> >>> > problems?
>> >>> >
>> >>> > Shelli
>> >>> >
>> >>> > -----Original Message-----
>> >>> > From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
>> >>> > Sent: Tuesday, October 12, 2010 11:35 AM
>> >>> > To: users@wicket.apache.org
>> >>> > Subject: Re: PropertyModel Not Refreshing
>> >>> >
>> >>> > On Tue, Oct 12, 2010 at 10:30 AM, Shelli Orton
>> <Sh...@sjrb.ca>
>> >>> > wrote:
>> >>> > > Thanks for the help.  Your changes got rid of the errors and I
>> can
>> >>> delete
>> >>> > records now (and the list is updated).
>> >>> > >
>> >>> > > However, once a record has been selected for edit and either
>> saved
>> >>> or
>> >>> > cancelled, that same record is always displayed in the edit
> group
>> when
>> >>> I
>> >>> > choose another record to edit or even when I try to create a new
>> one.
>> >>> I can
>> >>> > even delete the chosen record and it still displays in the edit
>> group.
>> >>> >
>> >>> > works fine here, meaning you did not completely/propery apply my
>> >>> > changes. below is the complete file.
>> >>> >
>> >>> > -igor
>> >>> >
>> >>> > public class RecordAPanel extends Panel
>> >>> > {
>> >>> >    private static final long serialVersionUID = 1L;
>> >>> >
>> >>> >    RecordAService recordAService;
>> >>> >    RecordBService recordBService;
>> >>> >
>> >>> >    RecordA selectedRecordA = new RecordA();
>> >>> >    IModel<RecordA> selectedRecordAModel;
>> >>> >    String unmodifiedRecordA;
>> >>> >
>> >>> >    boolean isNew = false;
>> >>> >
>> >>> >    WebMarkupContainer selectGroup;
>> >>> >    WebMarkupContainer editGroup;
>> >>> >
>> >>> >    Form selectForm;
>> >>> >    Form editForm;
>> >>> >
>> >>> >    DropDownChoice<RecordA> recordAs;
>> >>> >    DropDownChoice<RecordB> recordBs;
>> >>> >
>> >>> >    Button add;
>> >>> >    Button edit;
>> >>> >    Button save;
>> >>> >    Button delete;
>> >>> >    Button cancel;
>> >>> >
>> >>> >    Label editLegendLabel;
>> >>> >    String editLegend;
>> >>> >    Label recordALabel;
>> >>> >    Label recordBLabel;
>> >>> >
>> >>> >    RequiredTextField recordAText;
>> >>> >
>> >>> >    @SuppressWarnings({ "rawtypes", "unchecked" })
>> >>> >    public RecordAPanel(String id)
>> >>> >    {
>> >>> >        super(id);
>> >>> >
>> >>> >        recordAService = ((Application)
>> >>> > RequestCycle.get().getApplication()).getRecordAService();
>> >>> >        recordBService = ((Application)
>> >>> > RequestCycle.get().getApplication()).getRecordBService();
>> >>> >
>> >>> >        selectedRecordAModel = new PropertyModel<RecordA>(this,
>> >>> > "selectedRecordA");
>> >>> >        this.setDefaultModel(selectedRecordAModel);
>> >>> >
>> >>> >        // ************* Select  Group *************
>> >>> >
>> >>> >        selectGroup = new WebMarkupContainer("selectGroup");
>> >>> >        selectForm = new Form("selectForm");
>> >>> >
>> >>> >        recordAs = new DropDownChoice<RecordA>("recordAs");
>> >>> >        recordAs.setModel(selectedRecordAModel);
>> >>> >        recordAs.setChoices(recordAsModel);
>> >>> >        recordAs.setChoiceRenderer(new RecordARenderer());
>> >>> >
>> >>> >        //            recordAs = (DropDownChoice<RecordA>) new
>> >>> > DropDownChoice<RecordA>("recordAs",
>> >>> >        //                    new PropertyModel<RecordA>(this,
>> >>> > "selectedRecordA"),
>> >>> >        //                    recordAsModel,
>> >>> >        //                    new RecordARenderer());
>> >>> >
>> >>> >        recordAs.setNullValid(false);
>> >>> >
>> >>> >        selectForm.add(recordAs);
>> >>> >
>> >>> >        add = new Button("add")
>> >>> >        {
>> >>> >            private static final long serialVersionUID = 1L;
>> >>> >
>> >>> >            public void onSubmit()
>> >>> >            {
>> >>> >                setSelectedRecordA(new RecordA());
>> >>> >                isNew = true;
>> >>> >                editLegend = "New";
>> >>> >                editGroup.setVisible(true);
>> >>> >                selectGroup.setVisible(false);
>> >>> >            }
>> >>> >        };
>> >>> >
>> >>> >        selectForm.add(add);
>> >>> >
>> >>> >        edit = new Button("edit")
>> >>> >        {
>> >>> >            private static final long serialVersionUID = 1L;
>> >>> >
>> >>> >            public void onSubmit()
>> >>> >            {
>> >>> >                if (selectedRecordA == null)
>> >>> >                {
>> >>> >                    info("You must select a record to edit.");
>> >>> >                }
>> >>> >                else
>> >>> >                {
>> >>> >                    unmodifiedRecordA =
> selectedRecordA.getName();
>> >>> >                    isNew = false;
>> >>> >                    editLegend = "Edit";
>> >>> >                    editGroup.setVisible(true);
>> >>> >                    selectGroup.setVisible(false);
>> >>> >                }
>> >>> >            }
>> >>> >        };
>> >>> >
>> >>> >        selectForm.add(edit);
>> >>> >
>> >>> >        delete = new Button("delete")
>> >>> >        {
>> >>> >            private static final long serialVersionUID = 1L;
>> >>> >
>> >>> >            public void onSubmit()
>> >>> >            {
>> >>> >                if (selectedRecordA == null)
>> >>> >                {
>> >>> >                    info("You must select a record to delete.");
>> >>> >                }
>> >>> >                else
>> >>> >                {
>> >>> >                    // Delete the selected record
>> >>> >                    unmodifiedRecordA =
> selectedRecordA.getName();
>> >>> >
>> recordAService.delete(selectedRecordA.getName());
>> >>> >                    selectedRecordA = null;
>> >>> >                    info("Deleted '" + unmodifiedRecordA + "'");
>> >>> >
>> >>> >                    // Force refresh of records list
>> >>> >                    RecordAPanel.this.recordAsModel.detach();
>> >>> >                }
>> >>> >            }
>> >>> >        };
>> >>> >
>> >>> >        // Add confirmation dialog box
>> >>> >        delete.add(new SimpleAttributeModifier("onclick",
>> >>> >                "if (!confirm('Please confirm you want to delete
>> this
>> >>> > record') ){ return false; }"));
>> >>> >
>> >>> >        selectForm.add(delete);
>> >>> >        selectGroup.add(selectForm);
>> >>> >
>> >>> >        this.add(selectGroup);
>> >>> >
>> >>> >        // ************* Edit Group *************
>> >>> >
>> >>> >        editGroup = new WebMarkupContainer("editGroup");
>> >>> >
>> >>> >        editLegendLabel = new Label("editLegend", new
>> >>> PropertyModel(this,
>> >>> >                "editLegend"));
>> >>> >
>> >>> >        editGroup.add(editLegendLabel);
>> >>> >
>> >>> >        editForm = new Form("editForm");
>> >>> >
>> >>> >        recordALabel = new Label("recordALabel", "Record A");
>> >>> >        editForm.add(recordALabel);
>> >>> >
>> >>> >        recordBLabel = new Label("recordBLabel", "Record B");
>> >>> >        editForm.add(recordBLabel);
>> >>> >
>> >>> >        recordAText = new RequiredTextField("recordAText",
>> >>> >                new PropertyModel(selectedRecordAModel, "name"));
>> >>> >
>> >>> >        editForm.add(recordAText);
>> >>> >
>> >>> >        recordBs = new DropDownChoice<RecordB>("recordBs");
>> >>> >        recordBs.setModel(new PropertyModel(selectedRecordAModel,
>> >>> > "recordB"));
>> >>> >        recordBs.setChoices(RecordAPanel.this.getRecordBs());
>> >>> >        recordBs.setChoiceRenderer(new RecordBRenderer());
>> >>> >
>> >>> >        editForm.add(recordBs);
>> >>> >
>> >>> >        save = new Button("save")
>> >>> >        {
>> >>> >            private static final long serialVersionUID = 1L;
>> >>> >
>> >>> >            @Override
>> >>> >            public void onSubmit()
>> >>> >            {
>> >>> >                if (isNew)
>> >>> >                {
>> >>> >
>> >>> > recordAService.create(RecordAPanel.this.selectedRecordA);
>> >>> >                        info("Created '"
>> >>> >                                +
>> >>> > RecordAPanel.this.selectedRecordA.getName()
>> >>> >                                + "'");
>> >>> >                }
>> >>> >                else
>> >>> >                {
>> >>> >                        recordAService.update(unmodifiedRecordA,
>> >>> >
> RecordAPanel.this.selectedRecordA);
>> >>> >                        info("Updated '"
>> >>> >                                +
>> >>> > RecordAPanel.this.selectedRecordA.getName()
>> >>> >                                + "'");
>> >>> >                }
>> >>> >
>> >>> >                // TODO Update the dropdown list?
>> >>> >
>> >>> >                editGroup.setVisible(false);
>> >>> >                selectGroup.setVisible(true);
>> >>> >            }
>> >>> >        };
>> >>> >
>> >>> >        editForm.add(save);
>> >>> >
>> >>> >        cancel = new Button("cancel")
>> >>> >        {
>> >>> >            private static final long serialVersionUID = 1L;
>> >>> >
>> >>> >            public void onSubmit()
>> >>> >            {
>> >>> >                RecordAPanel.this.selectedRecordA = null;
>> >>> >                editGroup.setVisible(false);
>> >>> >                selectGroup.setVisible(true);
>> >>> >            }
>> >>> >        };
>> >>> >
>> >>> >        cancel.setDefaultFormProcessing(false);
>> >>> >        editForm.add(cancel);
>> >>> >
>> >>> >        editGroup.add(editForm);
>> >>> >
>> >>> >        editGroup.setVisible(false);
>> >>> >        this.add(editGroup);
>> >>> >    }
>> >>> >
>> >>> >    public RecordA getSelectedRecordA()
>> >>> >    {
>> >>> >        return selectedRecordA;
>> >>> >    }
>> >>> >
>> >>> >    public void setSelectedRecordA(RecordA selectedRecordA)
>> >>> >    {
>> >>> >        this.selectedRecordA = selectedRecordA;
>> >>> >    }
>> >>> >
>> >>> >    public LoadableDetachableModel<List<RecordA>> recordAsModel =
>> new
>> >>> > LoadableDetachableModel<List<RecordA>>()
>> >>> >    {
>> >>> >        private static final long serialVersionUID = 1L;
>> >>> >
>> >>> >        @Override
>> >>> >        protected List<RecordA> load()
>> >>> >        {
>> >>> >            return recordAService.getList();
>> >>> >        }
>> >>> >
>> >>> >        public void detach()
>> >>> >        {
>> >>> >            super.detach();
>> >>> >        }
>> >>> >    };
>> >>> >
>> >>> >    // TODO change this to LDM?
>> >>> >    List<RecordB> getRecordBs()
>> >>> >    {
>> >>> >        return recordBService.getList();
>> >>> >    }
>> >>> >
>> >>> >    class RecordARenderer implements IChoiceRenderer<RecordA>
>> >>> >    {
>> >>> >        private static final long serialVersionUID = 1L;
>> >>> >
>> >>> >        public Object getDisplayValue(RecordA recordA)
>> >>> >        {
>> >>> >            return recordA.getName();
>> >>> >        }
>> >>> >
>> >>> >        public String getIdValue(RecordA recordA, int index)
>> >>> >        {
>> >>> >            return recordA.getName();
>> >>> >        }
>> >>> >    }
>> >>> >
>> >>> >    class RecordBRenderer implements IChoiceRenderer<RecordB>
>> >>> >    {
>> >>> >        private static final long serialVersionUID = 1L;
>> >>> >
>> >>> >        public Object getDisplayValue(RecordB recordB)
>> >>> >        {
>> >>> >            return recordB.getName();
>> >>> >        }
>> >>> >
>> >>> >        public String getIdValue(RecordB recordB, int index)
>> >>> >        {
>> >>> >            return recordB.getName();
>> >>> >        }
>> >>> >    }
>> >>> > }
>> >>> >
>> >>> > >
>> >>> > > Shelli
>> >>> > >
>> >>> > > -----Original Message-----
>> >>> > > From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
>> >>> > > Sent: Tuesday, October 12, 2010 10:38 AM
>> >>> > > To: users@wicket.apache.org
>> >>> > > Subject: Re: PropertyModel Not Refreshing
>> >>> > >
>> >>> > > here are the tweaks you need to make this work:
>> >>> > >
>> >>> > > selectedRecordAModel = new PropertyModel<RecordA>(this,
>> >>> > "selectedRecordA");
>> >>> > >
>> >>> > > recordAText = new RequiredTextField("recordAText",
>> >>> > >                new PropertyModel(selectedRecordAModel,
> "name"));
>> >>> > >
>> >>> > >  recordBs.setModel(new PropertyModel(selectedRecordAModel,
>> >>> "recordB"));
>> >>> > >
>> >>> > > have fun
>> >>> > >
>> >>> > > -igor
>> >>> > >
>> >>> > > On Tue, Oct 12, 2010 at 9:03 AM, Shelli Orton
>> <Sh...@sjrb.ca>
>> >>> > wrote:
>> >>> > >> I've been able to create a sample application that exhibits
> the
>> >>> > >> same/similar problems to mine.  The sample makes use of an
>> >>> in-memory
>> >>> > >> list for the data versus accessing a database and so there's
>> some
>> >>> > >> differences.  However, I believe the problems that this
> sample
>> >>> exhibits
>> >>> > >> have the same root cause as my project (which I believe have
>> >>> something
>> >>> > >> to do with how my models are set up...).
>> >>> > >>
>> >>> > >> Issues this sample exhibits:
>> >>> > >>
>> >>> > >> 1. Choose to edit an existing record, then cancel the edit.
>> Choose
>> >>> > >> another/the same record to edit and the selected record is
> null
>> >>> (error
>> >>> > >> message "You must select a record to edit" is displayed).
> Must
>> >>> > >> close/open session to reset.
>> >>> > >>
>> >>> > >> 2. Choose to edit an existing record and save the edit.
> Choose
>> >>> > >> another/the same record to edit and you get a NPE:
>> >>> > >>
>> >>> > >>    WicketMessage: Method onFormSubmitted of interface
>> >>> > >> org.apache.wicket.markup.html.form.IFormSubmitListener
> targeted
>> at
>> >>> > >> component [MarkupContainer [Component id = selectForm]] threw
>> an
>> >>> > >> exception
>> >>> > >>
>> >>> > >>    Root cause:
>> >>> > >>
>> >>> > >>    java.lang.NullPointerException
>> >>> > >>    at
>> >>> > >>
>> >>>
>>
> org.apache.wicket.markup.html.form.AbstractSingleSelectChoice.convertCho
>> >>> > >> iceIdToChoice(AbstractSingleSelectChoice.java:247)
>> >>> > >>
>> >>> > >> 3. Create a new record and try to save it and get
>> >>> > >> WicketRuntimeException:
>> >>> > >>
>> >>> > >>    WicketMessage: Attempted to set property value on a null
>> object.
>> >>> > >> Property expression: name Value: New One
>> >>> > >>
>> >>> > >>    Root cause:
>> >>> > >>
>> >>> > >>    org.apache.wicket.WicketRuntimeException: Attempted to set
>> >>> property
>> >>> > >> value on a null object. Property expression: name Value: New
>> One
>> >>> > >>    at
>> >>> > >>
>> >>>
>>
> org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.j
>> >>> > >> ava:125)
>> >>> > >>
>> >>> > >> 4. Create a new record and then cancel the add, Choose an
>> existing
>> >>> > >> record to edit and the selected record is null (error message
>> "You
>> >>> must
>> >>> > >> select a record to edit" is displayed).  Must close/open
>> session to
>> >>> > >> reset.
>> >>> > >>
>> >>> > >> As always, all help is greatly appreciated as I am stumped.
>> >>> > >>
>> >>> > >> Thanks,
>> >>> > >> Shelli
>> >>> > >>
>> >>> > >> -----Original Message-----
>> >>> > >> From: jcgarciam [mailto:jcgarciam@gmail.com]
>> >>> > >> Sent: Friday, October 08, 2010 1:41 PM
>> >>> > >> To: users@wicket.apache.org
>> >>> > >> Subject: Re: PropertyModel Not Refreshing
>> >>> > >>
>> >>> > >>
>> >>> > >> The attachment didn't make it,
>> >>> > >>
>> >>> > >> Can you try to extract out the relevant part and creates a
>> >>> quickstart
>> >>> > >> project that actually reproduces your issue?
>> >>> > >>
>> >>> > >>
>> >>> > >> On Fri, Oct 8, 2010 at 1:41 PM, Shelli Orton [via Apache
>> Wicket] <
>> >>> > >>
>> >>>
>>
> ml-node+2968688-305091622-65838@n4.nabble.com<ml-node%2B2968688-30509162
> 2-65838@n4.nabble.com>
>> <ml-node%2B2968688-30509162
>> 2-65838@n4.nabble.com>
>> >>> <ml-node%2B2968688-30509162
>> >>> 2-65838@n4.nabble.com>
>> >>> > <ml-node%2B2968688-30509162
>> >>> > >> 2-65838@n4.nabble.com>
>> >>> > >>> wrote:
>> >>> > >>
>> >>> > >>> Hi,
>> >>> > >>>
>> >>> > >>> I have been trying different things to see if I could get my
>> code
>> >>> to
>> >>> > >> work
>> >>> > >>> (and understand Wicket models better), but am still stuck.
> I
>> have
>> >>> a
>> >>> > >>> attached the (latest) panel class code which I hope is
>> sufficient
>> >>> to
>> >>> > >> help.
>> >>> > >>>
>> >>> > >>> I was reading about different models (both online and the
>> Wicket
>> >>> in
>> >>> > >> Action
>> >>> > >>> book) and thought that perhaps using a CompoundPropertyModel
>> was
>> >>> more
>> >>> > >>> appropriate and may help with my issues.  Originally, I only
>> >>> declared
>> >>> > >>> selectedRecordA (line 40) but didn't instantiate it.  The
>> select
>> >>> group
>> >>> > >>> displayed properly but when I chose a record from the list
> and
>> >>> tried
>> >>> > >> to edit
>> >>> > >>> it, this exception was thrown:
>> >>> > >>>
>> >>> > >>>     WicketMessage: Attempted to set property value on a null
>> >>> object.
>> >>> > >>> Property expression: recordA Value: Name=A-One
>> >>> > >>>     Root cause:
>> >>> > >>>
>> >>> > >>>     org.apache.wicket.WicketRuntimeException: Attempted to
> set
>> >>> > >> property
>> >>> > >>> value on a null object. Property expression: recordA Value:
>> >>> Name=A-One
>> >>> > >>>         at
>> >>> > >>>
>> >>> > >>
>> >>>
>>
> org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.j
>> >>> > >> ava:125)
>> >>> > >>>
>> >>> > >>>         at
>> >>> > >>>
>> >>> > >>
>> >>>
>>
> org.apache.wicket.model.AbstractPropertyModel.setObject(AbstractProperty
>> >>> > >> Model.java:169)
>> >>> > >>>
>> >>> > >>>         at
>> >>> > >>>
>> >>>
>> org.apache.wicket.Component.setDefaultModelObject(Component.java:3125)
>> >>> > >>>         ....
>> >>> > >>>
>> >>> > >>> I set breakpoints on the getSelectedRecordA and
>> setSelectedRecordA
>> >>> > >> methods,
>> >>> > >>> but these aren't called when during the request cycle when
> the
>> >>> edit
>> >>> > >> button
>> >>> > >>> is clicked.
>> >>> > >>>
>> >>> > >>> I then changed the class so that selectedRecordA is
>> initialized to
>> >>> an
>> >>> > >> empty
>> >>> > >>> instance of RecordA. This got rid of the above error.
>> However, I
>> >>> > >> cannot
>> >>> > >>> save the edit changes because the selectedRecordA is still
> the
>> >>> empty
>> >>> > >>> instance that was created in the initialization and the
>> >>> persistence
>> >>> > >> layer
>> >>> > >>> throws an exception.  This same problem exists if I try to
> add
>> a
>> >>> new
>> >>> > >> RecordA
>> >>> > >>> or try to delete an existing one.
>> >>> > >>>
>> >>> > >>> If I choose to cancel the edit and then select another
> record
>> to
>> >>> edit,
>> >>> > >> I
>> >>> > >>> get the message "You must select a record to edit" (line
> 131).
>> >>> This
>> >>> > >> is
>> >>> > >>> because the cancel onSubmit sets selectedRecordA to null and
>> >>> choosing
>> >>> > >> the
>> >>> > >>> record from the DDC is not setting it to the chosen record.
>> >>> > >>>
>> >>> > >>> Clearly I am not setting up this CompoundPropertyModel
>> properly so
>> >>> > >> that the
>> >>> > >>> selectedARecord is set by the model.  Can someone tell me
> what
>> I'm
>> >>> > >> doing
>> >>> > >>> wrong?
>> >>> > >>>
>> >>> > >>> All help is greatly appreciated,
>> >>> > >>>
>> >>> > >>> Shelli
>> >>> > >>>
>> >>> > >>>
>> >>> > >>> -----Original Message-----
>> >>> > >>> From: Igor Vaynberg [mailto:[hidden
>> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=0>]
>> >>> > >>>
>> >>> > >>> Sent: Thursday, October 07, 2010 11:27 AM
>> >>> > >>> To: [hidden email]
>> >>> > >> <http://user/SendEmail.jtp?type=node&node=2968688&i=1>
>> >>> > >>> Subject: Re: PropertyModel Not Refreshing
>> >>> > >>>
>> >>> > >>> you have posted an incomplete piece of code and somehow from
>> that
>> >>> we
>> >>> > >>> are supposed to guess what is not working? create a
> quickstart
>> and
>> >>> > >>> provide that.
>> >>> > >>>
>> >>> > >>> -igor
>> >>> > >>>
>> >>> > >>> On Thu, Oct 7, 2010 at 10:15 AM, Shelli Orton <[hidden
>> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=2>>
>> >>> > >>> wrote:
>> >>> > >>>
>> >>> > >>> > Does nobody have any suggestions?  If I can't get this
>> fixed,
>> >>> I'm
>> >>> > >> going
>> >>> > >>> > to have to write the app in another framework (possibly
> GWT)
>> and
>> >>> I'd
>> >>> > >>> > really rather not have to do that.
>> >>> > >>> >
>> >>> > >>> > Shelli
>> >>> > >>> >
>> >>> > >>> > -----Original Message-----
>> >>> > >>> > From: Shelli Orton
>> >>> > >>> > Sent: Wednesday, October 06, 2010 3:52 PM
>> >>> > >>> > To: [hidden
>> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=3>
>> >>> > >>> > Subject: PropertyModel Not Refreshing
>> >>> > >>> >
>> >>> > >>> > Hi,
>> >>> > >>> >
>> >>> > >>> > First, thanks to all who have been helping me as I am new
> to
>> >>> Wicket.
>> >>> > >> I
>> >>> > >>> > am splitting out two issues I am dealing with to try to
> keep
>> >>> things
>> >>> > >>> > clear.
>> >>> > >>> >
>> >>> > >>> > I am trying to write a simple app that does CRUD
> operations
>> on
>> >>> > >> database
>> >>> > >>> > records.  The goal is for the app to make use of a tab
> panel
>> >>> where
>> >>> > >> each
>> >>> > >>> > tab encapsulates one table from the database.  Each tab
>> panel
>> >>> has
>> >>> > >> two
>> >>> > >>> > groups (WebMarkupContainer).  The first, selectGroup,
>> displays a
>> >>> > >> list
>> >>> > >>> > (DDC) of the current items, and three buttons, add, edit
> and
>> >>> delete.
>> >>> > >>> > The second, editGroup, is displayed when either the add or
>> edit
>> >>> > >> button
>> >>> > >>> > was clicked on the select group, displays the record
>> attributes
>> >>> and
>> >>> > >> save
>> >>> > >>> > and cancel buttons.  The tab panel has a "selectedRecord"
>> which
>> >>> is
>> >>> > >> used
>> >>> > >>> > by both groups' components via PropertyModels. Very basic
>> stuff.
>> >>> > >>> >
>> >>> > >>> > When I choose a record and click the edit button, the
> record
>> is
>> >>> > >>> > displayed in the edit group properly.  If I then choose
>> cancel,
>> >>> the
>> >>> > >> edit
>> >>> > >>> > group is no longer displayed and the select group DDC
>> selection
>> >>> is
>> >>> > >> null
>> >>> > >>> > as expected. I then choose another record from the list
> and
>> >>> click
>> >>> > >> the
>> >>> > >>> > edit button and the previous record information is
> displayed
>> in
>> >>> the
>> >>> > >> edit
>> >>> > >>> > group even though the select group DDC shows the
>> >>> correct/selected
>> >>> > >>> > record.
>> >>> > >>> >
>> >>> > >>> > This problem also occurs if I first choose to add a new
>> record
>> >>> and
>> >>> > >> then
>> >>> > >>> > cancel the add and then choose to edit a different record.
>> The
>> >>> DDC
>> >>> > >>> > shows the correct/selected record, but all the attributes
> in
>> the
>> >>> > >> edit
>> >>> > >>> > group are null/defaults for a new record.
>> >>> > >>> >
>> >>> > >>> > If I remove the call to setDefaultFormProcessing(false) on
>> the
>> >>> > >> cancel
>> >>> > >>> > button, selecting other records for edit works correctly,
>> but I
>> >>> > >> can't
>> >>> > >>> > cancel a creating a new record if I use a
> RequiredTextField
>> >>> because
>> >>> > >> the
>> >>> > >>> > form validation fails.
>> >>> > >>> >
>> >>> > >>> > If I select a record for editing or save the newly created
>> >>> record, I
>> >>> > >> can
>> >>> > >>> > select a different record for edit or create another one
>> >>> correctly.
>> >>> > >> So
>> >>> > >>> > I must be doing something wrong in the cancel logic. My
>> editForm
>> >>> > >>> > (created in the EditGroup constructor) looks like this:
>> >>> > >>> >
>> >>> > >>> >            Form editForm = new Form("editForm");
>> >>> > >>> >
>> >>> > >>> >            editForm.add(new Label("nameLabel", "Name"));
>> >>> > >>> >
>> >>> > >>> >            editForm.add(new Label("attributeLabel",
>> >>> "Attribute"));
>> >>> > >>> >
>> >>> > >>> >            editForm.add(new
>> >>> > >> RequiredTextField<String>("recordNameText",
>> >>> > >>> >                    new
>> PropertyModel<String>(MyRecordPanel.this,
>> >>> > >>> >                            "selectedRecord.name")));
>> >>> > >>> >
>> >>> > >>> >            editForm.add(new
>> DropDownChoice<Lir>("attributes",
>> >>> > >>> >                    new
>> >>> PropertyModel<Attribute>(MyRecordPanel.this,
>> >>> > >>> >                            "selectedRecord.attribute"),
>> >>> > >>> >                    RateCentrePanel.this.getAttributes(),
>> >>> > >>> >                    new AttributeRenderer()));
>> >>> > >>> >
>> >>> > >>> >            ....
>> >>> > >>> >
>> >>> > >>> >            editForm.add(new Button("cancel")
>> >>> > >>> >            {
>> >>> > >>> >                private static final long serialVersionUID
> =
>> 1L;
>> >>> > >>> >
>> >>> > >>> >                public void onSubmit()
>> >>> > >>> >                {
>> >>> > >>> >                    MyRecordPanel.this.selectedRecord =
> null;
>> >>> > >>> >                    editGroup.setVisible(false);
>> >>> > >>> >                    selectGroup.setVisible(true);
>> >>> > >>> >                }
>> >>> > >>> >            }.setDefaultFormProcessing(false));
>> >>> > >>> >
>> >>> > >>> >            add(editForm);
>> >>> > >>> >
>> >>> > >>> > Other than setting the selectedRecord to null, what should
> I
>> be
>> >>> > >> doing
>> >>> > >>> > differently?
>> >>> > >>> >
>> >>> > >>> > Thanks in advance!
>> >>> > >>> >
>> >>> > >>> > Shelli
>> >>> > >>> >
>> >>> > >>> >
>> >>> > >>
>> >>>
>> ---------------------------------------------------------------------
>> >>> > >>> > To unsubscribe, e-mail: [hidden
>> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=4>
>> >>> > >>> > For additional commands, e-mail: [hidden
>> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=5>
>> >>> > >>> >
>> >>> > >>> >
>> >>> > >>> >
>> >>> > >>
>> >>>
>> ---------------------------------------------------------------------
>> >>> > >>> > To unsubscribe, e-mail: [hidden
>> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=6>
>> >>> > >>> > For additional commands, e-mail: [hidden
>> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=7>
>> >>> > >>> >
>> >>> > >>> >
>> >>> > >>>
>> >>>
>> ---------------------------------------------------------------------
>> >>> > >>> To unsubscribe, e-mail: [hidden
>> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=8>
>> >>> > >>> For additional commands, e-mail: [hidden
>> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=9>
>> >>> > >>>
>> >>> > >>>
>> >>> > >>>
>> >>> > >>>
>> >>> > >>>
>> >>>
>> ---------------------------------------------------------------------
>> >>> > >>> To unsubscribe, e-mail: [hidden
>> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=10>
>> >>> > >>> For additional commands, e-mail: [hidden
>> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=11>
>> >>> > >>>
>> >>> > >>> ------------------------------
>> >>> > >>>  View message @
>> >>> > >>>
>> >>> > >>
>> >>> >
>> >>>
>>
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
>> >>> > >> n-tp2955144p2968688.html
>> >>> > >>> To start a new topic under Apache Wicket, email
>> >>> > >>>
>> >>> > >>
>> >>>
>>
> ml-node+1842946-398011874-65838@n4.nabble.com<ml-node%2B1842946-39801187
> 4-65838@n4.nabble.com>
>> <ml-node%2B1842946-39801187
>> 4-65838@n4.nabble.com>
>> >>> <ml-node%2B1842946-39801187
>> >>> 4-65838@n4.nabble.com>
>> >>> > <ml-node%2B1842946-39801187
>> >>> > >> 4-65838@n4.nabble.com>
>> >>> > >>> To unsubscribe from Apache Wicket, click
>> >>> > >>
>> >>>
>>
> here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp
>> >>> > ?
>> >>> > >>
>> >>>
>>
> tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
>> >>> > >> QyOTQ2fDEyNTYxMzc3ODY=>.
>> >>> > >>>
>> >>> > >>>
>> >>> > >>>
>> >>> > >>
>> >>> > >>
>> >>> > >> --
>> >>> > >> Sincerely,
>> >>> > >> JC (http://www.linkedin.com/in/jcgarciam)
>> >>> > >> Work smarter, not harder!.
>> >>> > >>
>> >>> > >> --
>> >>> > >> View this message in context:
>> >>> > >>
>> >>> >
>> >>>
>>
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
>> >>> > >> n-tp2955144p2968936.html
>> >>> > >> Sent from the Users forum mailing list archive at Nabble.com.
>> >>> > >>
>> >>> > >>
>> >>>
>> ---------------------------------------------------------------------
>> >>> > >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >>> > >> For additional commands, e-mail: users-help@wicket.apache.org
>> >>> > >>
>> >>> > >>
>> >>> > >>
>> >>> > >>
>> >>>
>> ---------------------------------------------------------------------
>> >>> > >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >>> > >> For additional commands, e-mail: users-help@wicket.apache.org
>> >>> > >>
>> >>> > >
>> >>> > >
>> >>>
>> ---------------------------------------------------------------------
>> >>> > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >>> > > For additional commands, e-mail: users-help@wicket.apache.org
>> >>> > >
>> >>> > >
>> >>> > >
>> >>>
>> ---------------------------------------------------------------------
>> >>> > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >>> > > For additional commands, e-mail: users-help@wicket.apache.org
>> >>> > >
>> >>> > >
>> >>> >
>> >>> >
>> ---------------------------------------------------------------------
>> >>> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >>> > For additional commands, e-mail: users-help@wicket.apache.org
>> >>> >
>> >>> >
>> >>> >
>> ---------------------------------------------------------------------
>> >>> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >>> > For additional commands, e-mail: users-help@wicket.apache.org
>> >>> >
>> >>> >
>> >>>
>> >>>
>> ---------------------------------------------------------------------
>> >>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >>> For additional commands, e-mail: users-help@wicket.apache.org
>> >>>
>> >>>
>> >>
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


RE: PropertyModel Not Refreshing

Posted by Shelli Orton <Sh...@sjrb.ca>.
I only explicitly set the selectedRecordA in two places, during the
cancel and add onSubmit methods (I removed the initialization in the
declaration in my code).  As you alluded to earlier, add is done via 

    setSelectedRecordA(new RecordA());

and cancel is done via:

    RecordAPanel.this.selectedRecordA = null;

I changed cancel to be:

    setSelectedRecordA(new RecordA());

but it doesn't seem to make a difference, still get the issue when
cancelling.

Should I be setting the selectedRecordA to null on cancel?  It makes
sense to me and it's what I've done in other applications/frameworks,
but perhaps it's not correct in Wicket...

Shelli

-----Original Message-----
From: nino martinez wael [mailto:nino.martinez.wael@gmail.com] 
Sent: Tuesday, October 12, 2010 3:00 PM
To: users@wicket.apache.org
Subject: Re: PropertyModel Not Refreshing

Think I was going in the wrong direction.. Looking at the error, seems
to
get triggered by pressing the cancel button only..

2010/10/12 Shelli Orton <Sh...@sjrb.ca>

> This is where my confusion about models may be kicking in.  I thought
> that property models (PropertModel or CompoundPropertyModel)
> automatically checked if the model object changed.  How do I tell the
> model it has?
>
> Shelli
>
> -----Original Message-----
> From: nino martinez wael [mailto:nino.martinez.wael@gmail.com]
> Sent: Tuesday, October 12, 2010 12:10 PM
> To: users@wicket.apache.org
> Subject: Re: PropertyModel Not Refreshing
>
> in your add button you call setSelectedRecordA(new RecordA()) but
never
> notify the model that a change has occured...
>
> 2010/10/12 nino martinez wael <ni...@gmail.com>
>
> > hmm getting a lot of errors on the services not implementing
> > serialization...
> >
> > But does seem theres a difference between calling :
> >
> > selectedRecordAModel.getObject().getName() and
> > RecordAPanel.this.selectedRecordA
> >
> > 2010/10/12 nino martinez wael <ni...@gmail.com>
> >
> > sorry.. Did'nt see it attached.. So did igor provide you with an
fixed
> >> quickstart (working on his system).. That did not work on
glassfish?
> >>
> >>
> >> 2010/10/12 Shelli Orton <Sh...@sjrb.ca>
> >>
> >>> The quickstart was sent to the list this morning at 10:04 MST.
Does
> it
> >>> need to be resent?
> >>>
> >>> Shelli
> >>>
> >>> -----Original Message-----
> >>> From: nino martinez wael [mailto:nino.martinez.wael@gmail.com]
> >>> Sent: Tuesday, October 12, 2010 11:52 AM
> >>> To: users@wicket.apache.org
> >>> Subject: Re: PropertyModel Not Refreshing
> >>>
> >>> No dont think so.. Please provide a quickstart.. I have had
property
> >>> models
> >>> working in 1.2, 1.3, 1.4 and 1.5 so must be error 42:)
> >>>
> >>> 2010/10/12 Shelli Orton <Sh...@sjrb.ca>
> >>>
> >>> > Hi,
> >>> >
> >>> > Thanks for file.  Your first email was missing these changes:
> >>> >
> >>> >    IModel<RecordA> selectedRecordAModel;  (I had set mine to
> >>> > PropertyModel<RecordA> selectedRecordAModel;)
> >>> >    recordAs.setModel(selectedRecordAModel)
> >>> >
> >>> > However, even with those changes applied, I still get the same
> issue
> >>> of the
> >>> > selected record not updating in the edit group.
> >>> >
> >>> > I am deploying in Glassfish v3.  Could that have anything to do
> with
> >>> my
> >>> > problems?
> >>> >
> >>> > Shelli
> >>> >
> >>> > -----Original Message-----
> >>> > From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
> >>> > Sent: Tuesday, October 12, 2010 11:35 AM
> >>> > To: users@wicket.apache.org
> >>> > Subject: Re: PropertyModel Not Refreshing
> >>> >
> >>> > On Tue, Oct 12, 2010 at 10:30 AM, Shelli Orton
> <Sh...@sjrb.ca>
> >>> > wrote:
> >>> > > Thanks for the help.  Your changes got rid of the errors and I
> can
> >>> delete
> >>> > records now (and the list is updated).
> >>> > >
> >>> > > However, once a record has been selected for edit and either
> saved
> >>> or
> >>> > cancelled, that same record is always displayed in the edit
group
> when
> >>> I
> >>> > choose another record to edit or even when I try to create a new
> one.
> >>> I can
> >>> > even delete the chosen record and it still displays in the edit
> group.
> >>> >
> >>> > works fine here, meaning you did not completely/propery apply my
> >>> > changes. below is the complete file.
> >>> >
> >>> > -igor
> >>> >
> >>> > public class RecordAPanel extends Panel
> >>> > {
> >>> >    private static final long serialVersionUID = 1L;
> >>> >
> >>> >    RecordAService recordAService;
> >>> >    RecordBService recordBService;
> >>> >
> >>> >    RecordA selectedRecordA = new RecordA();
> >>> >    IModel<RecordA> selectedRecordAModel;
> >>> >    String unmodifiedRecordA;
> >>> >
> >>> >    boolean isNew = false;
> >>> >
> >>> >    WebMarkupContainer selectGroup;
> >>> >    WebMarkupContainer editGroup;
> >>> >
> >>> >    Form selectForm;
> >>> >    Form editForm;
> >>> >
> >>> >    DropDownChoice<RecordA> recordAs;
> >>> >    DropDownChoice<RecordB> recordBs;
> >>> >
> >>> >    Button add;
> >>> >    Button edit;
> >>> >    Button save;
> >>> >    Button delete;
> >>> >    Button cancel;
> >>> >
> >>> >    Label editLegendLabel;
> >>> >    String editLegend;
> >>> >    Label recordALabel;
> >>> >    Label recordBLabel;
> >>> >
> >>> >    RequiredTextField recordAText;
> >>> >
> >>> >    @SuppressWarnings({ "rawtypes", "unchecked" })
> >>> >    public RecordAPanel(String id)
> >>> >    {
> >>> >        super(id);
> >>> >
> >>> >        recordAService = ((Application)
> >>> > RequestCycle.get().getApplication()).getRecordAService();
> >>> >        recordBService = ((Application)
> >>> > RequestCycle.get().getApplication()).getRecordBService();
> >>> >
> >>> >        selectedRecordAModel = new PropertyModel<RecordA>(this,
> >>> > "selectedRecordA");
> >>> >        this.setDefaultModel(selectedRecordAModel);
> >>> >
> >>> >        // ************* Select  Group *************
> >>> >
> >>> >        selectGroup = new WebMarkupContainer("selectGroup");
> >>> >        selectForm = new Form("selectForm");
> >>> >
> >>> >        recordAs = new DropDownChoice<RecordA>("recordAs");
> >>> >        recordAs.setModel(selectedRecordAModel);
> >>> >        recordAs.setChoices(recordAsModel);
> >>> >        recordAs.setChoiceRenderer(new RecordARenderer());
> >>> >
> >>> >        //            recordAs = (DropDownChoice<RecordA>) new
> >>> > DropDownChoice<RecordA>("recordAs",
> >>> >        //                    new PropertyModel<RecordA>(this,
> >>> > "selectedRecordA"),
> >>> >        //                    recordAsModel,
> >>> >        //                    new RecordARenderer());
> >>> >
> >>> >        recordAs.setNullValid(false);
> >>> >
> >>> >        selectForm.add(recordAs);
> >>> >
> >>> >        add = new Button("add")
> >>> >        {
> >>> >            private static final long serialVersionUID = 1L;
> >>> >
> >>> >            public void onSubmit()
> >>> >            {
> >>> >                setSelectedRecordA(new RecordA());
> >>> >                isNew = true;
> >>> >                editLegend = "New";
> >>> >                editGroup.setVisible(true);
> >>> >                selectGroup.setVisible(false);
> >>> >            }
> >>> >        };
> >>> >
> >>> >        selectForm.add(add);
> >>> >
> >>> >        edit = new Button("edit")
> >>> >        {
> >>> >            private static final long serialVersionUID = 1L;
> >>> >
> >>> >            public void onSubmit()
> >>> >            {
> >>> >                if (selectedRecordA == null)
> >>> >                {
> >>> >                    info("You must select a record to edit.");
> >>> >                }
> >>> >                else
> >>> >                {
> >>> >                    unmodifiedRecordA =
selectedRecordA.getName();
> >>> >                    isNew = false;
> >>> >                    editLegend = "Edit";
> >>> >                    editGroup.setVisible(true);
> >>> >                    selectGroup.setVisible(false);
> >>> >                }
> >>> >            }
> >>> >        };
> >>> >
> >>> >        selectForm.add(edit);
> >>> >
> >>> >        delete = new Button("delete")
> >>> >        {
> >>> >            private static final long serialVersionUID = 1L;
> >>> >
> >>> >            public void onSubmit()
> >>> >            {
> >>> >                if (selectedRecordA == null)
> >>> >                {
> >>> >                    info("You must select a record to delete.");
> >>> >                }
> >>> >                else
> >>> >                {
> >>> >                    // Delete the selected record
> >>> >                    unmodifiedRecordA =
selectedRecordA.getName();
> >>> >
> recordAService.delete(selectedRecordA.getName());
> >>> >                    selectedRecordA = null;
> >>> >                    info("Deleted '" + unmodifiedRecordA + "'");
> >>> >
> >>> >                    // Force refresh of records list
> >>> >                    RecordAPanel.this.recordAsModel.detach();
> >>> >                }
> >>> >            }
> >>> >        };
> >>> >
> >>> >        // Add confirmation dialog box
> >>> >        delete.add(new SimpleAttributeModifier("onclick",
> >>> >                "if (!confirm('Please confirm you want to delete
> this
> >>> > record') ){ return false; }"));
> >>> >
> >>> >        selectForm.add(delete);
> >>> >        selectGroup.add(selectForm);
> >>> >
> >>> >        this.add(selectGroup);
> >>> >
> >>> >        // ************* Edit Group *************
> >>> >
> >>> >        editGroup = new WebMarkupContainer("editGroup");
> >>> >
> >>> >        editLegendLabel = new Label("editLegend", new
> >>> PropertyModel(this,
> >>> >                "editLegend"));
> >>> >
> >>> >        editGroup.add(editLegendLabel);
> >>> >
> >>> >        editForm = new Form("editForm");
> >>> >
> >>> >        recordALabel = new Label("recordALabel", "Record A");
> >>> >        editForm.add(recordALabel);
> >>> >
> >>> >        recordBLabel = new Label("recordBLabel", "Record B");
> >>> >        editForm.add(recordBLabel);
> >>> >
> >>> >        recordAText = new RequiredTextField("recordAText",
> >>> >                new PropertyModel(selectedRecordAModel, "name"));
> >>> >
> >>> >        editForm.add(recordAText);
> >>> >
> >>> >        recordBs = new DropDownChoice<RecordB>("recordBs");
> >>> >        recordBs.setModel(new PropertyModel(selectedRecordAModel,
> >>> > "recordB"));
> >>> >        recordBs.setChoices(RecordAPanel.this.getRecordBs());
> >>> >        recordBs.setChoiceRenderer(new RecordBRenderer());
> >>> >
> >>> >        editForm.add(recordBs);
> >>> >
> >>> >        save = new Button("save")
> >>> >        {
> >>> >            private static final long serialVersionUID = 1L;
> >>> >
> >>> >            @Override
> >>> >            public void onSubmit()
> >>> >            {
> >>> >                if (isNew)
> >>> >                {
> >>> >
> >>> > recordAService.create(RecordAPanel.this.selectedRecordA);
> >>> >                        info("Created '"
> >>> >                                +
> >>> > RecordAPanel.this.selectedRecordA.getName()
> >>> >                                + "'");
> >>> >                }
> >>> >                else
> >>> >                {
> >>> >                        recordAService.update(unmodifiedRecordA,
> >>> >
RecordAPanel.this.selectedRecordA);
> >>> >                        info("Updated '"
> >>> >                                +
> >>> > RecordAPanel.this.selectedRecordA.getName()
> >>> >                                + "'");
> >>> >                }
> >>> >
> >>> >                // TODO Update the dropdown list?
> >>> >
> >>> >                editGroup.setVisible(false);
> >>> >                selectGroup.setVisible(true);
> >>> >            }
> >>> >        };
> >>> >
> >>> >        editForm.add(save);
> >>> >
> >>> >        cancel = new Button("cancel")
> >>> >        {
> >>> >            private static final long serialVersionUID = 1L;
> >>> >
> >>> >            public void onSubmit()
> >>> >            {
> >>> >                RecordAPanel.this.selectedRecordA = null;
> >>> >                editGroup.setVisible(false);
> >>> >                selectGroup.setVisible(true);
> >>> >            }
> >>> >        };
> >>> >
> >>> >        cancel.setDefaultFormProcessing(false);
> >>> >        editForm.add(cancel);
> >>> >
> >>> >        editGroup.add(editForm);
> >>> >
> >>> >        editGroup.setVisible(false);
> >>> >        this.add(editGroup);
> >>> >    }
> >>> >
> >>> >    public RecordA getSelectedRecordA()
> >>> >    {
> >>> >        return selectedRecordA;
> >>> >    }
> >>> >
> >>> >    public void setSelectedRecordA(RecordA selectedRecordA)
> >>> >    {
> >>> >        this.selectedRecordA = selectedRecordA;
> >>> >    }
> >>> >
> >>> >    public LoadableDetachableModel<List<RecordA>> recordAsModel =
> new
> >>> > LoadableDetachableModel<List<RecordA>>()
> >>> >    {
> >>> >        private static final long serialVersionUID = 1L;
> >>> >
> >>> >        @Override
> >>> >        protected List<RecordA> load()
> >>> >        {
> >>> >            return recordAService.getList();
> >>> >        }
> >>> >
> >>> >        public void detach()
> >>> >        {
> >>> >            super.detach();
> >>> >        }
> >>> >    };
> >>> >
> >>> >    // TODO change this to LDM?
> >>> >    List<RecordB> getRecordBs()
> >>> >    {
> >>> >        return recordBService.getList();
> >>> >    }
> >>> >
> >>> >    class RecordARenderer implements IChoiceRenderer<RecordA>
> >>> >    {
> >>> >        private static final long serialVersionUID = 1L;
> >>> >
> >>> >        public Object getDisplayValue(RecordA recordA)
> >>> >        {
> >>> >            return recordA.getName();
> >>> >        }
> >>> >
> >>> >        public String getIdValue(RecordA recordA, int index)
> >>> >        {
> >>> >            return recordA.getName();
> >>> >        }
> >>> >    }
> >>> >
> >>> >    class RecordBRenderer implements IChoiceRenderer<RecordB>
> >>> >    {
> >>> >        private static final long serialVersionUID = 1L;
> >>> >
> >>> >        public Object getDisplayValue(RecordB recordB)
> >>> >        {
> >>> >            return recordB.getName();
> >>> >        }
> >>> >
> >>> >        public String getIdValue(RecordB recordB, int index)
> >>> >        {
> >>> >            return recordB.getName();
> >>> >        }
> >>> >    }
> >>> > }
> >>> >
> >>> > >
> >>> > > Shelli
> >>> > >
> >>> > > -----Original Message-----
> >>> > > From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
> >>> > > Sent: Tuesday, October 12, 2010 10:38 AM
> >>> > > To: users@wicket.apache.org
> >>> > > Subject: Re: PropertyModel Not Refreshing
> >>> > >
> >>> > > here are the tweaks you need to make this work:
> >>> > >
> >>> > > selectedRecordAModel = new PropertyModel<RecordA>(this,
> >>> > "selectedRecordA");
> >>> > >
> >>> > > recordAText = new RequiredTextField("recordAText",
> >>> > >                new PropertyModel(selectedRecordAModel,
"name"));
> >>> > >
> >>> > >  recordBs.setModel(new PropertyModel(selectedRecordAModel,
> >>> "recordB"));
> >>> > >
> >>> > > have fun
> >>> > >
> >>> > > -igor
> >>> > >
> >>> > > On Tue, Oct 12, 2010 at 9:03 AM, Shelli Orton
> <Sh...@sjrb.ca>
> >>> > wrote:
> >>> > >> I've been able to create a sample application that exhibits
the
> >>> > >> same/similar problems to mine.  The sample makes use of an
> >>> in-memory
> >>> > >> list for the data versus accessing a database and so there's
> some
> >>> > >> differences.  However, I believe the problems that this
sample
> >>> exhibits
> >>> > >> have the same root cause as my project (which I believe have
> >>> something
> >>> > >> to do with how my models are set up...).
> >>> > >>
> >>> > >> Issues this sample exhibits:
> >>> > >>
> >>> > >> 1. Choose to edit an existing record, then cancel the edit.
> Choose
> >>> > >> another/the same record to edit and the selected record is
null
> >>> (error
> >>> > >> message "You must select a record to edit" is displayed).
Must
> >>> > >> close/open session to reset.
> >>> > >>
> >>> > >> 2. Choose to edit an existing record and save the edit.
Choose
> >>> > >> another/the same record to edit and you get a NPE:
> >>> > >>
> >>> > >>    WicketMessage: Method onFormSubmitted of interface
> >>> > >> org.apache.wicket.markup.html.form.IFormSubmitListener
targeted
> at
> >>> > >> component [MarkupContainer [Component id = selectForm]] threw
> an
> >>> > >> exception
> >>> > >>
> >>> > >>    Root cause:
> >>> > >>
> >>> > >>    java.lang.NullPointerException
> >>> > >>    at
> >>> > >>
> >>>
>
org.apache.wicket.markup.html.form.AbstractSingleSelectChoice.convertCho
> >>> > >> iceIdToChoice(AbstractSingleSelectChoice.java:247)
> >>> > >>
> >>> > >> 3. Create a new record and try to save it and get
> >>> > >> WicketRuntimeException:
> >>> > >>
> >>> > >>    WicketMessage: Attempted to set property value on a null
> object.
> >>> > >> Property expression: name Value: New One
> >>> > >>
> >>> > >>    Root cause:
> >>> > >>
> >>> > >>    org.apache.wicket.WicketRuntimeException: Attempted to set
> >>> property
> >>> > >> value on a null object. Property expression: name Value: New
> One
> >>> > >>    at
> >>> > >>
> >>>
>
org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.j
> >>> > >> ava:125)
> >>> > >>
> >>> > >> 4. Create a new record and then cancel the add, Choose an
> existing
> >>> > >> record to edit and the selected record is null (error message
> "You
> >>> must
> >>> > >> select a record to edit" is displayed).  Must close/open
> session to
> >>> > >> reset.
> >>> > >>
> >>> > >> As always, all help is greatly appreciated as I am stumped.
> >>> > >>
> >>> > >> Thanks,
> >>> > >> Shelli
> >>> > >>
> >>> > >> -----Original Message-----
> >>> > >> From: jcgarciam [mailto:jcgarciam@gmail.com]
> >>> > >> Sent: Friday, October 08, 2010 1:41 PM
> >>> > >> To: users@wicket.apache.org
> >>> > >> Subject: Re: PropertyModel Not Refreshing
> >>> > >>
> >>> > >>
> >>> > >> The attachment didn't make it,
> >>> > >>
> >>> > >> Can you try to extract out the relevant part and creates a
> >>> quickstart
> >>> > >> project that actually reproduces your issue?
> >>> > >>
> >>> > >>
> >>> > >> On Fri, Oct 8, 2010 at 1:41 PM, Shelli Orton [via Apache
> Wicket] <
> >>> > >>
> >>>
>
ml-node+2968688-305091622-65838@n4.nabble.com<ml-node%2B2968688-30509162
2-65838@n4.nabble.com>
> <ml-node%2B2968688-30509162
> 2-65838@n4.nabble.com>
> >>> <ml-node%2B2968688-30509162
> >>> 2-65838@n4.nabble.com>
> >>> > <ml-node%2B2968688-30509162
> >>> > >> 2-65838@n4.nabble.com>
> >>> > >>> wrote:
> >>> > >>
> >>> > >>> Hi,
> >>> > >>>
> >>> > >>> I have been trying different things to see if I could get my
> code
> >>> to
> >>> > >> work
> >>> > >>> (and understand Wicket models better), but am still stuck.
I
> have
> >>> a
> >>> > >>> attached the (latest) panel class code which I hope is
> sufficient
> >>> to
> >>> > >> help.
> >>> > >>>
> >>> > >>> I was reading about different models (both online and the
> Wicket
> >>> in
> >>> > >> Action
> >>> > >>> book) and thought that perhaps using a CompoundPropertyModel
> was
> >>> more
> >>> > >>> appropriate and may help with my issues.  Originally, I only
> >>> declared
> >>> > >>> selectedRecordA (line 40) but didn't instantiate it.  The
> select
> >>> group
> >>> > >>> displayed properly but when I chose a record from the list
and
> >>> tried
> >>> > >> to edit
> >>> > >>> it, this exception was thrown:
> >>> > >>>
> >>> > >>>     WicketMessage: Attempted to set property value on a null
> >>> object.
> >>> > >>> Property expression: recordA Value: Name=A-One
> >>> > >>>     Root cause:
> >>> > >>>
> >>> > >>>     org.apache.wicket.WicketRuntimeException: Attempted to
set
> >>> > >> property
> >>> > >>> value on a null object. Property expression: recordA Value:
> >>> Name=A-One
> >>> > >>>         at
> >>> > >>>
> >>> > >>
> >>>
>
org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.j
> >>> > >> ava:125)
> >>> > >>>
> >>> > >>>         at
> >>> > >>>
> >>> > >>
> >>>
>
org.apache.wicket.model.AbstractPropertyModel.setObject(AbstractProperty
> >>> > >> Model.java:169)
> >>> > >>>
> >>> > >>>         at
> >>> > >>>
> >>>
> org.apache.wicket.Component.setDefaultModelObject(Component.java:3125)
> >>> > >>>         ....
> >>> > >>>
> >>> > >>> I set breakpoints on the getSelectedRecordA and
> setSelectedRecordA
> >>> > >> methods,
> >>> > >>> but these aren't called when during the request cycle when
the
> >>> edit
> >>> > >> button
> >>> > >>> is clicked.
> >>> > >>>
> >>> > >>> I then changed the class so that selectedRecordA is
> initialized to
> >>> an
> >>> > >> empty
> >>> > >>> instance of RecordA. This got rid of the above error.
> However, I
> >>> > >> cannot
> >>> > >>> save the edit changes because the selectedRecordA is still
the
> >>> empty
> >>> > >>> instance that was created in the initialization and the
> >>> persistence
> >>> > >> layer
> >>> > >>> throws an exception.  This same problem exists if I try to
add
> a
> >>> new
> >>> > >> RecordA
> >>> > >>> or try to delete an existing one.
> >>> > >>>
> >>> > >>> If I choose to cancel the edit and then select another
record
> to
> >>> edit,
> >>> > >> I
> >>> > >>> get the message "You must select a record to edit" (line
131).
> >>> This
> >>> > >> is
> >>> > >>> because the cancel onSubmit sets selectedRecordA to null and
> >>> choosing
> >>> > >> the
> >>> > >>> record from the DDC is not setting it to the chosen record.
> >>> > >>>
> >>> > >>> Clearly I am not setting up this CompoundPropertyModel
> properly so
> >>> > >> that the
> >>> > >>> selectedARecord is set by the model.  Can someone tell me
what
> I'm
> >>> > >> doing
> >>> > >>> wrong?
> >>> > >>>
> >>> > >>> All help is greatly appreciated,
> >>> > >>>
> >>> > >>> Shelli
> >>> > >>>
> >>> > >>>
> >>> > >>> -----Original Message-----
> >>> > >>> From: Igor Vaynberg [mailto:[hidden
> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=0>]
> >>> > >>>
> >>> > >>> Sent: Thursday, October 07, 2010 11:27 AM
> >>> > >>> To: [hidden email]
> >>> > >> <http://user/SendEmail.jtp?type=node&node=2968688&i=1>
> >>> > >>> Subject: Re: PropertyModel Not Refreshing
> >>> > >>>
> >>> > >>> you have posted an incomplete piece of code and somehow from
> that
> >>> we
> >>> > >>> are supposed to guess what is not working? create a
quickstart
> and
> >>> > >>> provide that.
> >>> > >>>
> >>> > >>> -igor
> >>> > >>>
> >>> > >>> On Thu, Oct 7, 2010 at 10:15 AM, Shelli Orton <[hidden
> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=2>>
> >>> > >>> wrote:
> >>> > >>>
> >>> > >>> > Does nobody have any suggestions?  If I can't get this
> fixed,
> >>> I'm
> >>> > >> going
> >>> > >>> > to have to write the app in another framework (possibly
GWT)
> and
> >>> I'd
> >>> > >>> > really rather not have to do that.
> >>> > >>> >
> >>> > >>> > Shelli
> >>> > >>> >
> >>> > >>> > -----Original Message-----
> >>> > >>> > From: Shelli Orton
> >>> > >>> > Sent: Wednesday, October 06, 2010 3:52 PM
> >>> > >>> > To: [hidden
> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=3>
> >>> > >>> > Subject: PropertyModel Not Refreshing
> >>> > >>> >
> >>> > >>> > Hi,
> >>> > >>> >
> >>> > >>> > First, thanks to all who have been helping me as I am new
to
> >>> Wicket.
> >>> > >> I
> >>> > >>> > am splitting out two issues I am dealing with to try to
keep
> >>> things
> >>> > >>> > clear.
> >>> > >>> >
> >>> > >>> > I am trying to write a simple app that does CRUD
operations
> on
> >>> > >> database
> >>> > >>> > records.  The goal is for the app to make use of a tab
panel
> >>> where
> >>> > >> each
> >>> > >>> > tab encapsulates one table from the database.  Each tab
> panel
> >>> has
> >>> > >> two
> >>> > >>> > groups (WebMarkupContainer).  The first, selectGroup,
> displays a
> >>> > >> list
> >>> > >>> > (DDC) of the current items, and three buttons, add, edit
and
> >>> delete.
> >>> > >>> > The second, editGroup, is displayed when either the add or
> edit
> >>> > >> button
> >>> > >>> > was clicked on the select group, displays the record
> attributes
> >>> and
> >>> > >> save
> >>> > >>> > and cancel buttons.  The tab panel has a "selectedRecord"
> which
> >>> is
> >>> > >> used
> >>> > >>> > by both groups' components via PropertyModels. Very basic
> stuff.
> >>> > >>> >
> >>> > >>> > When I choose a record and click the edit button, the
record
> is
> >>> > >>> > displayed in the edit group properly.  If I then choose
> cancel,
> >>> the
> >>> > >> edit
> >>> > >>> > group is no longer displayed and the select group DDC
> selection
> >>> is
> >>> > >> null
> >>> > >>> > as expected. I then choose another record from the list
and
> >>> click
> >>> > >> the
> >>> > >>> > edit button and the previous record information is
displayed
> in
> >>> the
> >>> > >> edit
> >>> > >>> > group even though the select group DDC shows the
> >>> correct/selected
> >>> > >>> > record.
> >>> > >>> >
> >>> > >>> > This problem also occurs if I first choose to add a new
> record
> >>> and
> >>> > >> then
> >>> > >>> > cancel the add and then choose to edit a different record.
> The
> >>> DDC
> >>> > >>> > shows the correct/selected record, but all the attributes
in
> the
> >>> > >> edit
> >>> > >>> > group are null/defaults for a new record.
> >>> > >>> >
> >>> > >>> > If I remove the call to setDefaultFormProcessing(false) on
> the
> >>> > >> cancel
> >>> > >>> > button, selecting other records for edit works correctly,
> but I
> >>> > >> can't
> >>> > >>> > cancel a creating a new record if I use a
RequiredTextField
> >>> because
> >>> > >> the
> >>> > >>> > form validation fails.
> >>> > >>> >
> >>> > >>> > If I select a record for editing or save the newly created
> >>> record, I
> >>> > >> can
> >>> > >>> > select a different record for edit or create another one
> >>> correctly.
> >>> > >> So
> >>> > >>> > I must be doing something wrong in the cancel logic. My
> editForm
> >>> > >>> > (created in the EditGroup constructor) looks like this:
> >>> > >>> >
> >>> > >>> >            Form editForm = new Form("editForm");
> >>> > >>> >
> >>> > >>> >            editForm.add(new Label("nameLabel", "Name"));
> >>> > >>> >
> >>> > >>> >            editForm.add(new Label("attributeLabel",
> >>> "Attribute"));
> >>> > >>> >
> >>> > >>> >            editForm.add(new
> >>> > >> RequiredTextField<String>("recordNameText",
> >>> > >>> >                    new
> PropertyModel<String>(MyRecordPanel.this,
> >>> > >>> >                            "selectedRecord.name")));
> >>> > >>> >
> >>> > >>> >            editForm.add(new
> DropDownChoice<Lir>("attributes",
> >>> > >>> >                    new
> >>> PropertyModel<Attribute>(MyRecordPanel.this,
> >>> > >>> >                            "selectedRecord.attribute"),
> >>> > >>> >                    RateCentrePanel.this.getAttributes(),
> >>> > >>> >                    new AttributeRenderer()));
> >>> > >>> >
> >>> > >>> >            ....
> >>> > >>> >
> >>> > >>> >            editForm.add(new Button("cancel")
> >>> > >>> >            {
> >>> > >>> >                private static final long serialVersionUID
=
> 1L;
> >>> > >>> >
> >>> > >>> >                public void onSubmit()
> >>> > >>> >                {
> >>> > >>> >                    MyRecordPanel.this.selectedRecord =
null;
> >>> > >>> >                    editGroup.setVisible(false);
> >>> > >>> >                    selectGroup.setVisible(true);
> >>> > >>> >                }
> >>> > >>> >            }.setDefaultFormProcessing(false));
> >>> > >>> >
> >>> > >>> >            add(editForm);
> >>> > >>> >
> >>> > >>> > Other than setting the selectedRecord to null, what should
I
> be
> >>> > >> doing
> >>> > >>> > differently?
> >>> > >>> >
> >>> > >>> > Thanks in advance!
> >>> > >>> >
> >>> > >>> > Shelli
> >>> > >>> >
> >>> > >>> >
> >>> > >>
> >>>
> ---------------------------------------------------------------------
> >>> > >>> > To unsubscribe, e-mail: [hidden
> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=4>
> >>> > >>> > For additional commands, e-mail: [hidden
> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=5>
> >>> > >>> >
> >>> > >>> >
> >>> > >>> >
> >>> > >>
> >>>
> ---------------------------------------------------------------------
> >>> > >>> > To unsubscribe, e-mail: [hidden
> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=6>
> >>> > >>> > For additional commands, e-mail: [hidden
> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=7>
> >>> > >>> >
> >>> > >>> >
> >>> > >>>
> >>>
> ---------------------------------------------------------------------
> >>> > >>> To unsubscribe, e-mail: [hidden
> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=8>
> >>> > >>> For additional commands, e-mail: [hidden
> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=9>
> >>> > >>>
> >>> > >>>
> >>> > >>>
> >>> > >>>
> >>> > >>>
> >>>
> ---------------------------------------------------------------------
> >>> > >>> To unsubscribe, e-mail: [hidden
> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=10>
> >>> > >>> For additional commands, e-mail: [hidden
> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=11>
> >>> > >>>
> >>> > >>> ------------------------------
> >>> > >>>  View message @
> >>> > >>>
> >>> > >>
> >>> >
> >>>
>
http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
> >>> > >> n-tp2955144p2968688.html
> >>> > >>> To start a new topic under Apache Wicket, email
> >>> > >>>
> >>> > >>
> >>>
>
ml-node+1842946-398011874-65838@n4.nabble.com<ml-node%2B1842946-39801187
4-65838@n4.nabble.com>
> <ml-node%2B1842946-39801187
> 4-65838@n4.nabble.com>
> >>> <ml-node%2B1842946-39801187
> >>> 4-65838@n4.nabble.com>
> >>> > <ml-node%2B1842946-39801187
> >>> > >> 4-65838@n4.nabble.com>
> >>> > >>> To unsubscribe from Apache Wicket, click
> >>> > >>
> >>>
>
here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp
> >>> > ?
> >>> > >>
> >>>
>
tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
> >>> > >> QyOTQ2fDEyNTYxMzc3ODY=>.
> >>> > >>>
> >>> > >>>
> >>> > >>>
> >>> > >>
> >>> > >>
> >>> > >> --
> >>> > >> Sincerely,
> >>> > >> JC (http://www.linkedin.com/in/jcgarciam)
> >>> > >> Work smarter, not harder!.
> >>> > >>
> >>> > >> --
> >>> > >> View this message in context:
> >>> > >>
> >>> >
> >>>
>
http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
> >>> > >> n-tp2955144p2968936.html
> >>> > >> Sent from the Users forum mailing list archive at Nabble.com.
> >>> > >>
> >>> > >>
> >>>
> ---------------------------------------------------------------------
> >>> > >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >>> > >> For additional commands, e-mail: users-help@wicket.apache.org
> >>> > >>
> >>> > >>
> >>> > >>
> >>> > >>
> >>>
> ---------------------------------------------------------------------
> >>> > >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >>> > >> For additional commands, e-mail: users-help@wicket.apache.org
> >>> > >>
> >>> > >
> >>> > >
> >>>
> ---------------------------------------------------------------------
> >>> > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >>> > > For additional commands, e-mail: users-help@wicket.apache.org
> >>> > >
> >>> > >
> >>> > >
> >>>
> ---------------------------------------------------------------------
> >>> > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >>> > > For additional commands, e-mail: users-help@wicket.apache.org
> >>> > >
> >>> > >
> >>> >
> >>> >
> ---------------------------------------------------------------------
> >>> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >>> > For additional commands, e-mail: users-help@wicket.apache.org
> >>> >
> >>> >
> >>> >
> ---------------------------------------------------------------------
> >>> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >>> > For additional commands, e-mail: users-help@wicket.apache.org
> >>> >
> >>> >
> >>>
> >>>
> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >>> For additional commands, e-mail: users-help@wicket.apache.org
> >>>
> >>>
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: PropertyModel Not Refreshing

Posted by nino martinez wael <ni...@gmail.com>.
yeah I see your point.. But you could always validate latter.. But I agree
it's not the way it's supposed to be. It's like the components on the form
does not update when you press cancel and default form processing are off.

-Nino

2010/10/12 Shelli Orton <Sh...@sjrb.ca>

> I had tried removing that line once before and it does solve the problem
> when cancelling an edit of an existing record, but I can't cancel the
> add of a new one.  Because I'm using a RequiredTextField, I get a
> validation error:
>
>     Field 'recordAText' is required.
>
> Thanks for taking the time to look at this and at least confirming that
> there is an issue (and it's not just in my mind).
>
> Shelli
>
> -----Original Message-----
> From: nino martinez wael [mailto:nino.martinez.wael@gmail.com]
> Sent: Tuesday, October 12, 2010 3:26 PM
> To: users@wicket.apache.org
> Subject: Re: PropertyModel Not Refreshing
>
> going at a hunch I decided to rem out the below:
>
> //        cancel.setDefaultFormProcessing(false);
>
> And seems it fixed the problem.. But im too tired to digg further had a
> similar situation last week.. And the reason was sound.. Just cant
> remember
> it now..
>
> 2010/10/12 nino martinez wael <ni...@gmail.com>
>
> > Think I was going in the wrong direction.. Looking at the error, seems
> to
> > get triggered by pressing the cancel button only..
> >
> >
> > 2010/10/12 Shelli Orton <Sh...@sjrb.ca>
> >
> >> This is where my confusion about models may be kicking in.  I thought
> >> that property models (PropertModel or CompoundPropertyModel)
> >> automatically checked if the model object changed.  How do I tell the
> >> model it has?
> >>
> >> Shelli
> >>
> >> -----Original Message-----
> >> From: nino martinez wael [mailto:nino.martinez.wael@gmail.com]
> >> Sent: Tuesday, October 12, 2010 12:10 PM
> >> To: users@wicket.apache.org
> >> Subject: Re: PropertyModel Not Refreshing
> >>
> >> in your add button you call setSelectedRecordA(new RecordA()) but
> never
> >> notify the model that a change has occured...
> >>
> >> 2010/10/12 nino martinez wael <ni...@gmail.com>
> >>
> >> > hmm getting a lot of errors on the services not implementing
> >> > serialization...
> >> >
> >> > But does seem theres a difference between calling :
> >> >
> >> > selectedRecordAModel.getObject().getName() and
> >> > RecordAPanel.this.selectedRecordA
> >> >
> >> > 2010/10/12 nino martinez wael <ni...@gmail.com>
> >> >
> >> > sorry.. Did'nt see it attached.. So did igor provide you with an
> fixed
> >> >> quickstart (working on his system).. That did not work on
> glassfish?
> >> >>
> >> >>
> >> >> 2010/10/12 Shelli Orton <Sh...@sjrb.ca>
> >> >>
> >> >>> The quickstart was sent to the list this morning at 10:04 MST.
> Does
> >> it
> >> >>> need to be resent?
> >> >>>
> >> >>> Shelli
> >> >>>
> >> >>> -----Original Message-----
> >> >>> From: nino martinez wael [mailto:nino.martinez.wael@gmail.com]
> >> >>> Sent: Tuesday, October 12, 2010 11:52 AM
> >> >>> To: users@wicket.apache.org
> >> >>> Subject: Re: PropertyModel Not Refreshing
> >> >>>
> >> >>> No dont think so.. Please provide a quickstart.. I have had
> property
> >> >>> models
> >> >>> working in 1.2, 1.3, 1.4 and 1.5 so must be error 42:)
> >> >>>
> >> >>> 2010/10/12 Shelli Orton <Sh...@sjrb.ca>
> >> >>>
> >> >>> > Hi,
> >> >>> >
> >> >>> > Thanks for file.  Your first email was missing these changes:
> >> >>> >
> >> >>> >    IModel<RecordA> selectedRecordAModel;  (I had set mine to
> >> >>> > PropertyModel<RecordA> selectedRecordAModel;)
> >> >>> >    recordAs.setModel(selectedRecordAModel)
> >> >>> >
> >> >>> > However, even with those changes applied, I still get the same
> >> issue
> >> >>> of the
> >> >>> > selected record not updating in the edit group.
> >> >>> >
> >> >>> > I am deploying in Glassfish v3.  Could that have anything to do
> >> with
> >> >>> my
> >> >>> > problems?
> >> >>> >
> >> >>> > Shelli
> >> >>> >
> >> >>> > -----Original Message-----
> >> >>> > From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
> >> >>> > Sent: Tuesday, October 12, 2010 11:35 AM
> >> >>> > To: users@wicket.apache.org
> >> >>> > Subject: Re: PropertyModel Not Refreshing
> >> >>> >
> >> >>> > On Tue, Oct 12, 2010 at 10:30 AM, Shelli Orton
> >> <Sh...@sjrb.ca>
> >> >>> > wrote:
> >> >>> > > Thanks for the help.  Your changes got rid of the errors and
> I
> >> can
> >> >>> delete
> >> >>> > records now (and the list is updated).
> >> >>> > >
> >> >>> > > However, once a record has been selected for edit and either
> >> saved
> >> >>> or
> >> >>> > cancelled, that same record is always displayed in the edit
> group
> >> when
> >> >>> I
> >> >>> > choose another record to edit or even when I try to create a
> new
> >> one.
> >> >>> I can
> >> >>> > even delete the chosen record and it still displays in the edit
> >> group.
> >> >>> >
> >> >>> > works fine here, meaning you did not completely/propery apply
> my
> >> >>> > changes. below is the complete file.
> >> >>> >
> >> >>> > -igor
> >> >>> >
> >> >>> > public class RecordAPanel extends Panel
> >> >>> > {
> >> >>> >    private static final long serialVersionUID = 1L;
> >> >>> >
> >> >>> >    RecordAService recordAService;
> >> >>> >    RecordBService recordBService;
> >> >>> >
> >> >>> >    RecordA selectedRecordA = new RecordA();
> >> >>> >    IModel<RecordA> selectedRecordAModel;
> >> >>> >    String unmodifiedRecordA;
> >> >>> >
> >> >>> >    boolean isNew = false;
> >> >>> >
> >> >>> >    WebMarkupContainer selectGroup;
> >> >>> >    WebMarkupContainer editGroup;
> >> >>> >
> >> >>> >    Form selectForm;
> >> >>> >    Form editForm;
> >> >>> >
> >> >>> >    DropDownChoice<RecordA> recordAs;
> >> >>> >    DropDownChoice<RecordB> recordBs;
> >> >>> >
> >> >>> >    Button add;
> >> >>> >    Button edit;
> >> >>> >    Button save;
> >> >>> >    Button delete;
> >> >>> >    Button cancel;
> >> >>> >
> >> >>> >    Label editLegendLabel;
> >> >>> >    String editLegend;
> >> >>> >    Label recordALabel;
> >> >>> >    Label recordBLabel;
> >> >>> >
> >> >>> >    RequiredTextField recordAText;
> >> >>> >
> >> >>> >    @SuppressWarnings({ "rawtypes", "unchecked" })
> >> >>> >    public RecordAPanel(String id)
> >> >>> >    {
> >> >>> >        super(id);
> >> >>> >
> >> >>> >        recordAService = ((Application)
> >> >>> > RequestCycle.get().getApplication()).getRecordAService();
> >> >>> >        recordBService = ((Application)
> >> >>> > RequestCycle.get().getApplication()).getRecordBService();
> >> >>> >
> >> >>> >        selectedRecordAModel = new PropertyModel<RecordA>(this,
> >> >>> > "selectedRecordA");
> >> >>> >        this.setDefaultModel(selectedRecordAModel);
> >> >>> >
> >> >>> >        // ************* Select  Group *************
> >> >>> >
> >> >>> >        selectGroup = new WebMarkupContainer("selectGroup");
> >> >>> >        selectForm = new Form("selectForm");
> >> >>> >
> >> >>> >        recordAs = new DropDownChoice<RecordA>("recordAs");
> >> >>> >        recordAs.setModel(selectedRecordAModel);
> >> >>> >        recordAs.setChoices(recordAsModel);
> >> >>> >        recordAs.setChoiceRenderer(new RecordARenderer());
> >> >>> >
> >> >>> >        //            recordAs = (DropDownChoice<RecordA>) new
> >> >>> > DropDownChoice<RecordA>("recordAs",
> >> >>> >        //                    new PropertyModel<RecordA>(this,
> >> >>> > "selectedRecordA"),
> >> >>> >        //                    recordAsModel,
> >> >>> >        //                    new RecordARenderer());
> >> >>> >
> >> >>> >        recordAs.setNullValid(false);
> >> >>> >
> >> >>> >        selectForm.add(recordAs);
> >> >>> >
> >> >>> >        add = new Button("add")
> >> >>> >        {
> >> >>> >            private static final long serialVersionUID = 1L;
> >> >>> >
> >> >>> >            public void onSubmit()
> >> >>> >            {
> >> >>> >                setSelectedRecordA(new RecordA());
> >> >>> >                isNew = true;
> >> >>> >                editLegend = "New";
> >> >>> >                editGroup.setVisible(true);
> >> >>> >                selectGroup.setVisible(false);
> >> >>> >            }
> >> >>> >        };
> >> >>> >
> >> >>> >        selectForm.add(add);
> >> >>> >
> >> >>> >        edit = new Button("edit")
> >> >>> >        {
> >> >>> >            private static final long serialVersionUID = 1L;
> >> >>> >
> >> >>> >            public void onSubmit()
> >> >>> >            {
> >> >>> >                if (selectedRecordA == null)
> >> >>> >                {
> >> >>> >                    info("You must select a record to edit.");
> >> >>> >                }
> >> >>> >                else
> >> >>> >                {
> >> >>> >                    unmodifiedRecordA =
> selectedRecordA.getName();
> >> >>> >                    isNew = false;
> >> >>> >                    editLegend = "Edit";
> >> >>> >                    editGroup.setVisible(true);
> >> >>> >                    selectGroup.setVisible(false);
> >> >>> >                }
> >> >>> >            }
> >> >>> >        };
> >> >>> >
> >> >>> >        selectForm.add(edit);
> >> >>> >
> >> >>> >        delete = new Button("delete")
> >> >>> >        {
> >> >>> >            private static final long serialVersionUID = 1L;
> >> >>> >
> >> >>> >            public void onSubmit()
> >> >>> >            {
> >> >>> >                if (selectedRecordA == null)
> >> >>> >                {
> >> >>> >                    info("You must select a record to delete.");
> >> >>> >                }
> >> >>> >                else
> >> >>> >                {
> >> >>> >                    // Delete the selected record
> >> >>> >                    unmodifiedRecordA =
> selectedRecordA.getName();
> >> >>> >
> >> recordAService.delete(selectedRecordA.getName());
> >> >>> >                    selectedRecordA = null;
> >> >>> >                    info("Deleted '" + unmodifiedRecordA + "'");
> >> >>> >
> >> >>> >                    // Force refresh of records list
> >> >>> >                    RecordAPanel.this.recordAsModel.detach();
> >> >>> >                }
> >> >>> >            }
> >> >>> >        };
> >> >>> >
> >> >>> >        // Add confirmation dialog box
> >> >>> >        delete.add(new SimpleAttributeModifier("onclick",
> >> >>> >                "if (!confirm('Please confirm you want to delete
> >> this
> >> >>> > record') ){ return false; }"));
> >> >>> >
> >> >>> >        selectForm.add(delete);
> >> >>> >        selectGroup.add(selectForm);
> >> >>> >
> >> >>> >        this.add(selectGroup);
> >> >>> >
> >> >>> >        // ************* Edit Group *************
> >> >>> >
> >> >>> >        editGroup = new WebMarkupContainer("editGroup");
> >> >>> >
> >> >>> >        editLegendLabel = new Label("editLegend", new
> >> >>> PropertyModel(this,
> >> >>> >                "editLegend"));
> >> >>> >
> >> >>> >        editGroup.add(editLegendLabel);
> >> >>> >
> >> >>> >        editForm = new Form("editForm");
> >> >>> >
> >> >>> >        recordALabel = new Label("recordALabel", "Record A");
> >> >>> >        editForm.add(recordALabel);
> >> >>> >
> >> >>> >        recordBLabel = new Label("recordBLabel", "Record B");
> >> >>> >        editForm.add(recordBLabel);
> >> >>> >
> >> >>> >        recordAText = new RequiredTextField("recordAText",
> >> >>> >                new PropertyModel(selectedRecordAModel,
> "name"));
> >> >>> >
> >> >>> >        editForm.add(recordAText);
> >> >>> >
> >> >>> >        recordBs = new DropDownChoice<RecordB>("recordBs");
> >> >>> >        recordBs.setModel(new
> PropertyModel(selectedRecordAModel,
> >> >>> > "recordB"));
> >> >>> >        recordBs.setChoices(RecordAPanel.this.getRecordBs());
> >> >>> >        recordBs.setChoiceRenderer(new RecordBRenderer());
> >> >>> >
> >> >>> >        editForm.add(recordBs);
> >> >>> >
> >> >>> >        save = new Button("save")
> >> >>> >        {
> >> >>> >            private static final long serialVersionUID = 1L;
> >> >>> >
> >> >>> >            @Override
> >> >>> >            public void onSubmit()
> >> >>> >            {
> >> >>> >                if (isNew)
> >> >>> >                {
> >> >>> >
> >> >>> > recordAService.create(RecordAPanel.this.selectedRecordA);
> >> >>> >                        info("Created '"
> >> >>> >                                +
> >> >>> > RecordAPanel.this.selectedRecordA.getName()
> >> >>> >                                + "'");
> >> >>> >                }
> >> >>> >                else
> >> >>> >                {
> >> >>> >                        recordAService.update(unmodifiedRecordA,
> >> >>> >
> RecordAPanel.this.selectedRecordA);
> >> >>> >                        info("Updated '"
> >> >>> >                                +
> >> >>> > RecordAPanel.this.selectedRecordA.getName()
> >> >>> >                                + "'");
> >> >>> >                }
> >> >>> >
> >> >>> >                // TODO Update the dropdown list?
> >> >>> >
> >> >>> >                editGroup.setVisible(false);
> >> >>> >                selectGroup.setVisible(true);
> >> >>> >            }
> >> >>> >        };
> >> >>> >
> >> >>> >        editForm.add(save);
> >> >>> >
> >> >>> >        cancel = new Button("cancel")
> >> >>> >        {
> >> >>> >            private static final long serialVersionUID = 1L;
> >> >>> >
> >> >>> >            public void onSubmit()
> >> >>> >            {
> >> >>> >                RecordAPanel.this.selectedRecordA = null;
> >> >>> >                editGroup.setVisible(false);
> >> >>> >                selectGroup.setVisible(true);
> >> >>> >            }
> >> >>> >        };
> >> >>> >
> >> >>> >        cancel.setDefaultFormProcessing(false);
> >> >>> >        editForm.add(cancel);
> >> >>> >
> >> >>> >        editGroup.add(editForm);
> >> >>> >
> >> >>> >        editGroup.setVisible(false);
> >> >>> >        this.add(editGroup);
> >> >>> >    }
> >> >>> >
> >> >>> >    public RecordA getSelectedRecordA()
> >> >>> >    {
> >> >>> >        return selectedRecordA;
> >> >>> >    }
> >> >>> >
> >> >>> >    public void setSelectedRecordA(RecordA selectedRecordA)
> >> >>> >    {
> >> >>> >        this.selectedRecordA = selectedRecordA;
> >> >>> >    }
> >> >>> >
> >> >>> >    public LoadableDetachableModel<List<RecordA>> recordAsModel
> =
> >> new
> >> >>> > LoadableDetachableModel<List<RecordA>>()
> >> >>> >    {
> >> >>> >        private static final long serialVersionUID = 1L;
> >> >>> >
> >> >>> >        @Override
> >> >>> >        protected List<RecordA> load()
> >> >>> >        {
> >> >>> >            return recordAService.getList();
> >> >>> >        }
> >> >>> >
> >> >>> >        public void detach()
> >> >>> >        {
> >> >>> >            super.detach();
> >> >>> >        }
> >> >>> >    };
> >> >>> >
> >> >>> >    // TODO change this to LDM?
> >> >>> >    List<RecordB> getRecordBs()
> >> >>> >    {
> >> >>> >        return recordBService.getList();
> >> >>> >    }
> >> >>> >
> >> >>> >    class RecordARenderer implements IChoiceRenderer<RecordA>
> >> >>> >    {
> >> >>> >        private static final long serialVersionUID = 1L;
> >> >>> >
> >> >>> >        public Object getDisplayValue(RecordA recordA)
> >> >>> >        {
> >> >>> >            return recordA.getName();
> >> >>> >        }
> >> >>> >
> >> >>> >        public String getIdValue(RecordA recordA, int index)
> >> >>> >        {
> >> >>> >            return recordA.getName();
> >> >>> >        }
> >> >>> >    }
> >> >>> >
> >> >>> >    class RecordBRenderer implements IChoiceRenderer<RecordB>
> >> >>> >    {
> >> >>> >        private static final long serialVersionUID = 1L;
> >> >>> >
> >> >>> >        public Object getDisplayValue(RecordB recordB)
> >> >>> >        {
> >> >>> >            return recordB.getName();
> >> >>> >        }
> >> >>> >
> >> >>> >        public String getIdValue(RecordB recordB, int index)
> >> >>> >        {
> >> >>> >            return recordB.getName();
> >> >>> >        }
> >> >>> >    }
> >> >>> > }
> >> >>> >
> >> >>> > >
> >> >>> > > Shelli
> >> >>> > >
> >> >>> > > -----Original Message-----
> >> >>> > > From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
> >> >>> > > Sent: Tuesday, October 12, 2010 10:38 AM
> >> >>> > > To: users@wicket.apache.org
> >> >>> > > Subject: Re: PropertyModel Not Refreshing
> >> >>> > >
> >> >>> > > here are the tweaks you need to make this work:
> >> >>> > >
> >> >>> > > selectedRecordAModel = new PropertyModel<RecordA>(this,
> >> >>> > "selectedRecordA");
> >> >>> > >
> >> >>> > > recordAText = new RequiredTextField("recordAText",
> >> >>> > >                new PropertyModel(selectedRecordAModel,
> "name"));
> >> >>> > >
> >> >>> > >  recordBs.setModel(new PropertyModel(selectedRecordAModel,
> >> >>> "recordB"));
> >> >>> > >
> >> >>> > > have fun
> >> >>> > >
> >> >>> > > -igor
> >> >>> > >
> >> >>> > > On Tue, Oct 12, 2010 at 9:03 AM, Shelli Orton
> >> <Sh...@sjrb.ca>
> >> >>> > wrote:
> >> >>> > >> I've been able to create a sample application that exhibits
> the
> >> >>> > >> same/similar problems to mine.  The sample makes use of an
> >> >>> in-memory
> >> >>> > >> list for the data versus accessing a database and so there's
> >> some
> >> >>> > >> differences.  However, I believe the problems that this
> sample
> >> >>> exhibits
> >> >>> > >> have the same root cause as my project (which I believe have
> >> >>> something
> >> >>> > >> to do with how my models are set up...).
> >> >>> > >>
> >> >>> > >> Issues this sample exhibits:
> >> >>> > >>
> >> >>> > >> 1. Choose to edit an existing record, then cancel the edit.
> >> Choose
> >> >>> > >> another/the same record to edit and the selected record is
> null
> >> >>> (error
> >> >>> > >> message "You must select a record to edit" is displayed).
> Must
> >> >>> > >> close/open session to reset.
> >> >>> > >>
> >> >>> > >> 2. Choose to edit an existing record and save the edit.
> Choose
> >> >>> > >> another/the same record to edit and you get a NPE:
> >> >>> > >>
> >> >>> > >>    WicketMessage: Method onFormSubmitted of interface
> >> >>> > >> org.apache.wicket.markup.html.form.IFormSubmitListener
> targeted
> >> at
> >> >>> > >> component [MarkupContainer [Component id = selectForm]]
> threw
> >> an
> >> >>> > >> exception
> >> >>> > >>
> >> >>> > >>    Root cause:
> >> >>> > >>
> >> >>> > >>    java.lang.NullPointerException
> >> >>> > >>    at
> >> >>> > >>
> >> >>>
> >>
> org.apache.wicket.markup.html.form.AbstractSingleSelectChoice.convertCho
> >> >>> > >> iceIdToChoice(AbstractSingleSelectChoice.java:247)
> >> >>> > >>
> >> >>> > >> 3. Create a new record and try to save it and get
> >> >>> > >> WicketRuntimeException:
> >> >>> > >>
> >> >>> > >>    WicketMessage: Attempted to set property value on a null
> >> object.
> >> >>> > >> Property expression: name Value: New One
> >> >>> > >>
> >> >>> > >>    Root cause:
> >> >>> > >>
> >> >>> > >>    org.apache.wicket.WicketRuntimeException: Attempted to
> set
> >> >>> property
> >> >>> > >> value on a null object. Property expression: name Value: New
> >> One
> >> >>> > >>    at
> >> >>> > >>
> >> >>>
> >>
> org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.j
> >> >>> > >> ava:125)
> >> >>> > >>
> >> >>> > >> 4. Create a new record and then cancel the add, Choose an
> >> existing
> >> >>> > >> record to edit and the selected record is null (error
> message
> >> "You
> >> >>> must
> >> >>> > >> select a record to edit" is displayed).  Must close/open
> >> session to
> >> >>> > >> reset.
> >> >>> > >>
> >> >>> > >> As always, all help is greatly appreciated as I am stumped.
> >> >>> > >>
> >> >>> > >> Thanks,
> >> >>> > >> Shelli
> >> >>> > >>
> >> >>> > >> -----Original Message-----
> >> >>> > >> From: jcgarciam [mailto:jcgarciam@gmail.com]
> >> >>> > >> Sent: Friday, October 08, 2010 1:41 PM
> >> >>> > >> To: users@wicket.apache.org
> >> >>> > >> Subject: Re: PropertyModel Not Refreshing
> >> >>> > >>
> >> >>> > >>
> >> >>> > >> The attachment didn't make it,
> >> >>> > >>
> >> >>> > >> Can you try to extract out the relevant part and creates a
> >> >>> quickstart
> >> >>> > >> project that actually reproduces your issue?
> >> >>> > >>
> >> >>> > >>
> >> >>> > >> On Fri, Oct 8, 2010 at 1:41 PM, Shelli Orton [via Apache
> >> Wicket] <
> >> >>> > >>
> >> >>>
> >>
> ml-node+2968688-305091622-65838@n4.nabble.com<ml...@n4.nabble.com>
> <ml-node%2B2968688-30509162
> 2-65838@n4.nabble.com>
> >> <ml-node%2B2968688-30509162
> >> 2-65838@n4.nabble.com>
> >> >>> <ml-node%2B2968688-30509162
> >> >>> 2-65838@n4.nabble.com>
> >> >>> > <ml-node%2B2968688-30509162
> >> >>> > >> 2-65838@n4.nabble.com>
> >> >>> > >>> wrote:
> >> >>> > >>
> >> >>> > >>> Hi,
> >> >>> > >>>
> >> >>> > >>> I have been trying different things to see if I could get
> my
> >> code
> >> >>> to
> >> >>> > >> work
> >> >>> > >>> (and understand Wicket models better), but am still stuck.
> I
> >> have
> >> >>> a
> >> >>> > >>> attached the (latest) panel class code which I hope is
> >> sufficient
> >> >>> to
> >> >>> > >> help.
> >> >>> > >>>
> >> >>> > >>> I was reading about different models (both online and the
> >> Wicket
> >> >>> in
> >> >>> > >> Action
> >> >>> > >>> book) and thought that perhaps using a
> CompoundPropertyModel
> >> was
> >> >>> more
> >> >>> > >>> appropriate and may help with my issues.  Originally, I
> only
> >> >>> declared
> >> >>> > >>> selectedRecordA (line 40) but didn't instantiate it.  The
> >> select
> >> >>> group
> >> >>> > >>> displayed properly but when I chose a record from the list
> and
> >> >>> tried
> >> >>> > >> to edit
> >> >>> > >>> it, this exception was thrown:
> >> >>> > >>>
> >> >>> > >>>     WicketMessage: Attempted to set property value on a
> null
> >> >>> object.
> >> >>> > >>> Property expression: recordA Value: Name=A-One
> >> >>> > >>>     Root cause:
> >> >>> > >>>
> >> >>> > >>>     org.apache.wicket.WicketRuntimeException: Attempted to
> set
> >> >>> > >> property
> >> >>> > >>> value on a null object. Property expression: recordA Value:
> >> >>> Name=A-One
> >> >>> > >>>         at
> >> >>> > >>>
> >> >>> > >>
> >> >>>
> >>
> org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.j
> >> >>> > >> ava:125)
> >> >>> > >>>
> >> >>> > >>>         at
> >> >>> > >>>
> >> >>> > >>
> >> >>>
> >>
> org.apache.wicket.model.AbstractPropertyModel.setObject(AbstractProperty
> >> >>> > >> Model.java:169)
> >> >>> > >>>
> >> >>> > >>>         at
> >> >>> > >>>
> >> >>>
> >>
> org.apache.wicket.Component.setDefaultModelObject(Component.java:3125)
> >> >>> > >>>         ....
> >> >>> > >>>
> >> >>> > >>> I set breakpoints on the getSelectedRecordA and
> >> setSelectedRecordA
> >> >>> > >> methods,
> >> >>> > >>> but these aren't called when during the request cycle when
> the
> >> >>> edit
> >> >>> > >> button
> >> >>> > >>> is clicked.
> >> >>> > >>>
> >> >>> > >>> I then changed the class so that selectedRecordA is
> >> initialized to
> >> >>> an
> >> >>> > >> empty
> >> >>> > >>> instance of RecordA. This got rid of the above error.
> >> However, I
> >> >>> > >> cannot
> >> >>> > >>> save the edit changes because the selectedRecordA is still
> the
> >> >>> empty
> >> >>> > >>> instance that was created in the initialization and the
> >> >>> persistence
> >> >>> > >> layer
> >> >>> > >>> throws an exception.  This same problem exists if I try to
> add
> >> a
> >> >>> new
> >> >>> > >> RecordA
> >> >>> > >>> or try to delete an existing one.
> >> >>> > >>>
> >> >>> > >>> If I choose to cancel the edit and then select another
> record
> >> to
> >> >>> edit,
> >> >>> > >> I
> >> >>> > >>> get the message "You must select a record to edit" (line
> 131).
> >> >>> This
> >> >>> > >> is
> >> >>> > >>> because the cancel onSubmit sets selectedRecordA to null
> and
> >> >>> choosing
> >> >>> > >> the
> >> >>> > >>> record from the DDC is not setting it to the chosen record.
> >> >>> > >>>
> >> >>> > >>> Clearly I am not setting up this CompoundPropertyModel
> >> properly so
> >> >>> > >> that the
> >> >>> > >>> selectedARecord is set by the model.  Can someone tell me
> what
> >> I'm
> >> >>> > >> doing
> >> >>> > >>> wrong?
> >> >>> > >>>
> >> >>> > >>> All help is greatly appreciated,
> >> >>> > >>>
> >> >>> > >>> Shelli
> >> >>> > >>>
> >> >>> > >>>
> >> >>> > >>> -----Original Message-----
> >> >>> > >>> From: Igor Vaynberg [mailto:[hidden
> >> >>> > >>
> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=0>]
> >> >>> > >>>
> >> >>> > >>> Sent: Thursday, October 07, 2010 11:27 AM
> >> >>> > >>> To: [hidden email]
> >> >>> > >> <http://user/SendEmail.jtp?type=node&node=2968688&i=1>
> >> >>> > >>> Subject: Re: PropertyModel Not Refreshing
> >> >>> > >>>
> >> >>> > >>> you have posted an incomplete piece of code and somehow
> from
> >> that
> >> >>> we
> >> >>> > >>> are supposed to guess what is not working? create a
> quickstart
> >> and
> >> >>> > >>> provide that.
> >> >>> > >>>
> >> >>> > >>> -igor
> >> >>> > >>>
> >> >>> > >>> On Thu, Oct 7, 2010 at 10:15 AM, Shelli Orton <[hidden
> >> >>> > >>
> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=2>>
> >> >>> > >>> wrote:
> >> >>> > >>>
> >> >>> > >>> > Does nobody have any suggestions?  If I can't get this
> >> fixed,
> >> >>> I'm
> >> >>> > >> going
> >> >>> > >>> > to have to write the app in another framework (possibly
> GWT)
> >> and
> >> >>> I'd
> >> >>> > >>> > really rather not have to do that.
> >> >>> > >>> >
> >> >>> > >>> > Shelli
> >> >>> > >>> >
> >> >>> > >>> > -----Original Message-----
> >> >>> > >>> > From: Shelli Orton
> >> >>> > >>> > Sent: Wednesday, October 06, 2010 3:52 PM
> >> >>> > >>> > To: [hidden
> >> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=3>
> >> >>> > >>> > Subject: PropertyModel Not Refreshing
> >> >>> > >>> >
> >> >>> > >>> > Hi,
> >> >>> > >>> >
> >> >>> > >>> > First, thanks to all who have been helping me as I am new
> to
> >> >>> Wicket.
> >> >>> > >> I
> >> >>> > >>> > am splitting out two issues I am dealing with to try to
> keep
> >> >>> things
> >> >>> > >>> > clear.
> >> >>> > >>> >
> >> >>> > >>> > I am trying to write a simple app that does CRUD
> operations
> >> on
> >> >>> > >> database
> >> >>> > >>> > records.  The goal is for the app to make use of a tab
> panel
> >> >>> where
> >> >>> > >> each
> >> >>> > >>> > tab encapsulates one table from the database.  Each tab
> >> panel
> >> >>> has
> >> >>> > >> two
> >> >>> > >>> > groups (WebMarkupContainer).  The first, selectGroup,
> >> displays a
> >> >>> > >> list
> >> >>> > >>> > (DDC) of the current items, and three buttons, add, edit
> and
> >> >>> delete.
> >> >>> > >>> > The second, editGroup, is displayed when either the add
> or
> >> edit
> >> >>> > >> button
> >> >>> > >>> > was clicked on the select group, displays the record
> >> attributes
> >> >>> and
> >> >>> > >> save
> >> >>> > >>> > and cancel buttons.  The tab panel has a "selectedRecord"
> >> which
> >> >>> is
> >> >>> > >> used
> >> >>> > >>> > by both groups' components via PropertyModels. Very basic
> >> stuff.
> >> >>> > >>> >
> >> >>> > >>> > When I choose a record and click the edit button, the
> record
> >> is
> >> >>> > >>> > displayed in the edit group properly.  If I then choose
> >> cancel,
> >> >>> the
> >> >>> > >> edit
> >> >>> > >>> > group is no longer displayed and the select group DDC
> >> selection
> >> >>> is
> >> >>> > >> null
> >> >>> > >>> > as expected. I then choose another record from the list
> and
> >> >>> click
> >> >>> > >> the
> >> >>> > >>> > edit button and the previous record information is
> displayed
> >> in
> >> >>> the
> >> >>> > >> edit
> >> >>> > >>> > group even though the select group DDC shows the
> >> >>> correct/selected
> >> >>> > >>> > record.
> >> >>> > >>> >
> >> >>> > >>> > This problem also occurs if I first choose to add a new
> >> record
> >> >>> and
> >> >>> > >> then
> >> >>> > >>> > cancel the add and then choose to edit a different
> record.
> >> The
> >> >>> DDC
> >> >>> > >>> > shows the correct/selected record, but all the attributes
> in
> >> the
> >> >>> > >> edit
> >> >>> > >>> > group are null/defaults for a new record.
> >> >>> > >>> >
> >> >>> > >>> > If I remove the call to setDefaultFormProcessing(false)
> on
> >> the
> >> >>> > >> cancel
> >> >>> > >>> > button, selecting other records for edit works correctly,
> >> but I
> >> >>> > >> can't
> >> >>> > >>> > cancel a creating a new record if I use a
> RequiredTextField
> >> >>> because
> >> >>> > >> the
> >> >>> > >>> > form validation fails.
> >> >>> > >>> >
> >> >>> > >>> > If I select a record for editing or save the newly
> created
> >> >>> record, I
> >> >>> > >> can
> >> >>> > >>> > select a different record for edit or create another one
> >> >>> correctly.
> >> >>> > >> So
> >> >>> > >>> > I must be doing something wrong in the cancel logic. My
> >> editForm
> >> >>> > >>> > (created in the EditGroup constructor) looks like this:
> >> >>> > >>> >
> >> >>> > >>> >            Form editForm = new Form("editForm");
> >> >>> > >>> >
> >> >>> > >>> >            editForm.add(new Label("nameLabel", "Name"));
> >> >>> > >>> >
> >> >>> > >>> >            editForm.add(new Label("attributeLabel",
> >> >>> "Attribute"));
> >> >>> > >>> >
> >> >>> > >>> >            editForm.add(new
> >> >>> > >> RequiredTextField<String>("recordNameText",
> >> >>> > >>> >                    new
> >> PropertyModel<String>(MyRecordPanel.this,
> >> >>> > >>> >                            "selectedRecord.name")));
> >> >>> > >>> >
> >> >>> > >>> >            editForm.add(new
> >> DropDownChoice<Lir>("attributes",
> >> >>> > >>> >                    new
> >> >>> PropertyModel<Attribute>(MyRecordPanel.this,
> >> >>> > >>> >                            "selectedRecord.attribute"),
> >> >>> > >>> >                    RateCentrePanel.this.getAttributes(),
> >> >>> > >>> >                    new AttributeRenderer()));
> >> >>> > >>> >
> >> >>> > >>> >            ....
> >> >>> > >>> >
> >> >>> > >>> >            editForm.add(new Button("cancel")
> >> >>> > >>> >            {
> >> >>> > >>> >                private static final long serialVersionUID
> =
> >> 1L;
> >> >>> > >>> >
> >> >>> > >>> >                public void onSubmit()
> >> >>> > >>> >                {
> >> >>> > >>> >                    MyRecordPanel.this.selectedRecord =
> null;
> >> >>> > >>> >                    editGroup.setVisible(false);
> >> >>> > >>> >                    selectGroup.setVisible(true);
> >> >>> > >>> >                }
> >> >>> > >>> >            }.setDefaultFormProcessing(false));
> >> >>> > >>> >
> >> >>> > >>> >            add(editForm);
> >> >>> > >>> >
> >> >>> > >>> > Other than setting the selectedRecord to null, what
> should I
> >> be
> >> >>> > >> doing
> >> >>> > >>> > differently?
> >> >>> > >>> >
> >> >>> > >>> > Thanks in advance!
> >> >>> > >>> >
> >> >>> > >>> > Shelli
> >> >>> > >>> >
> >> >>> > >>> >
> >> >>> > >>
> >> >>>
> >> ---------------------------------------------------------------------
> >> >>> > >>> > To unsubscribe, e-mail: [hidden
> >> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=4>
> >> >>> > >>> > For additional commands, e-mail: [hidden
> >> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=5>
> >> >>> > >>> >
> >> >>> > >>> >
> >> >>> > >>> >
> >> >>> > >>
> >> >>>
> >> ---------------------------------------------------------------------
> >> >>> > >>> > To unsubscribe, e-mail: [hidden
> >> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=6>
> >> >>> > >>> > For additional commands, e-mail: [hidden
> >> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=7>
> >> >>> > >>> >
> >> >>> > >>> >
> >> >>> > >>>
> >> >>>
> >> ---------------------------------------------------------------------
> >> >>> > >>> To unsubscribe, e-mail: [hidden
> >> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=8>
> >> >>> > >>> For additional commands, e-mail: [hidden
> >> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=9>
> >> >>> > >>>
> >> >>> > >>>
> >> >>> > >>>
> >> >>> > >>>
> >> >>> > >>>
> >> >>>
> >> ---------------------------------------------------------------------
> >> >>> > >>> To unsubscribe, e-mail: [hidden
> >> >>> > >>
> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=10>
> >> >>> > >>> For additional commands, e-mail: [hidden
> >> >>> > >>
> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=11>
> >> >>> > >>>
> >> >>> > >>> ------------------------------
> >> >>> > >>>  View message @
> >> >>> > >>>
> >> >>> > >>
> >> >>> >
> >> >>>
> >>
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
> >> >>> > >> n-tp2955144p2968688.html
> >> >>> > >>> To start a new topic under Apache Wicket, email
> >> >>> > >>>
> >> >>> > >>
> >> >>>
> >>
> ml-node+1842946-398011874-65838@n4.nabble.com<ml...@n4.nabble.com>
> <ml-node%2B1842946-39801187
> 4-65838@n4.nabble.com>
> >> <ml-node%2B1842946-39801187
> >> 4-65838@n4.nabble.com>
> >> >>> <ml-node%2B1842946-39801187
> >> >>> 4-65838@n4.nabble.com>
> >> >>> > <ml-node%2B1842946-39801187
> >> >>> > >> 4-65838@n4.nabble.com>
> >> >>> > >>> To unsubscribe from Apache Wicket, click
> >> >>> > >>
> >> >>>
> >>
> here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp
> >> >>> > ?
> >> >>> > >>
> >> >>>
> >>
> tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
> >> >>> > >> QyOTQ2fDEyNTYxMzc3ODY=>.
> >> >>> > >>>
> >> >>> > >>>
> >> >>> > >>>
> >> >>> > >>
> >> >>> > >>
> >> >>> > >> --
> >> >>> > >> Sincerely,
> >> >>> > >> JC (http://www.linkedin.com/in/jcgarciam)
> >> >>> > >> Work smarter, not harder!.
> >> >>> > >>
> >> >>> > >> --
> >> >>> > >> View this message in context:
> >> >>> > >>
> >> >>> >
> >> >>>
> >>
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
> >> >>> > >> n-tp2955144p2968936.html
> >> >>> > >> Sent from the Users forum mailing list archive at
> Nabble.com.
> >> >>> > >>
> >> >>> > >>
> >> >>>
> >> ---------------------------------------------------------------------
> >> >>> > >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> >>> > >> For additional commands, e-mail:
> users-help@wicket.apache.org
> >> >>> > >>
> >> >>> > >>
> >> >>> > >>
> >> >>> > >>
> >> >>>
> >> ---------------------------------------------------------------------
> >> >>> > >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> >>> > >> For additional commands, e-mail:
> users-help@wicket.apache.org
> >> >>> > >>
> >> >>> > >
> >> >>> > >
> >> >>>
> >> ---------------------------------------------------------------------
> >> >>> > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> >>> > > For additional commands, e-mail: users-help@wicket.apache.org
> >> >>> > >
> >> >>> > >
> >> >>> > >
> >> >>>
> >> ---------------------------------------------------------------------
> >> >>> > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> >>> > > For additional commands, e-mail: users-help@wicket.apache.org
> >> >>> > >
> >> >>> > >
> >> >>> >
> >> >>> >
> >> ---------------------------------------------------------------------
> >> >>> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> >>> > For additional commands, e-mail: users-help@wicket.apache.org
> >> >>> >
> >> >>> >
> >> >>> >
> >> ---------------------------------------------------------------------
> >> >>> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> >>> > For additional commands, e-mail: users-help@wicket.apache.org
> >> >>> >
> >> >>> >
> >> >>>
> >> >>>
> >> ---------------------------------------------------------------------
> >> >>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> >>> For additional commands, e-mail: users-help@wicket.apache.org
> >> >>>
> >> >>>
> >> >>
> >> >
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

RE: PropertyModel Not Refreshing

Posted by Shelli Orton <Sh...@sjrb.ca>.
I had tried removing that line once before and it does solve the problem
when cancelling an edit of an existing record, but I can't cancel the
add of a new one.  Because I'm using a RequiredTextField, I get a
validation error:

     Field 'recordAText' is required.

Thanks for taking the time to look at this and at least confirming that
there is an issue (and it's not just in my mind).

Shelli

-----Original Message-----
From: nino martinez wael [mailto:nino.martinez.wael@gmail.com] 
Sent: Tuesday, October 12, 2010 3:26 PM
To: users@wicket.apache.org
Subject: Re: PropertyModel Not Refreshing

going at a hunch I decided to rem out the below:

//        cancel.setDefaultFormProcessing(false);

And seems it fixed the problem.. But im too tired to digg further had a
similar situation last week.. And the reason was sound.. Just cant
remember
it now..

2010/10/12 nino martinez wael <ni...@gmail.com>

> Think I was going in the wrong direction.. Looking at the error, seems
to
> get triggered by pressing the cancel button only..
>
>
> 2010/10/12 Shelli Orton <Sh...@sjrb.ca>
>
>> This is where my confusion about models may be kicking in.  I thought
>> that property models (PropertModel or CompoundPropertyModel)
>> automatically checked if the model object changed.  How do I tell the
>> model it has?
>>
>> Shelli
>>
>> -----Original Message-----
>> From: nino martinez wael [mailto:nino.martinez.wael@gmail.com]
>> Sent: Tuesday, October 12, 2010 12:10 PM
>> To: users@wicket.apache.org
>> Subject: Re: PropertyModel Not Refreshing
>>
>> in your add button you call setSelectedRecordA(new RecordA()) but
never
>> notify the model that a change has occured...
>>
>> 2010/10/12 nino martinez wael <ni...@gmail.com>
>>
>> > hmm getting a lot of errors on the services not implementing
>> > serialization...
>> >
>> > But does seem theres a difference between calling :
>> >
>> > selectedRecordAModel.getObject().getName() and
>> > RecordAPanel.this.selectedRecordA
>> >
>> > 2010/10/12 nino martinez wael <ni...@gmail.com>
>> >
>> > sorry.. Did'nt see it attached.. So did igor provide you with an
fixed
>> >> quickstart (working on his system).. That did not work on
glassfish?
>> >>
>> >>
>> >> 2010/10/12 Shelli Orton <Sh...@sjrb.ca>
>> >>
>> >>> The quickstart was sent to the list this morning at 10:04 MST.
Does
>> it
>> >>> need to be resent?
>> >>>
>> >>> Shelli
>> >>>
>> >>> -----Original Message-----
>> >>> From: nino martinez wael [mailto:nino.martinez.wael@gmail.com]
>> >>> Sent: Tuesday, October 12, 2010 11:52 AM
>> >>> To: users@wicket.apache.org
>> >>> Subject: Re: PropertyModel Not Refreshing
>> >>>
>> >>> No dont think so.. Please provide a quickstart.. I have had
property
>> >>> models
>> >>> working in 1.2, 1.3, 1.4 and 1.5 so must be error 42:)
>> >>>
>> >>> 2010/10/12 Shelli Orton <Sh...@sjrb.ca>
>> >>>
>> >>> > Hi,
>> >>> >
>> >>> > Thanks for file.  Your first email was missing these changes:
>> >>> >
>> >>> >    IModel<RecordA> selectedRecordAModel;  (I had set mine to
>> >>> > PropertyModel<RecordA> selectedRecordAModel;)
>> >>> >    recordAs.setModel(selectedRecordAModel)
>> >>> >
>> >>> > However, even with those changes applied, I still get the same
>> issue
>> >>> of the
>> >>> > selected record not updating in the edit group.
>> >>> >
>> >>> > I am deploying in Glassfish v3.  Could that have anything to do
>> with
>> >>> my
>> >>> > problems?
>> >>> >
>> >>> > Shelli
>> >>> >
>> >>> > -----Original Message-----
>> >>> > From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
>> >>> > Sent: Tuesday, October 12, 2010 11:35 AM
>> >>> > To: users@wicket.apache.org
>> >>> > Subject: Re: PropertyModel Not Refreshing
>> >>> >
>> >>> > On Tue, Oct 12, 2010 at 10:30 AM, Shelli Orton
>> <Sh...@sjrb.ca>
>> >>> > wrote:
>> >>> > > Thanks for the help.  Your changes got rid of the errors and
I
>> can
>> >>> delete
>> >>> > records now (and the list is updated).
>> >>> > >
>> >>> > > However, once a record has been selected for edit and either
>> saved
>> >>> or
>> >>> > cancelled, that same record is always displayed in the edit
group
>> when
>> >>> I
>> >>> > choose another record to edit or even when I try to create a
new
>> one.
>> >>> I can
>> >>> > even delete the chosen record and it still displays in the edit
>> group.
>> >>> >
>> >>> > works fine here, meaning you did not completely/propery apply
my
>> >>> > changes. below is the complete file.
>> >>> >
>> >>> > -igor
>> >>> >
>> >>> > public class RecordAPanel extends Panel
>> >>> > {
>> >>> >    private static final long serialVersionUID = 1L;
>> >>> >
>> >>> >    RecordAService recordAService;
>> >>> >    RecordBService recordBService;
>> >>> >
>> >>> >    RecordA selectedRecordA = new RecordA();
>> >>> >    IModel<RecordA> selectedRecordAModel;
>> >>> >    String unmodifiedRecordA;
>> >>> >
>> >>> >    boolean isNew = false;
>> >>> >
>> >>> >    WebMarkupContainer selectGroup;
>> >>> >    WebMarkupContainer editGroup;
>> >>> >
>> >>> >    Form selectForm;
>> >>> >    Form editForm;
>> >>> >
>> >>> >    DropDownChoice<RecordA> recordAs;
>> >>> >    DropDownChoice<RecordB> recordBs;
>> >>> >
>> >>> >    Button add;
>> >>> >    Button edit;
>> >>> >    Button save;
>> >>> >    Button delete;
>> >>> >    Button cancel;
>> >>> >
>> >>> >    Label editLegendLabel;
>> >>> >    String editLegend;
>> >>> >    Label recordALabel;
>> >>> >    Label recordBLabel;
>> >>> >
>> >>> >    RequiredTextField recordAText;
>> >>> >
>> >>> >    @SuppressWarnings({ "rawtypes", "unchecked" })
>> >>> >    public RecordAPanel(String id)
>> >>> >    {
>> >>> >        super(id);
>> >>> >
>> >>> >        recordAService = ((Application)
>> >>> > RequestCycle.get().getApplication()).getRecordAService();
>> >>> >        recordBService = ((Application)
>> >>> > RequestCycle.get().getApplication()).getRecordBService();
>> >>> >
>> >>> >        selectedRecordAModel = new PropertyModel<RecordA>(this,
>> >>> > "selectedRecordA");
>> >>> >        this.setDefaultModel(selectedRecordAModel);
>> >>> >
>> >>> >        // ************* Select  Group *************
>> >>> >
>> >>> >        selectGroup = new WebMarkupContainer("selectGroup");
>> >>> >        selectForm = new Form("selectForm");
>> >>> >
>> >>> >        recordAs = new DropDownChoice<RecordA>("recordAs");
>> >>> >        recordAs.setModel(selectedRecordAModel);
>> >>> >        recordAs.setChoices(recordAsModel);
>> >>> >        recordAs.setChoiceRenderer(new RecordARenderer());
>> >>> >
>> >>> >        //            recordAs = (DropDownChoice<RecordA>) new
>> >>> > DropDownChoice<RecordA>("recordAs",
>> >>> >        //                    new PropertyModel<RecordA>(this,
>> >>> > "selectedRecordA"),
>> >>> >        //                    recordAsModel,
>> >>> >        //                    new RecordARenderer());
>> >>> >
>> >>> >        recordAs.setNullValid(false);
>> >>> >
>> >>> >        selectForm.add(recordAs);
>> >>> >
>> >>> >        add = new Button("add")
>> >>> >        {
>> >>> >            private static final long serialVersionUID = 1L;
>> >>> >
>> >>> >            public void onSubmit()
>> >>> >            {
>> >>> >                setSelectedRecordA(new RecordA());
>> >>> >                isNew = true;
>> >>> >                editLegend = "New";
>> >>> >                editGroup.setVisible(true);
>> >>> >                selectGroup.setVisible(false);
>> >>> >            }
>> >>> >        };
>> >>> >
>> >>> >        selectForm.add(add);
>> >>> >
>> >>> >        edit = new Button("edit")
>> >>> >        {
>> >>> >            private static final long serialVersionUID = 1L;
>> >>> >
>> >>> >            public void onSubmit()
>> >>> >            {
>> >>> >                if (selectedRecordA == null)
>> >>> >                {
>> >>> >                    info("You must select a record to edit.");
>> >>> >                }
>> >>> >                else
>> >>> >                {
>> >>> >                    unmodifiedRecordA =
selectedRecordA.getName();
>> >>> >                    isNew = false;
>> >>> >                    editLegend = "Edit";
>> >>> >                    editGroup.setVisible(true);
>> >>> >                    selectGroup.setVisible(false);
>> >>> >                }
>> >>> >            }
>> >>> >        };
>> >>> >
>> >>> >        selectForm.add(edit);
>> >>> >
>> >>> >        delete = new Button("delete")
>> >>> >        {
>> >>> >            private static final long serialVersionUID = 1L;
>> >>> >
>> >>> >            public void onSubmit()
>> >>> >            {
>> >>> >                if (selectedRecordA == null)
>> >>> >                {
>> >>> >                    info("You must select a record to delete.");
>> >>> >                }
>> >>> >                else
>> >>> >                {
>> >>> >                    // Delete the selected record
>> >>> >                    unmodifiedRecordA =
selectedRecordA.getName();
>> >>> >
>> recordAService.delete(selectedRecordA.getName());
>> >>> >                    selectedRecordA = null;
>> >>> >                    info("Deleted '" + unmodifiedRecordA + "'");
>> >>> >
>> >>> >                    // Force refresh of records list
>> >>> >                    RecordAPanel.this.recordAsModel.detach();
>> >>> >                }
>> >>> >            }
>> >>> >        };
>> >>> >
>> >>> >        // Add confirmation dialog box
>> >>> >        delete.add(new SimpleAttributeModifier("onclick",
>> >>> >                "if (!confirm('Please confirm you want to delete
>> this
>> >>> > record') ){ return false; }"));
>> >>> >
>> >>> >        selectForm.add(delete);
>> >>> >        selectGroup.add(selectForm);
>> >>> >
>> >>> >        this.add(selectGroup);
>> >>> >
>> >>> >        // ************* Edit Group *************
>> >>> >
>> >>> >        editGroup = new WebMarkupContainer("editGroup");
>> >>> >
>> >>> >        editLegendLabel = new Label("editLegend", new
>> >>> PropertyModel(this,
>> >>> >                "editLegend"));
>> >>> >
>> >>> >        editGroup.add(editLegendLabel);
>> >>> >
>> >>> >        editForm = new Form("editForm");
>> >>> >
>> >>> >        recordALabel = new Label("recordALabel", "Record A");
>> >>> >        editForm.add(recordALabel);
>> >>> >
>> >>> >        recordBLabel = new Label("recordBLabel", "Record B");
>> >>> >        editForm.add(recordBLabel);
>> >>> >
>> >>> >        recordAText = new RequiredTextField("recordAText",
>> >>> >                new PropertyModel(selectedRecordAModel,
"name"));
>> >>> >
>> >>> >        editForm.add(recordAText);
>> >>> >
>> >>> >        recordBs = new DropDownChoice<RecordB>("recordBs");
>> >>> >        recordBs.setModel(new
PropertyModel(selectedRecordAModel,
>> >>> > "recordB"));
>> >>> >        recordBs.setChoices(RecordAPanel.this.getRecordBs());
>> >>> >        recordBs.setChoiceRenderer(new RecordBRenderer());
>> >>> >
>> >>> >        editForm.add(recordBs);
>> >>> >
>> >>> >        save = new Button("save")
>> >>> >        {
>> >>> >            private static final long serialVersionUID = 1L;
>> >>> >
>> >>> >            @Override
>> >>> >            public void onSubmit()
>> >>> >            {
>> >>> >                if (isNew)
>> >>> >                {
>> >>> >
>> >>> > recordAService.create(RecordAPanel.this.selectedRecordA);
>> >>> >                        info("Created '"
>> >>> >                                +
>> >>> > RecordAPanel.this.selectedRecordA.getName()
>> >>> >                                + "'");
>> >>> >                }
>> >>> >                else
>> >>> >                {
>> >>> >                        recordAService.update(unmodifiedRecordA,
>> >>> >
RecordAPanel.this.selectedRecordA);
>> >>> >                        info("Updated '"
>> >>> >                                +
>> >>> > RecordAPanel.this.selectedRecordA.getName()
>> >>> >                                + "'");
>> >>> >                }
>> >>> >
>> >>> >                // TODO Update the dropdown list?
>> >>> >
>> >>> >                editGroup.setVisible(false);
>> >>> >                selectGroup.setVisible(true);
>> >>> >            }
>> >>> >        };
>> >>> >
>> >>> >        editForm.add(save);
>> >>> >
>> >>> >        cancel = new Button("cancel")
>> >>> >        {
>> >>> >            private static final long serialVersionUID = 1L;
>> >>> >
>> >>> >            public void onSubmit()
>> >>> >            {
>> >>> >                RecordAPanel.this.selectedRecordA = null;
>> >>> >                editGroup.setVisible(false);
>> >>> >                selectGroup.setVisible(true);
>> >>> >            }
>> >>> >        };
>> >>> >
>> >>> >        cancel.setDefaultFormProcessing(false);
>> >>> >        editForm.add(cancel);
>> >>> >
>> >>> >        editGroup.add(editForm);
>> >>> >
>> >>> >        editGroup.setVisible(false);
>> >>> >        this.add(editGroup);
>> >>> >    }
>> >>> >
>> >>> >    public RecordA getSelectedRecordA()
>> >>> >    {
>> >>> >        return selectedRecordA;
>> >>> >    }
>> >>> >
>> >>> >    public void setSelectedRecordA(RecordA selectedRecordA)
>> >>> >    {
>> >>> >        this.selectedRecordA = selectedRecordA;
>> >>> >    }
>> >>> >
>> >>> >    public LoadableDetachableModel<List<RecordA>> recordAsModel
=
>> new
>> >>> > LoadableDetachableModel<List<RecordA>>()
>> >>> >    {
>> >>> >        private static final long serialVersionUID = 1L;
>> >>> >
>> >>> >        @Override
>> >>> >        protected List<RecordA> load()
>> >>> >        {
>> >>> >            return recordAService.getList();
>> >>> >        }
>> >>> >
>> >>> >        public void detach()
>> >>> >        {
>> >>> >            super.detach();
>> >>> >        }
>> >>> >    };
>> >>> >
>> >>> >    // TODO change this to LDM?
>> >>> >    List<RecordB> getRecordBs()
>> >>> >    {
>> >>> >        return recordBService.getList();
>> >>> >    }
>> >>> >
>> >>> >    class RecordARenderer implements IChoiceRenderer<RecordA>
>> >>> >    {
>> >>> >        private static final long serialVersionUID = 1L;
>> >>> >
>> >>> >        public Object getDisplayValue(RecordA recordA)
>> >>> >        {
>> >>> >            return recordA.getName();
>> >>> >        }
>> >>> >
>> >>> >        public String getIdValue(RecordA recordA, int index)
>> >>> >        {
>> >>> >            return recordA.getName();
>> >>> >        }
>> >>> >    }
>> >>> >
>> >>> >    class RecordBRenderer implements IChoiceRenderer<RecordB>
>> >>> >    {
>> >>> >        private static final long serialVersionUID = 1L;
>> >>> >
>> >>> >        public Object getDisplayValue(RecordB recordB)
>> >>> >        {
>> >>> >            return recordB.getName();
>> >>> >        }
>> >>> >
>> >>> >        public String getIdValue(RecordB recordB, int index)
>> >>> >        {
>> >>> >            return recordB.getName();
>> >>> >        }
>> >>> >    }
>> >>> > }
>> >>> >
>> >>> > >
>> >>> > > Shelli
>> >>> > >
>> >>> > > -----Original Message-----
>> >>> > > From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
>> >>> > > Sent: Tuesday, October 12, 2010 10:38 AM
>> >>> > > To: users@wicket.apache.org
>> >>> > > Subject: Re: PropertyModel Not Refreshing
>> >>> > >
>> >>> > > here are the tweaks you need to make this work:
>> >>> > >
>> >>> > > selectedRecordAModel = new PropertyModel<RecordA>(this,
>> >>> > "selectedRecordA");
>> >>> > >
>> >>> > > recordAText = new RequiredTextField("recordAText",
>> >>> > >                new PropertyModel(selectedRecordAModel,
"name"));
>> >>> > >
>> >>> > >  recordBs.setModel(new PropertyModel(selectedRecordAModel,
>> >>> "recordB"));
>> >>> > >
>> >>> > > have fun
>> >>> > >
>> >>> > > -igor
>> >>> > >
>> >>> > > On Tue, Oct 12, 2010 at 9:03 AM, Shelli Orton
>> <Sh...@sjrb.ca>
>> >>> > wrote:
>> >>> > >> I've been able to create a sample application that exhibits
the
>> >>> > >> same/similar problems to mine.  The sample makes use of an
>> >>> in-memory
>> >>> > >> list for the data versus accessing a database and so there's
>> some
>> >>> > >> differences.  However, I believe the problems that this
sample
>> >>> exhibits
>> >>> > >> have the same root cause as my project (which I believe have
>> >>> something
>> >>> > >> to do with how my models are set up...).
>> >>> > >>
>> >>> > >> Issues this sample exhibits:
>> >>> > >>
>> >>> > >> 1. Choose to edit an existing record, then cancel the edit.
>> Choose
>> >>> > >> another/the same record to edit and the selected record is
null
>> >>> (error
>> >>> > >> message "You must select a record to edit" is displayed).
Must
>> >>> > >> close/open session to reset.
>> >>> > >>
>> >>> > >> 2. Choose to edit an existing record and save the edit.
Choose
>> >>> > >> another/the same record to edit and you get a NPE:
>> >>> > >>
>> >>> > >>    WicketMessage: Method onFormSubmitted of interface
>> >>> > >> org.apache.wicket.markup.html.form.IFormSubmitListener
targeted
>> at
>> >>> > >> component [MarkupContainer [Component id = selectForm]]
threw
>> an
>> >>> > >> exception
>> >>> > >>
>> >>> > >>    Root cause:
>> >>> > >>
>> >>> > >>    java.lang.NullPointerException
>> >>> > >>    at
>> >>> > >>
>> >>>
>>
org.apache.wicket.markup.html.form.AbstractSingleSelectChoice.convertCho
>> >>> > >> iceIdToChoice(AbstractSingleSelectChoice.java:247)
>> >>> > >>
>> >>> > >> 3. Create a new record and try to save it and get
>> >>> > >> WicketRuntimeException:
>> >>> > >>
>> >>> > >>    WicketMessage: Attempted to set property value on a null
>> object.
>> >>> > >> Property expression: name Value: New One
>> >>> > >>
>> >>> > >>    Root cause:
>> >>> > >>
>> >>> > >>    org.apache.wicket.WicketRuntimeException: Attempted to
set
>> >>> property
>> >>> > >> value on a null object. Property expression: name Value: New
>> One
>> >>> > >>    at
>> >>> > >>
>> >>>
>>
org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.j
>> >>> > >> ava:125)
>> >>> > >>
>> >>> > >> 4. Create a new record and then cancel the add, Choose an
>> existing
>> >>> > >> record to edit and the selected record is null (error
message
>> "You
>> >>> must
>> >>> > >> select a record to edit" is displayed).  Must close/open
>> session to
>> >>> > >> reset.
>> >>> > >>
>> >>> > >> As always, all help is greatly appreciated as I am stumped.
>> >>> > >>
>> >>> > >> Thanks,
>> >>> > >> Shelli
>> >>> > >>
>> >>> > >> -----Original Message-----
>> >>> > >> From: jcgarciam [mailto:jcgarciam@gmail.com]
>> >>> > >> Sent: Friday, October 08, 2010 1:41 PM
>> >>> > >> To: users@wicket.apache.org
>> >>> > >> Subject: Re: PropertyModel Not Refreshing
>> >>> > >>
>> >>> > >>
>> >>> > >> The attachment didn't make it,
>> >>> > >>
>> >>> > >> Can you try to extract out the relevant part and creates a
>> >>> quickstart
>> >>> > >> project that actually reproduces your issue?
>> >>> > >>
>> >>> > >>
>> >>> > >> On Fri, Oct 8, 2010 at 1:41 PM, Shelli Orton [via Apache
>> Wicket] <
>> >>> > >>
>> >>>
>>
ml-node+2968688-305091622-65838@n4.nabble.com<ml-node%2B2968688-30509162
2-65838@n4.nabble.com>
>> <ml-node%2B2968688-30509162
>> 2-65838@n4.nabble.com>
>> >>> <ml-node%2B2968688-30509162
>> >>> 2-65838@n4.nabble.com>
>> >>> > <ml-node%2B2968688-30509162
>> >>> > >> 2-65838@n4.nabble.com>
>> >>> > >>> wrote:
>> >>> > >>
>> >>> > >>> Hi,
>> >>> > >>>
>> >>> > >>> I have been trying different things to see if I could get
my
>> code
>> >>> to
>> >>> > >> work
>> >>> > >>> (and understand Wicket models better), but am still stuck.
I
>> have
>> >>> a
>> >>> > >>> attached the (latest) panel class code which I hope is
>> sufficient
>> >>> to
>> >>> > >> help.
>> >>> > >>>
>> >>> > >>> I was reading about different models (both online and the
>> Wicket
>> >>> in
>> >>> > >> Action
>> >>> > >>> book) and thought that perhaps using a
CompoundPropertyModel
>> was
>> >>> more
>> >>> > >>> appropriate and may help with my issues.  Originally, I
only
>> >>> declared
>> >>> > >>> selectedRecordA (line 40) but didn't instantiate it.  The
>> select
>> >>> group
>> >>> > >>> displayed properly but when I chose a record from the list
and
>> >>> tried
>> >>> > >> to edit
>> >>> > >>> it, this exception was thrown:
>> >>> > >>>
>> >>> > >>>     WicketMessage: Attempted to set property value on a
null
>> >>> object.
>> >>> > >>> Property expression: recordA Value: Name=A-One
>> >>> > >>>     Root cause:
>> >>> > >>>
>> >>> > >>>     org.apache.wicket.WicketRuntimeException: Attempted to
set
>> >>> > >> property
>> >>> > >>> value on a null object. Property expression: recordA Value:
>> >>> Name=A-One
>> >>> > >>>         at
>> >>> > >>>
>> >>> > >>
>> >>>
>>
org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.j
>> >>> > >> ava:125)
>> >>> > >>>
>> >>> > >>>         at
>> >>> > >>>
>> >>> > >>
>> >>>
>>
org.apache.wicket.model.AbstractPropertyModel.setObject(AbstractProperty
>> >>> > >> Model.java:169)
>> >>> > >>>
>> >>> > >>>         at
>> >>> > >>>
>> >>>
>>
org.apache.wicket.Component.setDefaultModelObject(Component.java:3125)
>> >>> > >>>         ....
>> >>> > >>>
>> >>> > >>> I set breakpoints on the getSelectedRecordA and
>> setSelectedRecordA
>> >>> > >> methods,
>> >>> > >>> but these aren't called when during the request cycle when
the
>> >>> edit
>> >>> > >> button
>> >>> > >>> is clicked.
>> >>> > >>>
>> >>> > >>> I then changed the class so that selectedRecordA is
>> initialized to
>> >>> an
>> >>> > >> empty
>> >>> > >>> instance of RecordA. This got rid of the above error.
>> However, I
>> >>> > >> cannot
>> >>> > >>> save the edit changes because the selectedRecordA is still
the
>> >>> empty
>> >>> > >>> instance that was created in the initialization and the
>> >>> persistence
>> >>> > >> layer
>> >>> > >>> throws an exception.  This same problem exists if I try to
add
>> a
>> >>> new
>> >>> > >> RecordA
>> >>> > >>> or try to delete an existing one.
>> >>> > >>>
>> >>> > >>> If I choose to cancel the edit and then select another
record
>> to
>> >>> edit,
>> >>> > >> I
>> >>> > >>> get the message "You must select a record to edit" (line
131).
>> >>> This
>> >>> > >> is
>> >>> > >>> because the cancel onSubmit sets selectedRecordA to null
and
>> >>> choosing
>> >>> > >> the
>> >>> > >>> record from the DDC is not setting it to the chosen record.
>> >>> > >>>
>> >>> > >>> Clearly I am not setting up this CompoundPropertyModel
>> properly so
>> >>> > >> that the
>> >>> > >>> selectedARecord is set by the model.  Can someone tell me
what
>> I'm
>> >>> > >> doing
>> >>> > >>> wrong?
>> >>> > >>>
>> >>> > >>> All help is greatly appreciated,
>> >>> > >>>
>> >>> > >>> Shelli
>> >>> > >>>
>> >>> > >>>
>> >>> > >>> -----Original Message-----
>> >>> > >>> From: Igor Vaynberg [mailto:[hidden
>> >>> > >>
email]<http://user/SendEmail.jtp?type=node&node=2968688&i=0>]
>> >>> > >>>
>> >>> > >>> Sent: Thursday, October 07, 2010 11:27 AM
>> >>> > >>> To: [hidden email]
>> >>> > >> <http://user/SendEmail.jtp?type=node&node=2968688&i=1>
>> >>> > >>> Subject: Re: PropertyModel Not Refreshing
>> >>> > >>>
>> >>> > >>> you have posted an incomplete piece of code and somehow
from
>> that
>> >>> we
>> >>> > >>> are supposed to guess what is not working? create a
quickstart
>> and
>> >>> > >>> provide that.
>> >>> > >>>
>> >>> > >>> -igor
>> >>> > >>>
>> >>> > >>> On Thu, Oct 7, 2010 at 10:15 AM, Shelli Orton <[hidden
>> >>> > >>
email]<http://user/SendEmail.jtp?type=node&node=2968688&i=2>>
>> >>> > >>> wrote:
>> >>> > >>>
>> >>> > >>> > Does nobody have any suggestions?  If I can't get this
>> fixed,
>> >>> I'm
>> >>> > >> going
>> >>> > >>> > to have to write the app in another framework (possibly
GWT)
>> and
>> >>> I'd
>> >>> > >>> > really rather not have to do that.
>> >>> > >>> >
>> >>> > >>> > Shelli
>> >>> > >>> >
>> >>> > >>> > -----Original Message-----
>> >>> > >>> > From: Shelli Orton
>> >>> > >>> > Sent: Wednesday, October 06, 2010 3:52 PM
>> >>> > >>> > To: [hidden
>> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=3>
>> >>> > >>> > Subject: PropertyModel Not Refreshing
>> >>> > >>> >
>> >>> > >>> > Hi,
>> >>> > >>> >
>> >>> > >>> > First, thanks to all who have been helping me as I am new
to
>> >>> Wicket.
>> >>> > >> I
>> >>> > >>> > am splitting out two issues I am dealing with to try to
keep
>> >>> things
>> >>> > >>> > clear.
>> >>> > >>> >
>> >>> > >>> > I am trying to write a simple app that does CRUD
operations
>> on
>> >>> > >> database
>> >>> > >>> > records.  The goal is for the app to make use of a tab
panel
>> >>> where
>> >>> > >> each
>> >>> > >>> > tab encapsulates one table from the database.  Each tab
>> panel
>> >>> has
>> >>> > >> two
>> >>> > >>> > groups (WebMarkupContainer).  The first, selectGroup,
>> displays a
>> >>> > >> list
>> >>> > >>> > (DDC) of the current items, and three buttons, add, edit
and
>> >>> delete.
>> >>> > >>> > The second, editGroup, is displayed when either the add
or
>> edit
>> >>> > >> button
>> >>> > >>> > was clicked on the select group, displays the record
>> attributes
>> >>> and
>> >>> > >> save
>> >>> > >>> > and cancel buttons.  The tab panel has a "selectedRecord"
>> which
>> >>> is
>> >>> > >> used
>> >>> > >>> > by both groups' components via PropertyModels. Very basic
>> stuff.
>> >>> > >>> >
>> >>> > >>> > When I choose a record and click the edit button, the
record
>> is
>> >>> > >>> > displayed in the edit group properly.  If I then choose
>> cancel,
>> >>> the
>> >>> > >> edit
>> >>> > >>> > group is no longer displayed and the select group DDC
>> selection
>> >>> is
>> >>> > >> null
>> >>> > >>> > as expected. I then choose another record from the list
and
>> >>> click
>> >>> > >> the
>> >>> > >>> > edit button and the previous record information is
displayed
>> in
>> >>> the
>> >>> > >> edit
>> >>> > >>> > group even though the select group DDC shows the
>> >>> correct/selected
>> >>> > >>> > record.
>> >>> > >>> >
>> >>> > >>> > This problem also occurs if I first choose to add a new
>> record
>> >>> and
>> >>> > >> then
>> >>> > >>> > cancel the add and then choose to edit a different
record.
>> The
>> >>> DDC
>> >>> > >>> > shows the correct/selected record, but all the attributes
in
>> the
>> >>> > >> edit
>> >>> > >>> > group are null/defaults for a new record.
>> >>> > >>> >
>> >>> > >>> > If I remove the call to setDefaultFormProcessing(false)
on
>> the
>> >>> > >> cancel
>> >>> > >>> > button, selecting other records for edit works correctly,
>> but I
>> >>> > >> can't
>> >>> > >>> > cancel a creating a new record if I use a
RequiredTextField
>> >>> because
>> >>> > >> the
>> >>> > >>> > form validation fails.
>> >>> > >>> >
>> >>> > >>> > If I select a record for editing or save the newly
created
>> >>> record, I
>> >>> > >> can
>> >>> > >>> > select a different record for edit or create another one
>> >>> correctly.
>> >>> > >> So
>> >>> > >>> > I must be doing something wrong in the cancel logic. My
>> editForm
>> >>> > >>> > (created in the EditGroup constructor) looks like this:
>> >>> > >>> >
>> >>> > >>> >            Form editForm = new Form("editForm");
>> >>> > >>> >
>> >>> > >>> >            editForm.add(new Label("nameLabel", "Name"));
>> >>> > >>> >
>> >>> > >>> >            editForm.add(new Label("attributeLabel",
>> >>> "Attribute"));
>> >>> > >>> >
>> >>> > >>> >            editForm.add(new
>> >>> > >> RequiredTextField<String>("recordNameText",
>> >>> > >>> >                    new
>> PropertyModel<String>(MyRecordPanel.this,
>> >>> > >>> >                            "selectedRecord.name")));
>> >>> > >>> >
>> >>> > >>> >            editForm.add(new
>> DropDownChoice<Lir>("attributes",
>> >>> > >>> >                    new
>> >>> PropertyModel<Attribute>(MyRecordPanel.this,
>> >>> > >>> >                            "selectedRecord.attribute"),
>> >>> > >>> >                    RateCentrePanel.this.getAttributes(),
>> >>> > >>> >                    new AttributeRenderer()));
>> >>> > >>> >
>> >>> > >>> >            ....
>> >>> > >>> >
>> >>> > >>> >            editForm.add(new Button("cancel")
>> >>> > >>> >            {
>> >>> > >>> >                private static final long serialVersionUID
=
>> 1L;
>> >>> > >>> >
>> >>> > >>> >                public void onSubmit()
>> >>> > >>> >                {
>> >>> > >>> >                    MyRecordPanel.this.selectedRecord =
null;
>> >>> > >>> >                    editGroup.setVisible(false);
>> >>> > >>> >                    selectGroup.setVisible(true);
>> >>> > >>> >                }
>> >>> > >>> >            }.setDefaultFormProcessing(false));
>> >>> > >>> >
>> >>> > >>> >            add(editForm);
>> >>> > >>> >
>> >>> > >>> > Other than setting the selectedRecord to null, what
should I
>> be
>> >>> > >> doing
>> >>> > >>> > differently?
>> >>> > >>> >
>> >>> > >>> > Thanks in advance!
>> >>> > >>> >
>> >>> > >>> > Shelli
>> >>> > >>> >
>> >>> > >>> >
>> >>> > >>
>> >>>
>> ---------------------------------------------------------------------
>> >>> > >>> > To unsubscribe, e-mail: [hidden
>> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=4>
>> >>> > >>> > For additional commands, e-mail: [hidden
>> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=5>
>> >>> > >>> >
>> >>> > >>> >
>> >>> > >>> >
>> >>> > >>
>> >>>
>> ---------------------------------------------------------------------
>> >>> > >>> > To unsubscribe, e-mail: [hidden
>> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=6>
>> >>> > >>> > For additional commands, e-mail: [hidden
>> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=7>
>> >>> > >>> >
>> >>> > >>> >
>> >>> > >>>
>> >>>
>> ---------------------------------------------------------------------
>> >>> > >>> To unsubscribe, e-mail: [hidden
>> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=8>
>> >>> > >>> For additional commands, e-mail: [hidden
>> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=9>
>> >>> > >>>
>> >>> > >>>
>> >>> > >>>
>> >>> > >>>
>> >>> > >>>
>> >>>
>> ---------------------------------------------------------------------
>> >>> > >>> To unsubscribe, e-mail: [hidden
>> >>> > >>
email]<http://user/SendEmail.jtp?type=node&node=2968688&i=10>
>> >>> > >>> For additional commands, e-mail: [hidden
>> >>> > >>
email]<http://user/SendEmail.jtp?type=node&node=2968688&i=11>
>> >>> > >>>
>> >>> > >>> ------------------------------
>> >>> > >>>  View message @
>> >>> > >>>
>> >>> > >>
>> >>> >
>> >>>
>>
http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
>> >>> > >> n-tp2955144p2968688.html
>> >>> > >>> To start a new topic under Apache Wicket, email
>> >>> > >>>
>> >>> > >>
>> >>>
>>
ml-node+1842946-398011874-65838@n4.nabble.com<ml-node%2B1842946-39801187
4-65838@n4.nabble.com>
>> <ml-node%2B1842946-39801187
>> 4-65838@n4.nabble.com>
>> >>> <ml-node%2B1842946-39801187
>> >>> 4-65838@n4.nabble.com>
>> >>> > <ml-node%2B1842946-39801187
>> >>> > >> 4-65838@n4.nabble.com>
>> >>> > >>> To unsubscribe from Apache Wicket, click
>> >>> > >>
>> >>>
>>
here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp
>> >>> > ?
>> >>> > >>
>> >>>
>>
tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
>> >>> > >> QyOTQ2fDEyNTYxMzc3ODY=>.
>> >>> > >>>
>> >>> > >>>
>> >>> > >>>
>> >>> > >>
>> >>> > >>
>> >>> > >> --
>> >>> > >> Sincerely,
>> >>> > >> JC (http://www.linkedin.com/in/jcgarciam)
>> >>> > >> Work smarter, not harder!.
>> >>> > >>
>> >>> > >> --
>> >>> > >> View this message in context:
>> >>> > >>
>> >>> >
>> >>>
>>
http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
>> >>> > >> n-tp2955144p2968936.html
>> >>> > >> Sent from the Users forum mailing list archive at
Nabble.com.
>> >>> > >>
>> >>> > >>
>> >>>
>> ---------------------------------------------------------------------
>> >>> > >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >>> > >> For additional commands, e-mail:
users-help@wicket.apache.org
>> >>> > >>
>> >>> > >>
>> >>> > >>
>> >>> > >>
>> >>>
>> ---------------------------------------------------------------------
>> >>> > >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >>> > >> For additional commands, e-mail:
users-help@wicket.apache.org
>> >>> > >>
>> >>> > >
>> >>> > >
>> >>>
>> ---------------------------------------------------------------------
>> >>> > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >>> > > For additional commands, e-mail: users-help@wicket.apache.org
>> >>> > >
>> >>> > >
>> >>> > >
>> >>>
>> ---------------------------------------------------------------------
>> >>> > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >>> > > For additional commands, e-mail: users-help@wicket.apache.org
>> >>> > >
>> >>> > >
>> >>> >
>> >>> >
>> ---------------------------------------------------------------------
>> >>> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >>> > For additional commands, e-mail: users-help@wicket.apache.org
>> >>> >
>> >>> >
>> >>> >
>> ---------------------------------------------------------------------
>> >>> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >>> > For additional commands, e-mail: users-help@wicket.apache.org
>> >>> >
>> >>> >
>> >>>
>> >>>
>> ---------------------------------------------------------------------
>> >>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >>> For additional commands, e-mail: users-help@wicket.apache.org
>> >>>
>> >>>
>> >>
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>

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


Re: PropertyModel Not Refreshing

Posted by nino martinez wael <ni...@gmail.com>.
going at a hunch I decided to rem out the below:

//        cancel.setDefaultFormProcessing(false);

And seems it fixed the problem.. But im too tired to digg further had a
similar situation last week.. And the reason was sound.. Just cant remember
it now..

2010/10/12 nino martinez wael <ni...@gmail.com>

> Think I was going in the wrong direction.. Looking at the error, seems to
> get triggered by pressing the cancel button only..
>
>
> 2010/10/12 Shelli Orton <Sh...@sjrb.ca>
>
>> This is where my confusion about models may be kicking in.  I thought
>> that property models (PropertModel or CompoundPropertyModel)
>> automatically checked if the model object changed.  How do I tell the
>> model it has?
>>
>> Shelli
>>
>> -----Original Message-----
>> From: nino martinez wael [mailto:nino.martinez.wael@gmail.com]
>> Sent: Tuesday, October 12, 2010 12:10 PM
>> To: users@wicket.apache.org
>> Subject: Re: PropertyModel Not Refreshing
>>
>> in your add button you call setSelectedRecordA(new RecordA()) but never
>> notify the model that a change has occured...
>>
>> 2010/10/12 nino martinez wael <ni...@gmail.com>
>>
>> > hmm getting a lot of errors on the services not implementing
>> > serialization...
>> >
>> > But does seem theres a difference between calling :
>> >
>> > selectedRecordAModel.getObject().getName() and
>> > RecordAPanel.this.selectedRecordA
>> >
>> > 2010/10/12 nino martinez wael <ni...@gmail.com>
>> >
>> > sorry.. Did'nt see it attached.. So did igor provide you with an fixed
>> >> quickstart (working on his system).. That did not work on glassfish?
>> >>
>> >>
>> >> 2010/10/12 Shelli Orton <Sh...@sjrb.ca>
>> >>
>> >>> The quickstart was sent to the list this morning at 10:04 MST.  Does
>> it
>> >>> need to be resent?
>> >>>
>> >>> Shelli
>> >>>
>> >>> -----Original Message-----
>> >>> From: nino martinez wael [mailto:nino.martinez.wael@gmail.com]
>> >>> Sent: Tuesday, October 12, 2010 11:52 AM
>> >>> To: users@wicket.apache.org
>> >>> Subject: Re: PropertyModel Not Refreshing
>> >>>
>> >>> No dont think so.. Please provide a quickstart.. I have had property
>> >>> models
>> >>> working in 1.2, 1.3, 1.4 and 1.5 so must be error 42:)
>> >>>
>> >>> 2010/10/12 Shelli Orton <Sh...@sjrb.ca>
>> >>>
>> >>> > Hi,
>> >>> >
>> >>> > Thanks for file.  Your first email was missing these changes:
>> >>> >
>> >>> >    IModel<RecordA> selectedRecordAModel;  (I had set mine to
>> >>> > PropertyModel<RecordA> selectedRecordAModel;)
>> >>> >    recordAs.setModel(selectedRecordAModel)
>> >>> >
>> >>> > However, even with those changes applied, I still get the same
>> issue
>> >>> of the
>> >>> > selected record not updating in the edit group.
>> >>> >
>> >>> > I am deploying in Glassfish v3.  Could that have anything to do
>> with
>> >>> my
>> >>> > problems?
>> >>> >
>> >>> > Shelli
>> >>> >
>> >>> > -----Original Message-----
>> >>> > From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
>> >>> > Sent: Tuesday, October 12, 2010 11:35 AM
>> >>> > To: users@wicket.apache.org
>> >>> > Subject: Re: PropertyModel Not Refreshing
>> >>> >
>> >>> > On Tue, Oct 12, 2010 at 10:30 AM, Shelli Orton
>> <Sh...@sjrb.ca>
>> >>> > wrote:
>> >>> > > Thanks for the help.  Your changes got rid of the errors and I
>> can
>> >>> delete
>> >>> > records now (and the list is updated).
>> >>> > >
>> >>> > > However, once a record has been selected for edit and either
>> saved
>> >>> or
>> >>> > cancelled, that same record is always displayed in the edit group
>> when
>> >>> I
>> >>> > choose another record to edit or even when I try to create a new
>> one.
>> >>> I can
>> >>> > even delete the chosen record and it still displays in the edit
>> group.
>> >>> >
>> >>> > works fine here, meaning you did not completely/propery apply my
>> >>> > changes. below is the complete file.
>> >>> >
>> >>> > -igor
>> >>> >
>> >>> > public class RecordAPanel extends Panel
>> >>> > {
>> >>> >    private static final long serialVersionUID = 1L;
>> >>> >
>> >>> >    RecordAService recordAService;
>> >>> >    RecordBService recordBService;
>> >>> >
>> >>> >    RecordA selectedRecordA = new RecordA();
>> >>> >    IModel<RecordA> selectedRecordAModel;
>> >>> >    String unmodifiedRecordA;
>> >>> >
>> >>> >    boolean isNew = false;
>> >>> >
>> >>> >    WebMarkupContainer selectGroup;
>> >>> >    WebMarkupContainer editGroup;
>> >>> >
>> >>> >    Form selectForm;
>> >>> >    Form editForm;
>> >>> >
>> >>> >    DropDownChoice<RecordA> recordAs;
>> >>> >    DropDownChoice<RecordB> recordBs;
>> >>> >
>> >>> >    Button add;
>> >>> >    Button edit;
>> >>> >    Button save;
>> >>> >    Button delete;
>> >>> >    Button cancel;
>> >>> >
>> >>> >    Label editLegendLabel;
>> >>> >    String editLegend;
>> >>> >    Label recordALabel;
>> >>> >    Label recordBLabel;
>> >>> >
>> >>> >    RequiredTextField recordAText;
>> >>> >
>> >>> >    @SuppressWarnings({ "rawtypes", "unchecked" })
>> >>> >    public RecordAPanel(String id)
>> >>> >    {
>> >>> >        super(id);
>> >>> >
>> >>> >        recordAService = ((Application)
>> >>> > RequestCycle.get().getApplication()).getRecordAService();
>> >>> >        recordBService = ((Application)
>> >>> > RequestCycle.get().getApplication()).getRecordBService();
>> >>> >
>> >>> >        selectedRecordAModel = new PropertyModel<RecordA>(this,
>> >>> > "selectedRecordA");
>> >>> >        this.setDefaultModel(selectedRecordAModel);
>> >>> >
>> >>> >        // ************* Select  Group *************
>> >>> >
>> >>> >        selectGroup = new WebMarkupContainer("selectGroup");
>> >>> >        selectForm = new Form("selectForm");
>> >>> >
>> >>> >        recordAs = new DropDownChoice<RecordA>("recordAs");
>> >>> >        recordAs.setModel(selectedRecordAModel);
>> >>> >        recordAs.setChoices(recordAsModel);
>> >>> >        recordAs.setChoiceRenderer(new RecordARenderer());
>> >>> >
>> >>> >        //            recordAs = (DropDownChoice<RecordA>) new
>> >>> > DropDownChoice<RecordA>("recordAs",
>> >>> >        //                    new PropertyModel<RecordA>(this,
>> >>> > "selectedRecordA"),
>> >>> >        //                    recordAsModel,
>> >>> >        //                    new RecordARenderer());
>> >>> >
>> >>> >        recordAs.setNullValid(false);
>> >>> >
>> >>> >        selectForm.add(recordAs);
>> >>> >
>> >>> >        add = new Button("add")
>> >>> >        {
>> >>> >            private static final long serialVersionUID = 1L;
>> >>> >
>> >>> >            public void onSubmit()
>> >>> >            {
>> >>> >                setSelectedRecordA(new RecordA());
>> >>> >                isNew = true;
>> >>> >                editLegend = "New";
>> >>> >                editGroup.setVisible(true);
>> >>> >                selectGroup.setVisible(false);
>> >>> >            }
>> >>> >        };
>> >>> >
>> >>> >        selectForm.add(add);
>> >>> >
>> >>> >        edit = new Button("edit")
>> >>> >        {
>> >>> >            private static final long serialVersionUID = 1L;
>> >>> >
>> >>> >            public void onSubmit()
>> >>> >            {
>> >>> >                if (selectedRecordA == null)
>> >>> >                {
>> >>> >                    info("You must select a record to edit.");
>> >>> >                }
>> >>> >                else
>> >>> >                {
>> >>> >                    unmodifiedRecordA = selectedRecordA.getName();
>> >>> >                    isNew = false;
>> >>> >                    editLegend = "Edit";
>> >>> >                    editGroup.setVisible(true);
>> >>> >                    selectGroup.setVisible(false);
>> >>> >                }
>> >>> >            }
>> >>> >        };
>> >>> >
>> >>> >        selectForm.add(edit);
>> >>> >
>> >>> >        delete = new Button("delete")
>> >>> >        {
>> >>> >            private static final long serialVersionUID = 1L;
>> >>> >
>> >>> >            public void onSubmit()
>> >>> >            {
>> >>> >                if (selectedRecordA == null)
>> >>> >                {
>> >>> >                    info("You must select a record to delete.");
>> >>> >                }
>> >>> >                else
>> >>> >                {
>> >>> >                    // Delete the selected record
>> >>> >                    unmodifiedRecordA = selectedRecordA.getName();
>> >>> >
>> recordAService.delete(selectedRecordA.getName());
>> >>> >                    selectedRecordA = null;
>> >>> >                    info("Deleted '" + unmodifiedRecordA + "'");
>> >>> >
>> >>> >                    // Force refresh of records list
>> >>> >                    RecordAPanel.this.recordAsModel.detach();
>> >>> >                }
>> >>> >            }
>> >>> >        };
>> >>> >
>> >>> >        // Add confirmation dialog box
>> >>> >        delete.add(new SimpleAttributeModifier("onclick",
>> >>> >                "if (!confirm('Please confirm you want to delete
>> this
>> >>> > record') ){ return false; }"));
>> >>> >
>> >>> >        selectForm.add(delete);
>> >>> >        selectGroup.add(selectForm);
>> >>> >
>> >>> >        this.add(selectGroup);
>> >>> >
>> >>> >        // ************* Edit Group *************
>> >>> >
>> >>> >        editGroup = new WebMarkupContainer("editGroup");
>> >>> >
>> >>> >        editLegendLabel = new Label("editLegend", new
>> >>> PropertyModel(this,
>> >>> >                "editLegend"));
>> >>> >
>> >>> >        editGroup.add(editLegendLabel);
>> >>> >
>> >>> >        editForm = new Form("editForm");
>> >>> >
>> >>> >        recordALabel = new Label("recordALabel", "Record A");
>> >>> >        editForm.add(recordALabel);
>> >>> >
>> >>> >        recordBLabel = new Label("recordBLabel", "Record B");
>> >>> >        editForm.add(recordBLabel);
>> >>> >
>> >>> >        recordAText = new RequiredTextField("recordAText",
>> >>> >                new PropertyModel(selectedRecordAModel, "name"));
>> >>> >
>> >>> >        editForm.add(recordAText);
>> >>> >
>> >>> >        recordBs = new DropDownChoice<RecordB>("recordBs");
>> >>> >        recordBs.setModel(new PropertyModel(selectedRecordAModel,
>> >>> > "recordB"));
>> >>> >        recordBs.setChoices(RecordAPanel.this.getRecordBs());
>> >>> >        recordBs.setChoiceRenderer(new RecordBRenderer());
>> >>> >
>> >>> >        editForm.add(recordBs);
>> >>> >
>> >>> >        save = new Button("save")
>> >>> >        {
>> >>> >            private static final long serialVersionUID = 1L;
>> >>> >
>> >>> >            @Override
>> >>> >            public void onSubmit()
>> >>> >            {
>> >>> >                if (isNew)
>> >>> >                {
>> >>> >
>> >>> > recordAService.create(RecordAPanel.this.selectedRecordA);
>> >>> >                        info("Created '"
>> >>> >                                +
>> >>> > RecordAPanel.this.selectedRecordA.getName()
>> >>> >                                + "'");
>> >>> >                }
>> >>> >                else
>> >>> >                {
>> >>> >                        recordAService.update(unmodifiedRecordA,
>> >>> >                                RecordAPanel.this.selectedRecordA);
>> >>> >                        info("Updated '"
>> >>> >                                +
>> >>> > RecordAPanel.this.selectedRecordA.getName()
>> >>> >                                + "'");
>> >>> >                }
>> >>> >
>> >>> >                // TODO Update the dropdown list?
>> >>> >
>> >>> >                editGroup.setVisible(false);
>> >>> >                selectGroup.setVisible(true);
>> >>> >            }
>> >>> >        };
>> >>> >
>> >>> >        editForm.add(save);
>> >>> >
>> >>> >        cancel = new Button("cancel")
>> >>> >        {
>> >>> >            private static final long serialVersionUID = 1L;
>> >>> >
>> >>> >            public void onSubmit()
>> >>> >            {
>> >>> >                RecordAPanel.this.selectedRecordA = null;
>> >>> >                editGroup.setVisible(false);
>> >>> >                selectGroup.setVisible(true);
>> >>> >            }
>> >>> >        };
>> >>> >
>> >>> >        cancel.setDefaultFormProcessing(false);
>> >>> >        editForm.add(cancel);
>> >>> >
>> >>> >        editGroup.add(editForm);
>> >>> >
>> >>> >        editGroup.setVisible(false);
>> >>> >        this.add(editGroup);
>> >>> >    }
>> >>> >
>> >>> >    public RecordA getSelectedRecordA()
>> >>> >    {
>> >>> >        return selectedRecordA;
>> >>> >    }
>> >>> >
>> >>> >    public void setSelectedRecordA(RecordA selectedRecordA)
>> >>> >    {
>> >>> >        this.selectedRecordA = selectedRecordA;
>> >>> >    }
>> >>> >
>> >>> >    public LoadableDetachableModel<List<RecordA>> recordAsModel =
>> new
>> >>> > LoadableDetachableModel<List<RecordA>>()
>> >>> >    {
>> >>> >        private static final long serialVersionUID = 1L;
>> >>> >
>> >>> >        @Override
>> >>> >        protected List<RecordA> load()
>> >>> >        {
>> >>> >            return recordAService.getList();
>> >>> >        }
>> >>> >
>> >>> >        public void detach()
>> >>> >        {
>> >>> >            super.detach();
>> >>> >        }
>> >>> >    };
>> >>> >
>> >>> >    // TODO change this to LDM?
>> >>> >    List<RecordB> getRecordBs()
>> >>> >    {
>> >>> >        return recordBService.getList();
>> >>> >    }
>> >>> >
>> >>> >    class RecordARenderer implements IChoiceRenderer<RecordA>
>> >>> >    {
>> >>> >        private static final long serialVersionUID = 1L;
>> >>> >
>> >>> >        public Object getDisplayValue(RecordA recordA)
>> >>> >        {
>> >>> >            return recordA.getName();
>> >>> >        }
>> >>> >
>> >>> >        public String getIdValue(RecordA recordA, int index)
>> >>> >        {
>> >>> >            return recordA.getName();
>> >>> >        }
>> >>> >    }
>> >>> >
>> >>> >    class RecordBRenderer implements IChoiceRenderer<RecordB>
>> >>> >    {
>> >>> >        private static final long serialVersionUID = 1L;
>> >>> >
>> >>> >        public Object getDisplayValue(RecordB recordB)
>> >>> >        {
>> >>> >            return recordB.getName();
>> >>> >        }
>> >>> >
>> >>> >        public String getIdValue(RecordB recordB, int index)
>> >>> >        {
>> >>> >            return recordB.getName();
>> >>> >        }
>> >>> >    }
>> >>> > }
>> >>> >
>> >>> > >
>> >>> > > Shelli
>> >>> > >
>> >>> > > -----Original Message-----
>> >>> > > From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
>> >>> > > Sent: Tuesday, October 12, 2010 10:38 AM
>> >>> > > To: users@wicket.apache.org
>> >>> > > Subject: Re: PropertyModel Not Refreshing
>> >>> > >
>> >>> > > here are the tweaks you need to make this work:
>> >>> > >
>> >>> > > selectedRecordAModel = new PropertyModel<RecordA>(this,
>> >>> > "selectedRecordA");
>> >>> > >
>> >>> > > recordAText = new RequiredTextField("recordAText",
>> >>> > >                new PropertyModel(selectedRecordAModel, "name"));
>> >>> > >
>> >>> > >  recordBs.setModel(new PropertyModel(selectedRecordAModel,
>> >>> "recordB"));
>> >>> > >
>> >>> > > have fun
>> >>> > >
>> >>> > > -igor
>> >>> > >
>> >>> > > On Tue, Oct 12, 2010 at 9:03 AM, Shelli Orton
>> <Sh...@sjrb.ca>
>> >>> > wrote:
>> >>> > >> I've been able to create a sample application that exhibits the
>> >>> > >> same/similar problems to mine.  The sample makes use of an
>> >>> in-memory
>> >>> > >> list for the data versus accessing a database and so there's
>> some
>> >>> > >> differences.  However, I believe the problems that this sample
>> >>> exhibits
>> >>> > >> have the same root cause as my project (which I believe have
>> >>> something
>> >>> > >> to do with how my models are set up...).
>> >>> > >>
>> >>> > >> Issues this sample exhibits:
>> >>> > >>
>> >>> > >> 1. Choose to edit an existing record, then cancel the edit.
>> Choose
>> >>> > >> another/the same record to edit and the selected record is null
>> >>> (error
>> >>> > >> message "You must select a record to edit" is displayed).  Must
>> >>> > >> close/open session to reset.
>> >>> > >>
>> >>> > >> 2. Choose to edit an existing record and save the edit.  Choose
>> >>> > >> another/the same record to edit and you get a NPE:
>> >>> > >>
>> >>> > >>    WicketMessage: Method onFormSubmitted of interface
>> >>> > >> org.apache.wicket.markup.html.form.IFormSubmitListener targeted
>> at
>> >>> > >> component [MarkupContainer [Component id = selectForm]] threw
>> an
>> >>> > >> exception
>> >>> > >>
>> >>> > >>    Root cause:
>> >>> > >>
>> >>> > >>    java.lang.NullPointerException
>> >>> > >>    at
>> >>> > >>
>> >>>
>> org.apache.wicket.markup.html.form.AbstractSingleSelectChoice.convertCho
>> >>> > >> iceIdToChoice(AbstractSingleSelectChoice.java:247)
>> >>> > >>
>> >>> > >> 3. Create a new record and try to save it and get
>> >>> > >> WicketRuntimeException:
>> >>> > >>
>> >>> > >>    WicketMessage: Attempted to set property value on a null
>> object.
>> >>> > >> Property expression: name Value: New One
>> >>> > >>
>> >>> > >>    Root cause:
>> >>> > >>
>> >>> > >>    org.apache.wicket.WicketRuntimeException: Attempted to set
>> >>> property
>> >>> > >> value on a null object. Property expression: name Value: New
>> One
>> >>> > >>    at
>> >>> > >>
>> >>>
>> org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.j
>> >>> > >> ava:125)
>> >>> > >>
>> >>> > >> 4. Create a new record and then cancel the add, Choose an
>> existing
>> >>> > >> record to edit and the selected record is null (error message
>> "You
>> >>> must
>> >>> > >> select a record to edit" is displayed).  Must close/open
>> session to
>> >>> > >> reset.
>> >>> > >>
>> >>> > >> As always, all help is greatly appreciated as I am stumped.
>> >>> > >>
>> >>> > >> Thanks,
>> >>> > >> Shelli
>> >>> > >>
>> >>> > >> -----Original Message-----
>> >>> > >> From: jcgarciam [mailto:jcgarciam@gmail.com]
>> >>> > >> Sent: Friday, October 08, 2010 1:41 PM
>> >>> > >> To: users@wicket.apache.org
>> >>> > >> Subject: Re: PropertyModel Not Refreshing
>> >>> > >>
>> >>> > >>
>> >>> > >> The attachment didn't make it,
>> >>> > >>
>> >>> > >> Can you try to extract out the relevant part and creates a
>> >>> quickstart
>> >>> > >> project that actually reproduces your issue?
>> >>> > >>
>> >>> > >>
>> >>> > >> On Fri, Oct 8, 2010 at 1:41 PM, Shelli Orton [via Apache
>> Wicket] <
>> >>> > >>
>> >>>
>> ml-node+2968688-305091622-65838@n4.nabble.com<ml...@n4.nabble.com>
>> <ml-node%2B2968688-30509162
>> 2-65838@n4.nabble.com>
>> >>> <ml-node%2B2968688-30509162
>> >>> 2-65838@n4.nabble.com>
>> >>> > <ml-node%2B2968688-30509162
>> >>> > >> 2-65838@n4.nabble.com>
>> >>> > >>> wrote:
>> >>> > >>
>> >>> > >>> Hi,
>> >>> > >>>
>> >>> > >>> I have been trying different things to see if I could get my
>> code
>> >>> to
>> >>> > >> work
>> >>> > >>> (and understand Wicket models better), but am still stuck.  I
>> have
>> >>> a
>> >>> > >>> attached the (latest) panel class code which I hope is
>> sufficient
>> >>> to
>> >>> > >> help.
>> >>> > >>>
>> >>> > >>> I was reading about different models (both online and the
>> Wicket
>> >>> in
>> >>> > >> Action
>> >>> > >>> book) and thought that perhaps using a CompoundPropertyModel
>> was
>> >>> more
>> >>> > >>> appropriate and may help with my issues.  Originally, I only
>> >>> declared
>> >>> > >>> selectedRecordA (line 40) but didn't instantiate it.  The
>> select
>> >>> group
>> >>> > >>> displayed properly but when I chose a record from the list and
>> >>> tried
>> >>> > >> to edit
>> >>> > >>> it, this exception was thrown:
>> >>> > >>>
>> >>> > >>>     WicketMessage: Attempted to set property value on a null
>> >>> object.
>> >>> > >>> Property expression: recordA Value: Name=A-One
>> >>> > >>>     Root cause:
>> >>> > >>>
>> >>> > >>>     org.apache.wicket.WicketRuntimeException: Attempted to set
>> >>> > >> property
>> >>> > >>> value on a null object. Property expression: recordA Value:
>> >>> Name=A-One
>> >>> > >>>         at
>> >>> > >>>
>> >>> > >>
>> >>>
>> org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.j
>> >>> > >> ava:125)
>> >>> > >>>
>> >>> > >>>         at
>> >>> > >>>
>> >>> > >>
>> >>>
>> org.apache.wicket.model.AbstractPropertyModel.setObject(AbstractProperty
>> >>> > >> Model.java:169)
>> >>> > >>>
>> >>> > >>>         at
>> >>> > >>>
>> >>>
>> org.apache.wicket.Component.setDefaultModelObject(Component.java:3125)
>> >>> > >>>         ....
>> >>> > >>>
>> >>> > >>> I set breakpoints on the getSelectedRecordA and
>> setSelectedRecordA
>> >>> > >> methods,
>> >>> > >>> but these aren't called when during the request cycle when the
>> >>> edit
>> >>> > >> button
>> >>> > >>> is clicked.
>> >>> > >>>
>> >>> > >>> I then changed the class so that selectedRecordA is
>> initialized to
>> >>> an
>> >>> > >> empty
>> >>> > >>> instance of RecordA. This got rid of the above error.
>> However, I
>> >>> > >> cannot
>> >>> > >>> save the edit changes because the selectedRecordA is still the
>> >>> empty
>> >>> > >>> instance that was created in the initialization and the
>> >>> persistence
>> >>> > >> layer
>> >>> > >>> throws an exception.  This same problem exists if I try to add
>> a
>> >>> new
>> >>> > >> RecordA
>> >>> > >>> or try to delete an existing one.
>> >>> > >>>
>> >>> > >>> If I choose to cancel the edit and then select another record
>> to
>> >>> edit,
>> >>> > >> I
>> >>> > >>> get the message "You must select a record to edit" (line 131).
>> >>> This
>> >>> > >> is
>> >>> > >>> because the cancel onSubmit sets selectedRecordA to null and
>> >>> choosing
>> >>> > >> the
>> >>> > >>> record from the DDC is not setting it to the chosen record.
>> >>> > >>>
>> >>> > >>> Clearly I am not setting up this CompoundPropertyModel
>> properly so
>> >>> > >> that the
>> >>> > >>> selectedARecord is set by the model.  Can someone tell me what
>> I'm
>> >>> > >> doing
>> >>> > >>> wrong?
>> >>> > >>>
>> >>> > >>> All help is greatly appreciated,
>> >>> > >>>
>> >>> > >>> Shelli
>> >>> > >>>
>> >>> > >>>
>> >>> > >>> -----Original Message-----
>> >>> > >>> From: Igor Vaynberg [mailto:[hidden
>> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=0>]
>> >>> > >>>
>> >>> > >>> Sent: Thursday, October 07, 2010 11:27 AM
>> >>> > >>> To: [hidden email]
>> >>> > >> <http://user/SendEmail.jtp?type=node&node=2968688&i=1>
>> >>> > >>> Subject: Re: PropertyModel Not Refreshing
>> >>> > >>>
>> >>> > >>> you have posted an incomplete piece of code and somehow from
>> that
>> >>> we
>> >>> > >>> are supposed to guess what is not working? create a quickstart
>> and
>> >>> > >>> provide that.
>> >>> > >>>
>> >>> > >>> -igor
>> >>> > >>>
>> >>> > >>> On Thu, Oct 7, 2010 at 10:15 AM, Shelli Orton <[hidden
>> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=2>>
>> >>> > >>> wrote:
>> >>> > >>>
>> >>> > >>> > Does nobody have any suggestions?  If I can't get this
>> fixed,
>> >>> I'm
>> >>> > >> going
>> >>> > >>> > to have to write the app in another framework (possibly GWT)
>> and
>> >>> I'd
>> >>> > >>> > really rather not have to do that.
>> >>> > >>> >
>> >>> > >>> > Shelli
>> >>> > >>> >
>> >>> > >>> > -----Original Message-----
>> >>> > >>> > From: Shelli Orton
>> >>> > >>> > Sent: Wednesday, October 06, 2010 3:52 PM
>> >>> > >>> > To: [hidden
>> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=3>
>> >>> > >>> > Subject: PropertyModel Not Refreshing
>> >>> > >>> >
>> >>> > >>> > Hi,
>> >>> > >>> >
>> >>> > >>> > First, thanks to all who have been helping me as I am new to
>> >>> Wicket.
>> >>> > >> I
>> >>> > >>> > am splitting out two issues I am dealing with to try to keep
>> >>> things
>> >>> > >>> > clear.
>> >>> > >>> >
>> >>> > >>> > I am trying to write a simple app that does CRUD operations
>> on
>> >>> > >> database
>> >>> > >>> > records.  The goal is for the app to make use of a tab panel
>> >>> where
>> >>> > >> each
>> >>> > >>> > tab encapsulates one table from the database.  Each tab
>> panel
>> >>> has
>> >>> > >> two
>> >>> > >>> > groups (WebMarkupContainer).  The first, selectGroup,
>> displays a
>> >>> > >> list
>> >>> > >>> > (DDC) of the current items, and three buttons, add, edit and
>> >>> delete.
>> >>> > >>> > The second, editGroup, is displayed when either the add or
>> edit
>> >>> > >> button
>> >>> > >>> > was clicked on the select group, displays the record
>> attributes
>> >>> and
>> >>> > >> save
>> >>> > >>> > and cancel buttons.  The tab panel has a "selectedRecord"
>> which
>> >>> is
>> >>> > >> used
>> >>> > >>> > by both groups' components via PropertyModels. Very basic
>> stuff.
>> >>> > >>> >
>> >>> > >>> > When I choose a record and click the edit button, the record
>> is
>> >>> > >>> > displayed in the edit group properly.  If I then choose
>> cancel,
>> >>> the
>> >>> > >> edit
>> >>> > >>> > group is no longer displayed and the select group DDC
>> selection
>> >>> is
>> >>> > >> null
>> >>> > >>> > as expected. I then choose another record from the list and
>> >>> click
>> >>> > >> the
>> >>> > >>> > edit button and the previous record information is displayed
>> in
>> >>> the
>> >>> > >> edit
>> >>> > >>> > group even though the select group DDC shows the
>> >>> correct/selected
>> >>> > >>> > record.
>> >>> > >>> >
>> >>> > >>> > This problem also occurs if I first choose to add a new
>> record
>> >>> and
>> >>> > >> then
>> >>> > >>> > cancel the add and then choose to edit a different record.
>> The
>> >>> DDC
>> >>> > >>> > shows the correct/selected record, but all the attributes in
>> the
>> >>> > >> edit
>> >>> > >>> > group are null/defaults for a new record.
>> >>> > >>> >
>> >>> > >>> > If I remove the call to setDefaultFormProcessing(false) on
>> the
>> >>> > >> cancel
>> >>> > >>> > button, selecting other records for edit works correctly,
>> but I
>> >>> > >> can't
>> >>> > >>> > cancel a creating a new record if I use a RequiredTextField
>> >>> because
>> >>> > >> the
>> >>> > >>> > form validation fails.
>> >>> > >>> >
>> >>> > >>> > If I select a record for editing or save the newly created
>> >>> record, I
>> >>> > >> can
>> >>> > >>> > select a different record for edit or create another one
>> >>> correctly.
>> >>> > >> So
>> >>> > >>> > I must be doing something wrong in the cancel logic. My
>> editForm
>> >>> > >>> > (created in the EditGroup constructor) looks like this:
>> >>> > >>> >
>> >>> > >>> >            Form editForm = new Form("editForm");
>> >>> > >>> >
>> >>> > >>> >            editForm.add(new Label("nameLabel", "Name"));
>> >>> > >>> >
>> >>> > >>> >            editForm.add(new Label("attributeLabel",
>> >>> "Attribute"));
>> >>> > >>> >
>> >>> > >>> >            editForm.add(new
>> >>> > >> RequiredTextField<String>("recordNameText",
>> >>> > >>> >                    new
>> PropertyModel<String>(MyRecordPanel.this,
>> >>> > >>> >                            "selectedRecord.name")));
>> >>> > >>> >
>> >>> > >>> >            editForm.add(new
>> DropDownChoice<Lir>("attributes",
>> >>> > >>> >                    new
>> >>> PropertyModel<Attribute>(MyRecordPanel.this,
>> >>> > >>> >                            "selectedRecord.attribute"),
>> >>> > >>> >                    RateCentrePanel.this.getAttributes(),
>> >>> > >>> >                    new AttributeRenderer()));
>> >>> > >>> >
>> >>> > >>> >            ....
>> >>> > >>> >
>> >>> > >>> >            editForm.add(new Button("cancel")
>> >>> > >>> >            {
>> >>> > >>> >                private static final long serialVersionUID =
>> 1L;
>> >>> > >>> >
>> >>> > >>> >                public void onSubmit()
>> >>> > >>> >                {
>> >>> > >>> >                    MyRecordPanel.this.selectedRecord = null;
>> >>> > >>> >                    editGroup.setVisible(false);
>> >>> > >>> >                    selectGroup.setVisible(true);
>> >>> > >>> >                }
>> >>> > >>> >            }.setDefaultFormProcessing(false));
>> >>> > >>> >
>> >>> > >>> >            add(editForm);
>> >>> > >>> >
>> >>> > >>> > Other than setting the selectedRecord to null, what should I
>> be
>> >>> > >> doing
>> >>> > >>> > differently?
>> >>> > >>> >
>> >>> > >>> > Thanks in advance!
>> >>> > >>> >
>> >>> > >>> > Shelli
>> >>> > >>> >
>> >>> > >>> >
>> >>> > >>
>> >>>
>> ---------------------------------------------------------------------
>> >>> > >>> > To unsubscribe, e-mail: [hidden
>> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=4>
>> >>> > >>> > For additional commands, e-mail: [hidden
>> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=5>
>> >>> > >>> >
>> >>> > >>> >
>> >>> > >>> >
>> >>> > >>
>> >>>
>> ---------------------------------------------------------------------
>> >>> > >>> > To unsubscribe, e-mail: [hidden
>> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=6>
>> >>> > >>> > For additional commands, e-mail: [hidden
>> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=7>
>> >>> > >>> >
>> >>> > >>> >
>> >>> > >>>
>> >>>
>> ---------------------------------------------------------------------
>> >>> > >>> To unsubscribe, e-mail: [hidden
>> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=8>
>> >>> > >>> For additional commands, e-mail: [hidden
>> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=9>
>> >>> > >>>
>> >>> > >>>
>> >>> > >>>
>> >>> > >>>
>> >>> > >>>
>> >>>
>> ---------------------------------------------------------------------
>> >>> > >>> To unsubscribe, e-mail: [hidden
>> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=10>
>> >>> > >>> For additional commands, e-mail: [hidden
>> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=11>
>> >>> > >>>
>> >>> > >>> ------------------------------
>> >>> > >>>  View message @
>> >>> > >>>
>> >>> > >>
>> >>> >
>> >>>
>> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
>> >>> > >> n-tp2955144p2968688.html
>> >>> > >>> To start a new topic under Apache Wicket, email
>> >>> > >>>
>> >>> > >>
>> >>>
>> ml-node+1842946-398011874-65838@n4.nabble.com<ml...@n4.nabble.com>
>> <ml-node%2B1842946-39801187
>> 4-65838@n4.nabble.com>
>> >>> <ml-node%2B1842946-39801187
>> >>> 4-65838@n4.nabble.com>
>> >>> > <ml-node%2B1842946-39801187
>> >>> > >> 4-65838@n4.nabble.com>
>> >>> > >>> To unsubscribe from Apache Wicket, click
>> >>> > >>
>> >>>
>> here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp
>> >>> > ?
>> >>> > >>
>> >>>
>> tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
>> >>> > >> QyOTQ2fDEyNTYxMzc3ODY=>.
>> >>> > >>>
>> >>> > >>>
>> >>> > >>>
>> >>> > >>
>> >>> > >>
>> >>> > >> --
>> >>> > >> Sincerely,
>> >>> > >> JC (http://www.linkedin.com/in/jcgarciam)
>> >>> > >> Work smarter, not harder!.
>> >>> > >>
>> >>> > >> --
>> >>> > >> View this message in context:
>> >>> > >>
>> >>> >
>> >>>
>> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
>> >>> > >> n-tp2955144p2968936.html
>> >>> > >> Sent from the Users forum mailing list archive at Nabble.com.
>> >>> > >>
>> >>> > >>
>> >>>
>> ---------------------------------------------------------------------
>> >>> > >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >>> > >> For additional commands, e-mail: users-help@wicket.apache.org
>> >>> > >>
>> >>> > >>
>> >>> > >>
>> >>> > >>
>> >>>
>> ---------------------------------------------------------------------
>> >>> > >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >>> > >> For additional commands, e-mail: users-help@wicket.apache.org
>> >>> > >>
>> >>> > >
>> >>> > >
>> >>>
>> ---------------------------------------------------------------------
>> >>> > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >>> > > For additional commands, e-mail: users-help@wicket.apache.org
>> >>> > >
>> >>> > >
>> >>> > >
>> >>>
>> ---------------------------------------------------------------------
>> >>> > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >>> > > For additional commands, e-mail: users-help@wicket.apache.org
>> >>> > >
>> >>> > >
>> >>> >
>> >>> >
>> ---------------------------------------------------------------------
>> >>> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >>> > For additional commands, e-mail: users-help@wicket.apache.org
>> >>> >
>> >>> >
>> >>> >
>> ---------------------------------------------------------------------
>> >>> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >>> > For additional commands, e-mail: users-help@wicket.apache.org
>> >>> >
>> >>> >
>> >>>
>> >>>
>> ---------------------------------------------------------------------
>> >>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >>> For additional commands, e-mail: users-help@wicket.apache.org
>> >>>
>> >>>
>> >>
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>

Re: PropertyModel Not Refreshing

Posted by nino martinez wael <ni...@gmail.com>.
Think I was going in the wrong direction.. Looking at the error, seems to
get triggered by pressing the cancel button only..

2010/10/12 Shelli Orton <Sh...@sjrb.ca>

> This is where my confusion about models may be kicking in.  I thought
> that property models (PropertModel or CompoundPropertyModel)
> automatically checked if the model object changed.  How do I tell the
> model it has?
>
> Shelli
>
> -----Original Message-----
> From: nino martinez wael [mailto:nino.martinez.wael@gmail.com]
> Sent: Tuesday, October 12, 2010 12:10 PM
> To: users@wicket.apache.org
> Subject: Re: PropertyModel Not Refreshing
>
> in your add button you call setSelectedRecordA(new RecordA()) but never
> notify the model that a change has occured...
>
> 2010/10/12 nino martinez wael <ni...@gmail.com>
>
> > hmm getting a lot of errors on the services not implementing
> > serialization...
> >
> > But does seem theres a difference between calling :
> >
> > selectedRecordAModel.getObject().getName() and
> > RecordAPanel.this.selectedRecordA
> >
> > 2010/10/12 nino martinez wael <ni...@gmail.com>
> >
> > sorry.. Did'nt see it attached.. So did igor provide you with an fixed
> >> quickstart (working on his system).. That did not work on glassfish?
> >>
> >>
> >> 2010/10/12 Shelli Orton <Sh...@sjrb.ca>
> >>
> >>> The quickstart was sent to the list this morning at 10:04 MST.  Does
> it
> >>> need to be resent?
> >>>
> >>> Shelli
> >>>
> >>> -----Original Message-----
> >>> From: nino martinez wael [mailto:nino.martinez.wael@gmail.com]
> >>> Sent: Tuesday, October 12, 2010 11:52 AM
> >>> To: users@wicket.apache.org
> >>> Subject: Re: PropertyModel Not Refreshing
> >>>
> >>> No dont think so.. Please provide a quickstart.. I have had property
> >>> models
> >>> working in 1.2, 1.3, 1.4 and 1.5 so must be error 42:)
> >>>
> >>> 2010/10/12 Shelli Orton <Sh...@sjrb.ca>
> >>>
> >>> > Hi,
> >>> >
> >>> > Thanks for file.  Your first email was missing these changes:
> >>> >
> >>> >    IModel<RecordA> selectedRecordAModel;  (I had set mine to
> >>> > PropertyModel<RecordA> selectedRecordAModel;)
> >>> >    recordAs.setModel(selectedRecordAModel)
> >>> >
> >>> > However, even with those changes applied, I still get the same
> issue
> >>> of the
> >>> > selected record not updating in the edit group.
> >>> >
> >>> > I am deploying in Glassfish v3.  Could that have anything to do
> with
> >>> my
> >>> > problems?
> >>> >
> >>> > Shelli
> >>> >
> >>> > -----Original Message-----
> >>> > From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
> >>> > Sent: Tuesday, October 12, 2010 11:35 AM
> >>> > To: users@wicket.apache.org
> >>> > Subject: Re: PropertyModel Not Refreshing
> >>> >
> >>> > On Tue, Oct 12, 2010 at 10:30 AM, Shelli Orton
> <Sh...@sjrb.ca>
> >>> > wrote:
> >>> > > Thanks for the help.  Your changes got rid of the errors and I
> can
> >>> delete
> >>> > records now (and the list is updated).
> >>> > >
> >>> > > However, once a record has been selected for edit and either
> saved
> >>> or
> >>> > cancelled, that same record is always displayed in the edit group
> when
> >>> I
> >>> > choose another record to edit or even when I try to create a new
> one.
> >>> I can
> >>> > even delete the chosen record and it still displays in the edit
> group.
> >>> >
> >>> > works fine here, meaning you did not completely/propery apply my
> >>> > changes. below is the complete file.
> >>> >
> >>> > -igor
> >>> >
> >>> > public class RecordAPanel extends Panel
> >>> > {
> >>> >    private static final long serialVersionUID = 1L;
> >>> >
> >>> >    RecordAService recordAService;
> >>> >    RecordBService recordBService;
> >>> >
> >>> >    RecordA selectedRecordA = new RecordA();
> >>> >    IModel<RecordA> selectedRecordAModel;
> >>> >    String unmodifiedRecordA;
> >>> >
> >>> >    boolean isNew = false;
> >>> >
> >>> >    WebMarkupContainer selectGroup;
> >>> >    WebMarkupContainer editGroup;
> >>> >
> >>> >    Form selectForm;
> >>> >    Form editForm;
> >>> >
> >>> >    DropDownChoice<RecordA> recordAs;
> >>> >    DropDownChoice<RecordB> recordBs;
> >>> >
> >>> >    Button add;
> >>> >    Button edit;
> >>> >    Button save;
> >>> >    Button delete;
> >>> >    Button cancel;
> >>> >
> >>> >    Label editLegendLabel;
> >>> >    String editLegend;
> >>> >    Label recordALabel;
> >>> >    Label recordBLabel;
> >>> >
> >>> >    RequiredTextField recordAText;
> >>> >
> >>> >    @SuppressWarnings({ "rawtypes", "unchecked" })
> >>> >    public RecordAPanel(String id)
> >>> >    {
> >>> >        super(id);
> >>> >
> >>> >        recordAService = ((Application)
> >>> > RequestCycle.get().getApplication()).getRecordAService();
> >>> >        recordBService = ((Application)
> >>> > RequestCycle.get().getApplication()).getRecordBService();
> >>> >
> >>> >        selectedRecordAModel = new PropertyModel<RecordA>(this,
> >>> > "selectedRecordA");
> >>> >        this.setDefaultModel(selectedRecordAModel);
> >>> >
> >>> >        // ************* Select  Group *************
> >>> >
> >>> >        selectGroup = new WebMarkupContainer("selectGroup");
> >>> >        selectForm = new Form("selectForm");
> >>> >
> >>> >        recordAs = new DropDownChoice<RecordA>("recordAs");
> >>> >        recordAs.setModel(selectedRecordAModel);
> >>> >        recordAs.setChoices(recordAsModel);
> >>> >        recordAs.setChoiceRenderer(new RecordARenderer());
> >>> >
> >>> >        //            recordAs = (DropDownChoice<RecordA>) new
> >>> > DropDownChoice<RecordA>("recordAs",
> >>> >        //                    new PropertyModel<RecordA>(this,
> >>> > "selectedRecordA"),
> >>> >        //                    recordAsModel,
> >>> >        //                    new RecordARenderer());
> >>> >
> >>> >        recordAs.setNullValid(false);
> >>> >
> >>> >        selectForm.add(recordAs);
> >>> >
> >>> >        add = new Button("add")
> >>> >        {
> >>> >            private static final long serialVersionUID = 1L;
> >>> >
> >>> >            public void onSubmit()
> >>> >            {
> >>> >                setSelectedRecordA(new RecordA());
> >>> >                isNew = true;
> >>> >                editLegend = "New";
> >>> >                editGroup.setVisible(true);
> >>> >                selectGroup.setVisible(false);
> >>> >            }
> >>> >        };
> >>> >
> >>> >        selectForm.add(add);
> >>> >
> >>> >        edit = new Button("edit")
> >>> >        {
> >>> >            private static final long serialVersionUID = 1L;
> >>> >
> >>> >            public void onSubmit()
> >>> >            {
> >>> >                if (selectedRecordA == null)
> >>> >                {
> >>> >                    info("You must select a record to edit.");
> >>> >                }
> >>> >                else
> >>> >                {
> >>> >                    unmodifiedRecordA = selectedRecordA.getName();
> >>> >                    isNew = false;
> >>> >                    editLegend = "Edit";
> >>> >                    editGroup.setVisible(true);
> >>> >                    selectGroup.setVisible(false);
> >>> >                }
> >>> >            }
> >>> >        };
> >>> >
> >>> >        selectForm.add(edit);
> >>> >
> >>> >        delete = new Button("delete")
> >>> >        {
> >>> >            private static final long serialVersionUID = 1L;
> >>> >
> >>> >            public void onSubmit()
> >>> >            {
> >>> >                if (selectedRecordA == null)
> >>> >                {
> >>> >                    info("You must select a record to delete.");
> >>> >                }
> >>> >                else
> >>> >                {
> >>> >                    // Delete the selected record
> >>> >                    unmodifiedRecordA = selectedRecordA.getName();
> >>> >
> recordAService.delete(selectedRecordA.getName());
> >>> >                    selectedRecordA = null;
> >>> >                    info("Deleted '" + unmodifiedRecordA + "'");
> >>> >
> >>> >                    // Force refresh of records list
> >>> >                    RecordAPanel.this.recordAsModel.detach();
> >>> >                }
> >>> >            }
> >>> >        };
> >>> >
> >>> >        // Add confirmation dialog box
> >>> >        delete.add(new SimpleAttributeModifier("onclick",
> >>> >                "if (!confirm('Please confirm you want to delete
> this
> >>> > record') ){ return false; }"));
> >>> >
> >>> >        selectForm.add(delete);
> >>> >        selectGroup.add(selectForm);
> >>> >
> >>> >        this.add(selectGroup);
> >>> >
> >>> >        // ************* Edit Group *************
> >>> >
> >>> >        editGroup = new WebMarkupContainer("editGroup");
> >>> >
> >>> >        editLegendLabel = new Label("editLegend", new
> >>> PropertyModel(this,
> >>> >                "editLegend"));
> >>> >
> >>> >        editGroup.add(editLegendLabel);
> >>> >
> >>> >        editForm = new Form("editForm");
> >>> >
> >>> >        recordALabel = new Label("recordALabel", "Record A");
> >>> >        editForm.add(recordALabel);
> >>> >
> >>> >        recordBLabel = new Label("recordBLabel", "Record B");
> >>> >        editForm.add(recordBLabel);
> >>> >
> >>> >        recordAText = new RequiredTextField("recordAText",
> >>> >                new PropertyModel(selectedRecordAModel, "name"));
> >>> >
> >>> >        editForm.add(recordAText);
> >>> >
> >>> >        recordBs = new DropDownChoice<RecordB>("recordBs");
> >>> >        recordBs.setModel(new PropertyModel(selectedRecordAModel,
> >>> > "recordB"));
> >>> >        recordBs.setChoices(RecordAPanel.this.getRecordBs());
> >>> >        recordBs.setChoiceRenderer(new RecordBRenderer());
> >>> >
> >>> >        editForm.add(recordBs);
> >>> >
> >>> >        save = new Button("save")
> >>> >        {
> >>> >            private static final long serialVersionUID = 1L;
> >>> >
> >>> >            @Override
> >>> >            public void onSubmit()
> >>> >            {
> >>> >                if (isNew)
> >>> >                {
> >>> >
> >>> > recordAService.create(RecordAPanel.this.selectedRecordA);
> >>> >                        info("Created '"
> >>> >                                +
> >>> > RecordAPanel.this.selectedRecordA.getName()
> >>> >                                + "'");
> >>> >                }
> >>> >                else
> >>> >                {
> >>> >                        recordAService.update(unmodifiedRecordA,
> >>> >                                RecordAPanel.this.selectedRecordA);
> >>> >                        info("Updated '"
> >>> >                                +
> >>> > RecordAPanel.this.selectedRecordA.getName()
> >>> >                                + "'");
> >>> >                }
> >>> >
> >>> >                // TODO Update the dropdown list?
> >>> >
> >>> >                editGroup.setVisible(false);
> >>> >                selectGroup.setVisible(true);
> >>> >            }
> >>> >        };
> >>> >
> >>> >        editForm.add(save);
> >>> >
> >>> >        cancel = new Button("cancel")
> >>> >        {
> >>> >            private static final long serialVersionUID = 1L;
> >>> >
> >>> >            public void onSubmit()
> >>> >            {
> >>> >                RecordAPanel.this.selectedRecordA = null;
> >>> >                editGroup.setVisible(false);
> >>> >                selectGroup.setVisible(true);
> >>> >            }
> >>> >        };
> >>> >
> >>> >        cancel.setDefaultFormProcessing(false);
> >>> >        editForm.add(cancel);
> >>> >
> >>> >        editGroup.add(editForm);
> >>> >
> >>> >        editGroup.setVisible(false);
> >>> >        this.add(editGroup);
> >>> >    }
> >>> >
> >>> >    public RecordA getSelectedRecordA()
> >>> >    {
> >>> >        return selectedRecordA;
> >>> >    }
> >>> >
> >>> >    public void setSelectedRecordA(RecordA selectedRecordA)
> >>> >    {
> >>> >        this.selectedRecordA = selectedRecordA;
> >>> >    }
> >>> >
> >>> >    public LoadableDetachableModel<List<RecordA>> recordAsModel =
> new
> >>> > LoadableDetachableModel<List<RecordA>>()
> >>> >    {
> >>> >        private static final long serialVersionUID = 1L;
> >>> >
> >>> >        @Override
> >>> >        protected List<RecordA> load()
> >>> >        {
> >>> >            return recordAService.getList();
> >>> >        }
> >>> >
> >>> >        public void detach()
> >>> >        {
> >>> >            super.detach();
> >>> >        }
> >>> >    };
> >>> >
> >>> >    // TODO change this to LDM?
> >>> >    List<RecordB> getRecordBs()
> >>> >    {
> >>> >        return recordBService.getList();
> >>> >    }
> >>> >
> >>> >    class RecordARenderer implements IChoiceRenderer<RecordA>
> >>> >    {
> >>> >        private static final long serialVersionUID = 1L;
> >>> >
> >>> >        public Object getDisplayValue(RecordA recordA)
> >>> >        {
> >>> >            return recordA.getName();
> >>> >        }
> >>> >
> >>> >        public String getIdValue(RecordA recordA, int index)
> >>> >        {
> >>> >            return recordA.getName();
> >>> >        }
> >>> >    }
> >>> >
> >>> >    class RecordBRenderer implements IChoiceRenderer<RecordB>
> >>> >    {
> >>> >        private static final long serialVersionUID = 1L;
> >>> >
> >>> >        public Object getDisplayValue(RecordB recordB)
> >>> >        {
> >>> >            return recordB.getName();
> >>> >        }
> >>> >
> >>> >        public String getIdValue(RecordB recordB, int index)
> >>> >        {
> >>> >            return recordB.getName();
> >>> >        }
> >>> >    }
> >>> > }
> >>> >
> >>> > >
> >>> > > Shelli
> >>> > >
> >>> > > -----Original Message-----
> >>> > > From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
> >>> > > Sent: Tuesday, October 12, 2010 10:38 AM
> >>> > > To: users@wicket.apache.org
> >>> > > Subject: Re: PropertyModel Not Refreshing
> >>> > >
> >>> > > here are the tweaks you need to make this work:
> >>> > >
> >>> > > selectedRecordAModel = new PropertyModel<RecordA>(this,
> >>> > "selectedRecordA");
> >>> > >
> >>> > > recordAText = new RequiredTextField("recordAText",
> >>> > >                new PropertyModel(selectedRecordAModel, "name"));
> >>> > >
> >>> > >  recordBs.setModel(new PropertyModel(selectedRecordAModel,
> >>> "recordB"));
> >>> > >
> >>> > > have fun
> >>> > >
> >>> > > -igor
> >>> > >
> >>> > > On Tue, Oct 12, 2010 at 9:03 AM, Shelli Orton
> <Sh...@sjrb.ca>
> >>> > wrote:
> >>> > >> I've been able to create a sample application that exhibits the
> >>> > >> same/similar problems to mine.  The sample makes use of an
> >>> in-memory
> >>> > >> list for the data versus accessing a database and so there's
> some
> >>> > >> differences.  However, I believe the problems that this sample
> >>> exhibits
> >>> > >> have the same root cause as my project (which I believe have
> >>> something
> >>> > >> to do with how my models are set up...).
> >>> > >>
> >>> > >> Issues this sample exhibits:
> >>> > >>
> >>> > >> 1. Choose to edit an existing record, then cancel the edit.
> Choose
> >>> > >> another/the same record to edit and the selected record is null
> >>> (error
> >>> > >> message "You must select a record to edit" is displayed).  Must
> >>> > >> close/open session to reset.
> >>> > >>
> >>> > >> 2. Choose to edit an existing record and save the edit.  Choose
> >>> > >> another/the same record to edit and you get a NPE:
> >>> > >>
> >>> > >>    WicketMessage: Method onFormSubmitted of interface
> >>> > >> org.apache.wicket.markup.html.form.IFormSubmitListener targeted
> at
> >>> > >> component [MarkupContainer [Component id = selectForm]] threw
> an
> >>> > >> exception
> >>> > >>
> >>> > >>    Root cause:
> >>> > >>
> >>> > >>    java.lang.NullPointerException
> >>> > >>    at
> >>> > >>
> >>>
> org.apache.wicket.markup.html.form.AbstractSingleSelectChoice.convertCho
> >>> > >> iceIdToChoice(AbstractSingleSelectChoice.java:247)
> >>> > >>
> >>> > >> 3. Create a new record and try to save it and get
> >>> > >> WicketRuntimeException:
> >>> > >>
> >>> > >>    WicketMessage: Attempted to set property value on a null
> object.
> >>> > >> Property expression: name Value: New One
> >>> > >>
> >>> > >>    Root cause:
> >>> > >>
> >>> > >>    org.apache.wicket.WicketRuntimeException: Attempted to set
> >>> property
> >>> > >> value on a null object. Property expression: name Value: New
> One
> >>> > >>    at
> >>> > >>
> >>>
> org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.j
> >>> > >> ava:125)
> >>> > >>
> >>> > >> 4. Create a new record and then cancel the add, Choose an
> existing
> >>> > >> record to edit and the selected record is null (error message
> "You
> >>> must
> >>> > >> select a record to edit" is displayed).  Must close/open
> session to
> >>> > >> reset.
> >>> > >>
> >>> > >> As always, all help is greatly appreciated as I am stumped.
> >>> > >>
> >>> > >> Thanks,
> >>> > >> Shelli
> >>> > >>
> >>> > >> -----Original Message-----
> >>> > >> From: jcgarciam [mailto:jcgarciam@gmail.com]
> >>> > >> Sent: Friday, October 08, 2010 1:41 PM
> >>> > >> To: users@wicket.apache.org
> >>> > >> Subject: Re: PropertyModel Not Refreshing
> >>> > >>
> >>> > >>
> >>> > >> The attachment didn't make it,
> >>> > >>
> >>> > >> Can you try to extract out the relevant part and creates a
> >>> quickstart
> >>> > >> project that actually reproduces your issue?
> >>> > >>
> >>> > >>
> >>> > >> On Fri, Oct 8, 2010 at 1:41 PM, Shelli Orton [via Apache
> Wicket] <
> >>> > >>
> >>>
> ml-node+2968688-305091622-65838@n4.nabble.com<ml...@n4.nabble.com>
> <ml-node%2B2968688-30509162
> 2-65838@n4.nabble.com>
> >>> <ml-node%2B2968688-30509162
> >>> 2-65838@n4.nabble.com>
> >>> > <ml-node%2B2968688-30509162
> >>> > >> 2-65838@n4.nabble.com>
> >>> > >>> wrote:
> >>> > >>
> >>> > >>> Hi,
> >>> > >>>
> >>> > >>> I have been trying different things to see if I could get my
> code
> >>> to
> >>> > >> work
> >>> > >>> (and understand Wicket models better), but am still stuck.  I
> have
> >>> a
> >>> > >>> attached the (latest) panel class code which I hope is
> sufficient
> >>> to
> >>> > >> help.
> >>> > >>>
> >>> > >>> I was reading about different models (both online and the
> Wicket
> >>> in
> >>> > >> Action
> >>> > >>> book) and thought that perhaps using a CompoundPropertyModel
> was
> >>> more
> >>> > >>> appropriate and may help with my issues.  Originally, I only
> >>> declared
> >>> > >>> selectedRecordA (line 40) but didn't instantiate it.  The
> select
> >>> group
> >>> > >>> displayed properly but when I chose a record from the list and
> >>> tried
> >>> > >> to edit
> >>> > >>> it, this exception was thrown:
> >>> > >>>
> >>> > >>>     WicketMessage: Attempted to set property value on a null
> >>> object.
> >>> > >>> Property expression: recordA Value: Name=A-One
> >>> > >>>     Root cause:
> >>> > >>>
> >>> > >>>     org.apache.wicket.WicketRuntimeException: Attempted to set
> >>> > >> property
> >>> > >>> value on a null object. Property expression: recordA Value:
> >>> Name=A-One
> >>> > >>>         at
> >>> > >>>
> >>> > >>
> >>>
> org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.j
> >>> > >> ava:125)
> >>> > >>>
> >>> > >>>         at
> >>> > >>>
> >>> > >>
> >>>
> org.apache.wicket.model.AbstractPropertyModel.setObject(AbstractProperty
> >>> > >> Model.java:169)
> >>> > >>>
> >>> > >>>         at
> >>> > >>>
> >>>
> org.apache.wicket.Component.setDefaultModelObject(Component.java:3125)
> >>> > >>>         ....
> >>> > >>>
> >>> > >>> I set breakpoints on the getSelectedRecordA and
> setSelectedRecordA
> >>> > >> methods,
> >>> > >>> but these aren't called when during the request cycle when the
> >>> edit
> >>> > >> button
> >>> > >>> is clicked.
> >>> > >>>
> >>> > >>> I then changed the class so that selectedRecordA is
> initialized to
> >>> an
> >>> > >> empty
> >>> > >>> instance of RecordA. This got rid of the above error.
> However, I
> >>> > >> cannot
> >>> > >>> save the edit changes because the selectedRecordA is still the
> >>> empty
> >>> > >>> instance that was created in the initialization and the
> >>> persistence
> >>> > >> layer
> >>> > >>> throws an exception.  This same problem exists if I try to add
> a
> >>> new
> >>> > >> RecordA
> >>> > >>> or try to delete an existing one.
> >>> > >>>
> >>> > >>> If I choose to cancel the edit and then select another record
> to
> >>> edit,
> >>> > >> I
> >>> > >>> get the message "You must select a record to edit" (line 131).
> >>> This
> >>> > >> is
> >>> > >>> because the cancel onSubmit sets selectedRecordA to null and
> >>> choosing
> >>> > >> the
> >>> > >>> record from the DDC is not setting it to the chosen record.
> >>> > >>>
> >>> > >>> Clearly I am not setting up this CompoundPropertyModel
> properly so
> >>> > >> that the
> >>> > >>> selectedARecord is set by the model.  Can someone tell me what
> I'm
> >>> > >> doing
> >>> > >>> wrong?
> >>> > >>>
> >>> > >>> All help is greatly appreciated,
> >>> > >>>
> >>> > >>> Shelli
> >>> > >>>
> >>> > >>>
> >>> > >>> -----Original Message-----
> >>> > >>> From: Igor Vaynberg [mailto:[hidden
> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=0>]
> >>> > >>>
> >>> > >>> Sent: Thursday, October 07, 2010 11:27 AM
> >>> > >>> To: [hidden email]
> >>> > >> <http://user/SendEmail.jtp?type=node&node=2968688&i=1>
> >>> > >>> Subject: Re: PropertyModel Not Refreshing
> >>> > >>>
> >>> > >>> you have posted an incomplete piece of code and somehow from
> that
> >>> we
> >>> > >>> are supposed to guess what is not working? create a quickstart
> and
> >>> > >>> provide that.
> >>> > >>>
> >>> > >>> -igor
> >>> > >>>
> >>> > >>> On Thu, Oct 7, 2010 at 10:15 AM, Shelli Orton <[hidden
> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=2>>
> >>> > >>> wrote:
> >>> > >>>
> >>> > >>> > Does nobody have any suggestions?  If I can't get this
> fixed,
> >>> I'm
> >>> > >> going
> >>> > >>> > to have to write the app in another framework (possibly GWT)
> and
> >>> I'd
> >>> > >>> > really rather not have to do that.
> >>> > >>> >
> >>> > >>> > Shelli
> >>> > >>> >
> >>> > >>> > -----Original Message-----
> >>> > >>> > From: Shelli Orton
> >>> > >>> > Sent: Wednesday, October 06, 2010 3:52 PM
> >>> > >>> > To: [hidden
> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=3>
> >>> > >>> > Subject: PropertyModel Not Refreshing
> >>> > >>> >
> >>> > >>> > Hi,
> >>> > >>> >
> >>> > >>> > First, thanks to all who have been helping me as I am new to
> >>> Wicket.
> >>> > >> I
> >>> > >>> > am splitting out two issues I am dealing with to try to keep
> >>> things
> >>> > >>> > clear.
> >>> > >>> >
> >>> > >>> > I am trying to write a simple app that does CRUD operations
> on
> >>> > >> database
> >>> > >>> > records.  The goal is for the app to make use of a tab panel
> >>> where
> >>> > >> each
> >>> > >>> > tab encapsulates one table from the database.  Each tab
> panel
> >>> has
> >>> > >> two
> >>> > >>> > groups (WebMarkupContainer).  The first, selectGroup,
> displays a
> >>> > >> list
> >>> > >>> > (DDC) of the current items, and three buttons, add, edit and
> >>> delete.
> >>> > >>> > The second, editGroup, is displayed when either the add or
> edit
> >>> > >> button
> >>> > >>> > was clicked on the select group, displays the record
> attributes
> >>> and
> >>> > >> save
> >>> > >>> > and cancel buttons.  The tab panel has a "selectedRecord"
> which
> >>> is
> >>> > >> used
> >>> > >>> > by both groups' components via PropertyModels. Very basic
> stuff.
> >>> > >>> >
> >>> > >>> > When I choose a record and click the edit button, the record
> is
> >>> > >>> > displayed in the edit group properly.  If I then choose
> cancel,
> >>> the
> >>> > >> edit
> >>> > >>> > group is no longer displayed and the select group DDC
> selection
> >>> is
> >>> > >> null
> >>> > >>> > as expected. I then choose another record from the list and
> >>> click
> >>> > >> the
> >>> > >>> > edit button and the previous record information is displayed
> in
> >>> the
> >>> > >> edit
> >>> > >>> > group even though the select group DDC shows the
> >>> correct/selected
> >>> > >>> > record.
> >>> > >>> >
> >>> > >>> > This problem also occurs if I first choose to add a new
> record
> >>> and
> >>> > >> then
> >>> > >>> > cancel the add and then choose to edit a different record.
> The
> >>> DDC
> >>> > >>> > shows the correct/selected record, but all the attributes in
> the
> >>> > >> edit
> >>> > >>> > group are null/defaults for a new record.
> >>> > >>> >
> >>> > >>> > If I remove the call to setDefaultFormProcessing(false) on
> the
> >>> > >> cancel
> >>> > >>> > button, selecting other records for edit works correctly,
> but I
> >>> > >> can't
> >>> > >>> > cancel a creating a new record if I use a RequiredTextField
> >>> because
> >>> > >> the
> >>> > >>> > form validation fails.
> >>> > >>> >
> >>> > >>> > If I select a record for editing or save the newly created
> >>> record, I
> >>> > >> can
> >>> > >>> > select a different record for edit or create another one
> >>> correctly.
> >>> > >> So
> >>> > >>> > I must be doing something wrong in the cancel logic. My
> editForm
> >>> > >>> > (created in the EditGroup constructor) looks like this:
> >>> > >>> >
> >>> > >>> >            Form editForm = new Form("editForm");
> >>> > >>> >
> >>> > >>> >            editForm.add(new Label("nameLabel", "Name"));
> >>> > >>> >
> >>> > >>> >            editForm.add(new Label("attributeLabel",
> >>> "Attribute"));
> >>> > >>> >
> >>> > >>> >            editForm.add(new
> >>> > >> RequiredTextField<String>("recordNameText",
> >>> > >>> >                    new
> PropertyModel<String>(MyRecordPanel.this,
> >>> > >>> >                            "selectedRecord.name")));
> >>> > >>> >
> >>> > >>> >            editForm.add(new
> DropDownChoice<Lir>("attributes",
> >>> > >>> >                    new
> >>> PropertyModel<Attribute>(MyRecordPanel.this,
> >>> > >>> >                            "selectedRecord.attribute"),
> >>> > >>> >                    RateCentrePanel.this.getAttributes(),
> >>> > >>> >                    new AttributeRenderer()));
> >>> > >>> >
> >>> > >>> >            ....
> >>> > >>> >
> >>> > >>> >            editForm.add(new Button("cancel")
> >>> > >>> >            {
> >>> > >>> >                private static final long serialVersionUID =
> 1L;
> >>> > >>> >
> >>> > >>> >                public void onSubmit()
> >>> > >>> >                {
> >>> > >>> >                    MyRecordPanel.this.selectedRecord = null;
> >>> > >>> >                    editGroup.setVisible(false);
> >>> > >>> >                    selectGroup.setVisible(true);
> >>> > >>> >                }
> >>> > >>> >            }.setDefaultFormProcessing(false));
> >>> > >>> >
> >>> > >>> >            add(editForm);
> >>> > >>> >
> >>> > >>> > Other than setting the selectedRecord to null, what should I
> be
> >>> > >> doing
> >>> > >>> > differently?
> >>> > >>> >
> >>> > >>> > Thanks in advance!
> >>> > >>> >
> >>> > >>> > Shelli
> >>> > >>> >
> >>> > >>> >
> >>> > >>
> >>>
> ---------------------------------------------------------------------
> >>> > >>> > To unsubscribe, e-mail: [hidden
> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=4>
> >>> > >>> > For additional commands, e-mail: [hidden
> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=5>
> >>> > >>> >
> >>> > >>> >
> >>> > >>> >
> >>> > >>
> >>>
> ---------------------------------------------------------------------
> >>> > >>> > To unsubscribe, e-mail: [hidden
> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=6>
> >>> > >>> > For additional commands, e-mail: [hidden
> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=7>
> >>> > >>> >
> >>> > >>> >
> >>> > >>>
> >>>
> ---------------------------------------------------------------------
> >>> > >>> To unsubscribe, e-mail: [hidden
> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=8>
> >>> > >>> For additional commands, e-mail: [hidden
> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=9>
> >>> > >>>
> >>> > >>>
> >>> > >>>
> >>> > >>>
> >>> > >>>
> >>>
> ---------------------------------------------------------------------
> >>> > >>> To unsubscribe, e-mail: [hidden
> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=10>
> >>> > >>> For additional commands, e-mail: [hidden
> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=11>
> >>> > >>>
> >>> > >>> ------------------------------
> >>> > >>>  View message @
> >>> > >>>
> >>> > >>
> >>> >
> >>>
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
> >>> > >> n-tp2955144p2968688.html
> >>> > >>> To start a new topic under Apache Wicket, email
> >>> > >>>
> >>> > >>
> >>>
> ml-node+1842946-398011874-65838@n4.nabble.com<ml...@n4.nabble.com>
> <ml-node%2B1842946-39801187
> 4-65838@n4.nabble.com>
> >>> <ml-node%2B1842946-39801187
> >>> 4-65838@n4.nabble.com>
> >>> > <ml-node%2B1842946-39801187
> >>> > >> 4-65838@n4.nabble.com>
> >>> > >>> To unsubscribe from Apache Wicket, click
> >>> > >>
> >>>
> here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp
> >>> > ?
> >>> > >>
> >>>
> tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
> >>> > >> QyOTQ2fDEyNTYxMzc3ODY=>.
> >>> > >>>
> >>> > >>>
> >>> > >>>
> >>> > >>
> >>> > >>
> >>> > >> --
> >>> > >> Sincerely,
> >>> > >> JC (http://www.linkedin.com/in/jcgarciam)
> >>> > >> Work smarter, not harder!.
> >>> > >>
> >>> > >> --
> >>> > >> View this message in context:
> >>> > >>
> >>> >
> >>>
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
> >>> > >> n-tp2955144p2968936.html
> >>> > >> Sent from the Users forum mailing list archive at Nabble.com.
> >>> > >>
> >>> > >>
> >>>
> ---------------------------------------------------------------------
> >>> > >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >>> > >> For additional commands, e-mail: users-help@wicket.apache.org
> >>> > >>
> >>> > >>
> >>> > >>
> >>> > >>
> >>>
> ---------------------------------------------------------------------
> >>> > >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >>> > >> For additional commands, e-mail: users-help@wicket.apache.org
> >>> > >>
> >>> > >
> >>> > >
> >>>
> ---------------------------------------------------------------------
> >>> > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >>> > > For additional commands, e-mail: users-help@wicket.apache.org
> >>> > >
> >>> > >
> >>> > >
> >>>
> ---------------------------------------------------------------------
> >>> > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >>> > > For additional commands, e-mail: users-help@wicket.apache.org
> >>> > >
> >>> > >
> >>> >
> >>> >
> ---------------------------------------------------------------------
> >>> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >>> > For additional commands, e-mail: users-help@wicket.apache.org
> >>> >
> >>> >
> >>> >
> ---------------------------------------------------------------------
> >>> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >>> > For additional commands, e-mail: users-help@wicket.apache.org
> >>> >
> >>> >
> >>>
> >>>
> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >>> For additional commands, e-mail: users-help@wicket.apache.org
> >>>
> >>>
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

RE: PropertyModel Not Refreshing

Posted by Shelli Orton <Sh...@sjrb.ca>.
This is where my confusion about models may be kicking in.  I thought
that property models (PropertModel or CompoundPropertyModel)
automatically checked if the model object changed.  How do I tell the
model it has?

Shelli

-----Original Message-----
From: nino martinez wael [mailto:nino.martinez.wael@gmail.com] 
Sent: Tuesday, October 12, 2010 12:10 PM
To: users@wicket.apache.org
Subject: Re: PropertyModel Not Refreshing

in your add button you call setSelectedRecordA(new RecordA()) but never
notify the model that a change has occured...

2010/10/12 nino martinez wael <ni...@gmail.com>

> hmm getting a lot of errors on the services not implementing
> serialization...
>
> But does seem theres a difference between calling :
>
> selectedRecordAModel.getObject().getName() and
> RecordAPanel.this.selectedRecordA
>
> 2010/10/12 nino martinez wael <ni...@gmail.com>
>
> sorry.. Did'nt see it attached.. So did igor provide you with an fixed
>> quickstart (working on his system).. That did not work on glassfish?
>>
>>
>> 2010/10/12 Shelli Orton <Sh...@sjrb.ca>
>>
>>> The quickstart was sent to the list this morning at 10:04 MST.  Does
it
>>> need to be resent?
>>>
>>> Shelli
>>>
>>> -----Original Message-----
>>> From: nino martinez wael [mailto:nino.martinez.wael@gmail.com]
>>> Sent: Tuesday, October 12, 2010 11:52 AM
>>> To: users@wicket.apache.org
>>> Subject: Re: PropertyModel Not Refreshing
>>>
>>> No dont think so.. Please provide a quickstart.. I have had property
>>> models
>>> working in 1.2, 1.3, 1.4 and 1.5 so must be error 42:)
>>>
>>> 2010/10/12 Shelli Orton <Sh...@sjrb.ca>
>>>
>>> > Hi,
>>> >
>>> > Thanks for file.  Your first email was missing these changes:
>>> >
>>> >    IModel<RecordA> selectedRecordAModel;  (I had set mine to
>>> > PropertyModel<RecordA> selectedRecordAModel;)
>>> >    recordAs.setModel(selectedRecordAModel)
>>> >
>>> > However, even with those changes applied, I still get the same
issue
>>> of the
>>> > selected record not updating in the edit group.
>>> >
>>> > I am deploying in Glassfish v3.  Could that have anything to do
with
>>> my
>>> > problems?
>>> >
>>> > Shelli
>>> >
>>> > -----Original Message-----
>>> > From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
>>> > Sent: Tuesday, October 12, 2010 11:35 AM
>>> > To: users@wicket.apache.org
>>> > Subject: Re: PropertyModel Not Refreshing
>>> >
>>> > On Tue, Oct 12, 2010 at 10:30 AM, Shelli Orton
<Sh...@sjrb.ca>
>>> > wrote:
>>> > > Thanks for the help.  Your changes got rid of the errors and I
can
>>> delete
>>> > records now (and the list is updated).
>>> > >
>>> > > However, once a record has been selected for edit and either
saved
>>> or
>>> > cancelled, that same record is always displayed in the edit group
when
>>> I
>>> > choose another record to edit or even when I try to create a new
one.
>>> I can
>>> > even delete the chosen record and it still displays in the edit
group.
>>> >
>>> > works fine here, meaning you did not completely/propery apply my
>>> > changes. below is the complete file.
>>> >
>>> > -igor
>>> >
>>> > public class RecordAPanel extends Panel
>>> > {
>>> >    private static final long serialVersionUID = 1L;
>>> >
>>> >    RecordAService recordAService;
>>> >    RecordBService recordBService;
>>> >
>>> >    RecordA selectedRecordA = new RecordA();
>>> >    IModel<RecordA> selectedRecordAModel;
>>> >    String unmodifiedRecordA;
>>> >
>>> >    boolean isNew = false;
>>> >
>>> >    WebMarkupContainer selectGroup;
>>> >    WebMarkupContainer editGroup;
>>> >
>>> >    Form selectForm;
>>> >    Form editForm;
>>> >
>>> >    DropDownChoice<RecordA> recordAs;
>>> >    DropDownChoice<RecordB> recordBs;
>>> >
>>> >    Button add;
>>> >    Button edit;
>>> >    Button save;
>>> >    Button delete;
>>> >    Button cancel;
>>> >
>>> >    Label editLegendLabel;
>>> >    String editLegend;
>>> >    Label recordALabel;
>>> >    Label recordBLabel;
>>> >
>>> >    RequiredTextField recordAText;
>>> >
>>> >    @SuppressWarnings({ "rawtypes", "unchecked" })
>>> >    public RecordAPanel(String id)
>>> >    {
>>> >        super(id);
>>> >
>>> >        recordAService = ((Application)
>>> > RequestCycle.get().getApplication()).getRecordAService();
>>> >        recordBService = ((Application)
>>> > RequestCycle.get().getApplication()).getRecordBService();
>>> >
>>> >        selectedRecordAModel = new PropertyModel<RecordA>(this,
>>> > "selectedRecordA");
>>> >        this.setDefaultModel(selectedRecordAModel);
>>> >
>>> >        // ************* Select  Group *************
>>> >
>>> >        selectGroup = new WebMarkupContainer("selectGroup");
>>> >        selectForm = new Form("selectForm");
>>> >
>>> >        recordAs = new DropDownChoice<RecordA>("recordAs");
>>> >        recordAs.setModel(selectedRecordAModel);
>>> >        recordAs.setChoices(recordAsModel);
>>> >        recordAs.setChoiceRenderer(new RecordARenderer());
>>> >
>>> >        //            recordAs = (DropDownChoice<RecordA>) new
>>> > DropDownChoice<RecordA>("recordAs",
>>> >        //                    new PropertyModel<RecordA>(this,
>>> > "selectedRecordA"),
>>> >        //                    recordAsModel,
>>> >        //                    new RecordARenderer());
>>> >
>>> >        recordAs.setNullValid(false);
>>> >
>>> >        selectForm.add(recordAs);
>>> >
>>> >        add = new Button("add")
>>> >        {
>>> >            private static final long serialVersionUID = 1L;
>>> >
>>> >            public void onSubmit()
>>> >            {
>>> >                setSelectedRecordA(new RecordA());
>>> >                isNew = true;
>>> >                editLegend = "New";
>>> >                editGroup.setVisible(true);
>>> >                selectGroup.setVisible(false);
>>> >            }
>>> >        };
>>> >
>>> >        selectForm.add(add);
>>> >
>>> >        edit = new Button("edit")
>>> >        {
>>> >            private static final long serialVersionUID = 1L;
>>> >
>>> >            public void onSubmit()
>>> >            {
>>> >                if (selectedRecordA == null)
>>> >                {
>>> >                    info("You must select a record to edit.");
>>> >                }
>>> >                else
>>> >                {
>>> >                    unmodifiedRecordA = selectedRecordA.getName();
>>> >                    isNew = false;
>>> >                    editLegend = "Edit";
>>> >                    editGroup.setVisible(true);
>>> >                    selectGroup.setVisible(false);
>>> >                }
>>> >            }
>>> >        };
>>> >
>>> >        selectForm.add(edit);
>>> >
>>> >        delete = new Button("delete")
>>> >        {
>>> >            private static final long serialVersionUID = 1L;
>>> >
>>> >            public void onSubmit()
>>> >            {
>>> >                if (selectedRecordA == null)
>>> >                {
>>> >                    info("You must select a record to delete.");
>>> >                }
>>> >                else
>>> >                {
>>> >                    // Delete the selected record
>>> >                    unmodifiedRecordA = selectedRecordA.getName();
>>> >
recordAService.delete(selectedRecordA.getName());
>>> >                    selectedRecordA = null;
>>> >                    info("Deleted '" + unmodifiedRecordA + "'");
>>> >
>>> >                    // Force refresh of records list
>>> >                    RecordAPanel.this.recordAsModel.detach();
>>> >                }
>>> >            }
>>> >        };
>>> >
>>> >        // Add confirmation dialog box
>>> >        delete.add(new SimpleAttributeModifier("onclick",
>>> >                "if (!confirm('Please confirm you want to delete
this
>>> > record') ){ return false; }"));
>>> >
>>> >        selectForm.add(delete);
>>> >        selectGroup.add(selectForm);
>>> >
>>> >        this.add(selectGroup);
>>> >
>>> >        // ************* Edit Group *************
>>> >
>>> >        editGroup = new WebMarkupContainer("editGroup");
>>> >
>>> >        editLegendLabel = new Label("editLegend", new
>>> PropertyModel(this,
>>> >                "editLegend"));
>>> >
>>> >        editGroup.add(editLegendLabel);
>>> >
>>> >        editForm = new Form("editForm");
>>> >
>>> >        recordALabel = new Label("recordALabel", "Record A");
>>> >        editForm.add(recordALabel);
>>> >
>>> >        recordBLabel = new Label("recordBLabel", "Record B");
>>> >        editForm.add(recordBLabel);
>>> >
>>> >        recordAText = new RequiredTextField("recordAText",
>>> >                new PropertyModel(selectedRecordAModel, "name"));
>>> >
>>> >        editForm.add(recordAText);
>>> >
>>> >        recordBs = new DropDownChoice<RecordB>("recordBs");
>>> >        recordBs.setModel(new PropertyModel(selectedRecordAModel,
>>> > "recordB"));
>>> >        recordBs.setChoices(RecordAPanel.this.getRecordBs());
>>> >        recordBs.setChoiceRenderer(new RecordBRenderer());
>>> >
>>> >        editForm.add(recordBs);
>>> >
>>> >        save = new Button("save")
>>> >        {
>>> >            private static final long serialVersionUID = 1L;
>>> >
>>> >            @Override
>>> >            public void onSubmit()
>>> >            {
>>> >                if (isNew)
>>> >                {
>>> >
>>> > recordAService.create(RecordAPanel.this.selectedRecordA);
>>> >                        info("Created '"
>>> >                                +
>>> > RecordAPanel.this.selectedRecordA.getName()
>>> >                                + "'");
>>> >                }
>>> >                else
>>> >                {
>>> >                        recordAService.update(unmodifiedRecordA,
>>> >                                RecordAPanel.this.selectedRecordA);
>>> >                        info("Updated '"
>>> >                                +
>>> > RecordAPanel.this.selectedRecordA.getName()
>>> >                                + "'");
>>> >                }
>>> >
>>> >                // TODO Update the dropdown list?
>>> >
>>> >                editGroup.setVisible(false);
>>> >                selectGroup.setVisible(true);
>>> >            }
>>> >        };
>>> >
>>> >        editForm.add(save);
>>> >
>>> >        cancel = new Button("cancel")
>>> >        {
>>> >            private static final long serialVersionUID = 1L;
>>> >
>>> >            public void onSubmit()
>>> >            {
>>> >                RecordAPanel.this.selectedRecordA = null;
>>> >                editGroup.setVisible(false);
>>> >                selectGroup.setVisible(true);
>>> >            }
>>> >        };
>>> >
>>> >        cancel.setDefaultFormProcessing(false);
>>> >        editForm.add(cancel);
>>> >
>>> >        editGroup.add(editForm);
>>> >
>>> >        editGroup.setVisible(false);
>>> >        this.add(editGroup);
>>> >    }
>>> >
>>> >    public RecordA getSelectedRecordA()
>>> >    {
>>> >        return selectedRecordA;
>>> >    }
>>> >
>>> >    public void setSelectedRecordA(RecordA selectedRecordA)
>>> >    {
>>> >        this.selectedRecordA = selectedRecordA;
>>> >    }
>>> >
>>> >    public LoadableDetachableModel<List<RecordA>> recordAsModel =
new
>>> > LoadableDetachableModel<List<RecordA>>()
>>> >    {
>>> >        private static final long serialVersionUID = 1L;
>>> >
>>> >        @Override
>>> >        protected List<RecordA> load()
>>> >        {
>>> >            return recordAService.getList();
>>> >        }
>>> >
>>> >        public void detach()
>>> >        {
>>> >            super.detach();
>>> >        }
>>> >    };
>>> >
>>> >    // TODO change this to LDM?
>>> >    List<RecordB> getRecordBs()
>>> >    {
>>> >        return recordBService.getList();
>>> >    }
>>> >
>>> >    class RecordARenderer implements IChoiceRenderer<RecordA>
>>> >    {
>>> >        private static final long serialVersionUID = 1L;
>>> >
>>> >        public Object getDisplayValue(RecordA recordA)
>>> >        {
>>> >            return recordA.getName();
>>> >        }
>>> >
>>> >        public String getIdValue(RecordA recordA, int index)
>>> >        {
>>> >            return recordA.getName();
>>> >        }
>>> >    }
>>> >
>>> >    class RecordBRenderer implements IChoiceRenderer<RecordB>
>>> >    {
>>> >        private static final long serialVersionUID = 1L;
>>> >
>>> >        public Object getDisplayValue(RecordB recordB)
>>> >        {
>>> >            return recordB.getName();
>>> >        }
>>> >
>>> >        public String getIdValue(RecordB recordB, int index)
>>> >        {
>>> >            return recordB.getName();
>>> >        }
>>> >    }
>>> > }
>>> >
>>> > >
>>> > > Shelli
>>> > >
>>> > > -----Original Message-----
>>> > > From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
>>> > > Sent: Tuesday, October 12, 2010 10:38 AM
>>> > > To: users@wicket.apache.org
>>> > > Subject: Re: PropertyModel Not Refreshing
>>> > >
>>> > > here are the tweaks you need to make this work:
>>> > >
>>> > > selectedRecordAModel = new PropertyModel<RecordA>(this,
>>> > "selectedRecordA");
>>> > >
>>> > > recordAText = new RequiredTextField("recordAText",
>>> > >                new PropertyModel(selectedRecordAModel, "name"));
>>> > >
>>> > >  recordBs.setModel(new PropertyModel(selectedRecordAModel,
>>> "recordB"));
>>> > >
>>> > > have fun
>>> > >
>>> > > -igor
>>> > >
>>> > > On Tue, Oct 12, 2010 at 9:03 AM, Shelli Orton
<Sh...@sjrb.ca>
>>> > wrote:
>>> > >> I've been able to create a sample application that exhibits the
>>> > >> same/similar problems to mine.  The sample makes use of an
>>> in-memory
>>> > >> list for the data versus accessing a database and so there's
some
>>> > >> differences.  However, I believe the problems that this sample
>>> exhibits
>>> > >> have the same root cause as my project (which I believe have
>>> something
>>> > >> to do with how my models are set up...).
>>> > >>
>>> > >> Issues this sample exhibits:
>>> > >>
>>> > >> 1. Choose to edit an existing record, then cancel the edit.
Choose
>>> > >> another/the same record to edit and the selected record is null
>>> (error
>>> > >> message "You must select a record to edit" is displayed).  Must
>>> > >> close/open session to reset.
>>> > >>
>>> > >> 2. Choose to edit an existing record and save the edit.  Choose
>>> > >> another/the same record to edit and you get a NPE:
>>> > >>
>>> > >>    WicketMessage: Method onFormSubmitted of interface
>>> > >> org.apache.wicket.markup.html.form.IFormSubmitListener targeted
at
>>> > >> component [MarkupContainer [Component id = selectForm]] threw
an
>>> > >> exception
>>> > >>
>>> > >>    Root cause:
>>> > >>
>>> > >>    java.lang.NullPointerException
>>> > >>    at
>>> > >>
>>>
org.apache.wicket.markup.html.form.AbstractSingleSelectChoice.convertCho
>>> > >> iceIdToChoice(AbstractSingleSelectChoice.java:247)
>>> > >>
>>> > >> 3. Create a new record and try to save it and get
>>> > >> WicketRuntimeException:
>>> > >>
>>> > >>    WicketMessage: Attempted to set property value on a null
object.
>>> > >> Property expression: name Value: New One
>>> > >>
>>> > >>    Root cause:
>>> > >>
>>> > >>    org.apache.wicket.WicketRuntimeException: Attempted to set
>>> property
>>> > >> value on a null object. Property expression: name Value: New
One
>>> > >>    at
>>> > >>
>>>
org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.j
>>> > >> ava:125)
>>> > >>
>>> > >> 4. Create a new record and then cancel the add, Choose an
existing
>>> > >> record to edit and the selected record is null (error message
"You
>>> must
>>> > >> select a record to edit" is displayed).  Must close/open
session to
>>> > >> reset.
>>> > >>
>>> > >> As always, all help is greatly appreciated as I am stumped.
>>> > >>
>>> > >> Thanks,
>>> > >> Shelli
>>> > >>
>>> > >> -----Original Message-----
>>> > >> From: jcgarciam [mailto:jcgarciam@gmail.com]
>>> > >> Sent: Friday, October 08, 2010 1:41 PM
>>> > >> To: users@wicket.apache.org
>>> > >> Subject: Re: PropertyModel Not Refreshing
>>> > >>
>>> > >>
>>> > >> The attachment didn't make it,
>>> > >>
>>> > >> Can you try to extract out the relevant part and creates a
>>> quickstart
>>> > >> project that actually reproduces your issue?
>>> > >>
>>> > >>
>>> > >> On Fri, Oct 8, 2010 at 1:41 PM, Shelli Orton [via Apache
Wicket] <
>>> > >>
>>>
ml-node+2968688-305091622-65838@n4.nabble.com<ml-node%2B2968688-30509162
2-65838@n4.nabble.com>
>>> <ml-node%2B2968688-30509162
>>> 2-65838@n4.nabble.com>
>>> > <ml-node%2B2968688-30509162
>>> > >> 2-65838@n4.nabble.com>
>>> > >>> wrote:
>>> > >>
>>> > >>> Hi,
>>> > >>>
>>> > >>> I have been trying different things to see if I could get my
code
>>> to
>>> > >> work
>>> > >>> (and understand Wicket models better), but am still stuck.  I
have
>>> a
>>> > >>> attached the (latest) panel class code which I hope is
sufficient
>>> to
>>> > >> help.
>>> > >>>
>>> > >>> I was reading about different models (both online and the
Wicket
>>> in
>>> > >> Action
>>> > >>> book) and thought that perhaps using a CompoundPropertyModel
was
>>> more
>>> > >>> appropriate and may help with my issues.  Originally, I only
>>> declared
>>> > >>> selectedRecordA (line 40) but didn't instantiate it.  The
select
>>> group
>>> > >>> displayed properly but when I chose a record from the list and
>>> tried
>>> > >> to edit
>>> > >>> it, this exception was thrown:
>>> > >>>
>>> > >>>     WicketMessage: Attempted to set property value on a null
>>> object.
>>> > >>> Property expression: recordA Value: Name=A-One
>>> > >>>     Root cause:
>>> > >>>
>>> > >>>     org.apache.wicket.WicketRuntimeException: Attempted to set
>>> > >> property
>>> > >>> value on a null object. Property expression: recordA Value:
>>> Name=A-One
>>> > >>>         at
>>> > >>>
>>> > >>
>>>
org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.j
>>> > >> ava:125)
>>> > >>>
>>> > >>>         at
>>> > >>>
>>> > >>
>>>
org.apache.wicket.model.AbstractPropertyModel.setObject(AbstractProperty
>>> > >> Model.java:169)
>>> > >>>
>>> > >>>         at
>>> > >>>
>>>
org.apache.wicket.Component.setDefaultModelObject(Component.java:3125)
>>> > >>>         ....
>>> > >>>
>>> > >>> I set breakpoints on the getSelectedRecordA and
setSelectedRecordA
>>> > >> methods,
>>> > >>> but these aren't called when during the request cycle when the
>>> edit
>>> > >> button
>>> > >>> is clicked.
>>> > >>>
>>> > >>> I then changed the class so that selectedRecordA is
initialized to
>>> an
>>> > >> empty
>>> > >>> instance of RecordA. This got rid of the above error.
However, I
>>> > >> cannot
>>> > >>> save the edit changes because the selectedRecordA is still the
>>> empty
>>> > >>> instance that was created in the initialization and the
>>> persistence
>>> > >> layer
>>> > >>> throws an exception.  This same problem exists if I try to add
a
>>> new
>>> > >> RecordA
>>> > >>> or try to delete an existing one.
>>> > >>>
>>> > >>> If I choose to cancel the edit and then select another record
to
>>> edit,
>>> > >> I
>>> > >>> get the message "You must select a record to edit" (line 131).
>>> This
>>> > >> is
>>> > >>> because the cancel onSubmit sets selectedRecordA to null and
>>> choosing
>>> > >> the
>>> > >>> record from the DDC is not setting it to the chosen record.
>>> > >>>
>>> > >>> Clearly I am not setting up this CompoundPropertyModel
properly so
>>> > >> that the
>>> > >>> selectedARecord is set by the model.  Can someone tell me what
I'm
>>> > >> doing
>>> > >>> wrong?
>>> > >>>
>>> > >>> All help is greatly appreciated,
>>> > >>>
>>> > >>> Shelli
>>> > >>>
>>> > >>>
>>> > >>> -----Original Message-----
>>> > >>> From: Igor Vaynberg [mailto:[hidden
>>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=0>]
>>> > >>>
>>> > >>> Sent: Thursday, October 07, 2010 11:27 AM
>>> > >>> To: [hidden email]
>>> > >> <http://user/SendEmail.jtp?type=node&node=2968688&i=1>
>>> > >>> Subject: Re: PropertyModel Not Refreshing
>>> > >>>
>>> > >>> you have posted an incomplete piece of code and somehow from
that
>>> we
>>> > >>> are supposed to guess what is not working? create a quickstart
and
>>> > >>> provide that.
>>> > >>>
>>> > >>> -igor
>>> > >>>
>>> > >>> On Thu, Oct 7, 2010 at 10:15 AM, Shelli Orton <[hidden
>>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=2>>
>>> > >>> wrote:
>>> > >>>
>>> > >>> > Does nobody have any suggestions?  If I can't get this
fixed,
>>> I'm
>>> > >> going
>>> > >>> > to have to write the app in another framework (possibly GWT)
and
>>> I'd
>>> > >>> > really rather not have to do that.
>>> > >>> >
>>> > >>> > Shelli
>>> > >>> >
>>> > >>> > -----Original Message-----
>>> > >>> > From: Shelli Orton
>>> > >>> > Sent: Wednesday, October 06, 2010 3:52 PM
>>> > >>> > To: [hidden
>>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=3>
>>> > >>> > Subject: PropertyModel Not Refreshing
>>> > >>> >
>>> > >>> > Hi,
>>> > >>> >
>>> > >>> > First, thanks to all who have been helping me as I am new to
>>> Wicket.
>>> > >> I
>>> > >>> > am splitting out two issues I am dealing with to try to keep
>>> things
>>> > >>> > clear.
>>> > >>> >
>>> > >>> > I am trying to write a simple app that does CRUD operations
on
>>> > >> database
>>> > >>> > records.  The goal is for the app to make use of a tab panel
>>> where
>>> > >> each
>>> > >>> > tab encapsulates one table from the database.  Each tab
panel
>>> has
>>> > >> two
>>> > >>> > groups (WebMarkupContainer).  The first, selectGroup,
displays a
>>> > >> list
>>> > >>> > (DDC) of the current items, and three buttons, add, edit and
>>> delete.
>>> > >>> > The second, editGroup, is displayed when either the add or
edit
>>> > >> button
>>> > >>> > was clicked on the select group, displays the record
attributes
>>> and
>>> > >> save
>>> > >>> > and cancel buttons.  The tab panel has a "selectedRecord"
which
>>> is
>>> > >> used
>>> > >>> > by both groups' components via PropertyModels. Very basic
stuff.
>>> > >>> >
>>> > >>> > When I choose a record and click the edit button, the record
is
>>> > >>> > displayed in the edit group properly.  If I then choose
cancel,
>>> the
>>> > >> edit
>>> > >>> > group is no longer displayed and the select group DDC
selection
>>> is
>>> > >> null
>>> > >>> > as expected. I then choose another record from the list and
>>> click
>>> > >> the
>>> > >>> > edit button and the previous record information is displayed
in
>>> the
>>> > >> edit
>>> > >>> > group even though the select group DDC shows the
>>> correct/selected
>>> > >>> > record.
>>> > >>> >
>>> > >>> > This problem also occurs if I first choose to add a new
record
>>> and
>>> > >> then
>>> > >>> > cancel the add and then choose to edit a different record.
The
>>> DDC
>>> > >>> > shows the correct/selected record, but all the attributes in
the
>>> > >> edit
>>> > >>> > group are null/defaults for a new record.
>>> > >>> >
>>> > >>> > If I remove the call to setDefaultFormProcessing(false) on
the
>>> > >> cancel
>>> > >>> > button, selecting other records for edit works correctly,
but I
>>> > >> can't
>>> > >>> > cancel a creating a new record if I use a RequiredTextField
>>> because
>>> > >> the
>>> > >>> > form validation fails.
>>> > >>> >
>>> > >>> > If I select a record for editing or save the newly created
>>> record, I
>>> > >> can
>>> > >>> > select a different record for edit or create another one
>>> correctly.
>>> > >> So
>>> > >>> > I must be doing something wrong in the cancel logic. My
editForm
>>> > >>> > (created in the EditGroup constructor) looks like this:
>>> > >>> >
>>> > >>> >            Form editForm = new Form("editForm");
>>> > >>> >
>>> > >>> >            editForm.add(new Label("nameLabel", "Name"));
>>> > >>> >
>>> > >>> >            editForm.add(new Label("attributeLabel",
>>> "Attribute"));
>>> > >>> >
>>> > >>> >            editForm.add(new
>>> > >> RequiredTextField<String>("recordNameText",
>>> > >>> >                    new
PropertyModel<String>(MyRecordPanel.this,
>>> > >>> >                            "selectedRecord.name")));
>>> > >>> >
>>> > >>> >            editForm.add(new
DropDownChoice<Lir>("attributes",
>>> > >>> >                    new
>>> PropertyModel<Attribute>(MyRecordPanel.this,
>>> > >>> >                            "selectedRecord.attribute"),
>>> > >>> >                    RateCentrePanel.this.getAttributes(),
>>> > >>> >                    new AttributeRenderer()));
>>> > >>> >
>>> > >>> >            ....
>>> > >>> >
>>> > >>> >            editForm.add(new Button("cancel")
>>> > >>> >            {
>>> > >>> >                private static final long serialVersionUID =
1L;
>>> > >>> >
>>> > >>> >                public void onSubmit()
>>> > >>> >                {
>>> > >>> >                    MyRecordPanel.this.selectedRecord = null;
>>> > >>> >                    editGroup.setVisible(false);
>>> > >>> >                    selectGroup.setVisible(true);
>>> > >>> >                }
>>> > >>> >            }.setDefaultFormProcessing(false));
>>> > >>> >
>>> > >>> >            add(editForm);
>>> > >>> >
>>> > >>> > Other than setting the selectedRecord to null, what should I
be
>>> > >> doing
>>> > >>> > differently?
>>> > >>> >
>>> > >>> > Thanks in advance!
>>> > >>> >
>>> > >>> > Shelli
>>> > >>> >
>>> > >>> >
>>> > >>
>>>
---------------------------------------------------------------------
>>> > >>> > To unsubscribe, e-mail: [hidden
>>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=4>
>>> > >>> > For additional commands, e-mail: [hidden
>>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=5>
>>> > >>> >
>>> > >>> >
>>> > >>> >
>>> > >>
>>>
---------------------------------------------------------------------
>>> > >>> > To unsubscribe, e-mail: [hidden
>>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=6>
>>> > >>> > For additional commands, e-mail: [hidden
>>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=7>
>>> > >>> >
>>> > >>> >
>>> > >>>
>>>
---------------------------------------------------------------------
>>> > >>> To unsubscribe, e-mail: [hidden
>>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=8>
>>> > >>> For additional commands, e-mail: [hidden
>>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=9>
>>> > >>>
>>> > >>>
>>> > >>>
>>> > >>>
>>> > >>>
>>>
---------------------------------------------------------------------
>>> > >>> To unsubscribe, e-mail: [hidden
>>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=10>
>>> > >>> For additional commands, e-mail: [hidden
>>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=11>
>>> > >>>
>>> > >>> ------------------------------
>>> > >>>  View message @
>>> > >>>
>>> > >>
>>> >
>>>
http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
>>> > >> n-tp2955144p2968688.html
>>> > >>> To start a new topic under Apache Wicket, email
>>> > >>>
>>> > >>
>>>
ml-node+1842946-398011874-65838@n4.nabble.com<ml-node%2B1842946-39801187
4-65838@n4.nabble.com>
>>> <ml-node%2B1842946-39801187
>>> 4-65838@n4.nabble.com>
>>> > <ml-node%2B1842946-39801187
>>> > >> 4-65838@n4.nabble.com>
>>> > >>> To unsubscribe from Apache Wicket, click
>>> > >>
>>>
here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp
>>> > ?
>>> > >>
>>>
tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
>>> > >> QyOTQ2fDEyNTYxMzc3ODY=>.
>>> > >>>
>>> > >>>
>>> > >>>
>>> > >>
>>> > >>
>>> > >> --
>>> > >> Sincerely,
>>> > >> JC (http://www.linkedin.com/in/jcgarciam)
>>> > >> Work smarter, not harder!.
>>> > >>
>>> > >> --
>>> > >> View this message in context:
>>> > >>
>>> >
>>>
http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
>>> > >> n-tp2955144p2968936.html
>>> > >> Sent from the Users forum mailing list archive at Nabble.com.
>>> > >>
>>> > >>
>>>
---------------------------------------------------------------------
>>> > >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> > >> For additional commands, e-mail: users-help@wicket.apache.org
>>> > >>
>>> > >>
>>> > >>
>>> > >>
>>>
---------------------------------------------------------------------
>>> > >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> > >> For additional commands, e-mail: users-help@wicket.apache.org
>>> > >>
>>> > >
>>> > >
>>>
---------------------------------------------------------------------
>>> > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> > > For additional commands, e-mail: users-help@wicket.apache.org
>>> > >
>>> > >
>>> > >
>>>
---------------------------------------------------------------------
>>> > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> > > For additional commands, e-mail: users-help@wicket.apache.org
>>> > >
>>> > >
>>> >
>>> >
---------------------------------------------------------------------
>>> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> > For additional commands, e-mail: users-help@wicket.apache.org
>>> >
>>> >
>>> >
---------------------------------------------------------------------
>>> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> > For additional commands, e-mail: users-help@wicket.apache.org
>>> >
>>> >
>>>
>>>
---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>

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


Re: PropertyModel Not Refreshing

Posted by nino martinez wael <ni...@gmail.com>.
in your add button you call setSelectedRecordA(new RecordA()) but never
notify the model that a change has occured...

2010/10/12 nino martinez wael <ni...@gmail.com>

> hmm getting a lot of errors on the services not implementing
> serialization...
>
> But does seem theres a difference between calling :
>
> selectedRecordAModel.getObject().getName() and
> RecordAPanel.this.selectedRecordA
>
> 2010/10/12 nino martinez wael <ni...@gmail.com>
>
> sorry.. Did'nt see it attached.. So did igor provide you with an fixed
>> quickstart (working on his system).. That did not work on glassfish?
>>
>>
>> 2010/10/12 Shelli Orton <Sh...@sjrb.ca>
>>
>>> The quickstart was sent to the list this morning at 10:04 MST.  Does it
>>> need to be resent?
>>>
>>> Shelli
>>>
>>> -----Original Message-----
>>> From: nino martinez wael [mailto:nino.martinez.wael@gmail.com]
>>> Sent: Tuesday, October 12, 2010 11:52 AM
>>> To: users@wicket.apache.org
>>> Subject: Re: PropertyModel Not Refreshing
>>>
>>> No dont think so.. Please provide a quickstart.. I have had property
>>> models
>>> working in 1.2, 1.3, 1.4 and 1.5 so must be error 42:)
>>>
>>> 2010/10/12 Shelli Orton <Sh...@sjrb.ca>
>>>
>>> > Hi,
>>> >
>>> > Thanks for file.  Your first email was missing these changes:
>>> >
>>> >    IModel<RecordA> selectedRecordAModel;  (I had set mine to
>>> > PropertyModel<RecordA> selectedRecordAModel;)
>>> >    recordAs.setModel(selectedRecordAModel)
>>> >
>>> > However, even with those changes applied, I still get the same issue
>>> of the
>>> > selected record not updating in the edit group.
>>> >
>>> > I am deploying in Glassfish v3.  Could that have anything to do with
>>> my
>>> > problems?
>>> >
>>> > Shelli
>>> >
>>> > -----Original Message-----
>>> > From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
>>> > Sent: Tuesday, October 12, 2010 11:35 AM
>>> > To: users@wicket.apache.org
>>> > Subject: Re: PropertyModel Not Refreshing
>>> >
>>> > On Tue, Oct 12, 2010 at 10:30 AM, Shelli Orton <Sh...@sjrb.ca>
>>> > wrote:
>>> > > Thanks for the help.  Your changes got rid of the errors and I can
>>> delete
>>> > records now (and the list is updated).
>>> > >
>>> > > However, once a record has been selected for edit and either saved
>>> or
>>> > cancelled, that same record is always displayed in the edit group when
>>> I
>>> > choose another record to edit or even when I try to create a new one.
>>> I can
>>> > even delete the chosen record and it still displays in the edit group.
>>> >
>>> > works fine here, meaning you did not completely/propery apply my
>>> > changes. below is the complete file.
>>> >
>>> > -igor
>>> >
>>> > public class RecordAPanel extends Panel
>>> > {
>>> >    private static final long serialVersionUID = 1L;
>>> >
>>> >    RecordAService recordAService;
>>> >    RecordBService recordBService;
>>> >
>>> >    RecordA selectedRecordA = new RecordA();
>>> >    IModel<RecordA> selectedRecordAModel;
>>> >    String unmodifiedRecordA;
>>> >
>>> >    boolean isNew = false;
>>> >
>>> >    WebMarkupContainer selectGroup;
>>> >    WebMarkupContainer editGroup;
>>> >
>>> >    Form selectForm;
>>> >    Form editForm;
>>> >
>>> >    DropDownChoice<RecordA> recordAs;
>>> >    DropDownChoice<RecordB> recordBs;
>>> >
>>> >    Button add;
>>> >    Button edit;
>>> >    Button save;
>>> >    Button delete;
>>> >    Button cancel;
>>> >
>>> >    Label editLegendLabel;
>>> >    String editLegend;
>>> >    Label recordALabel;
>>> >    Label recordBLabel;
>>> >
>>> >    RequiredTextField recordAText;
>>> >
>>> >    @SuppressWarnings({ "rawtypes", "unchecked" })
>>> >    public RecordAPanel(String id)
>>> >    {
>>> >        super(id);
>>> >
>>> >        recordAService = ((Application)
>>> > RequestCycle.get().getApplication()).getRecordAService();
>>> >        recordBService = ((Application)
>>> > RequestCycle.get().getApplication()).getRecordBService();
>>> >
>>> >        selectedRecordAModel = new PropertyModel<RecordA>(this,
>>> > "selectedRecordA");
>>> >        this.setDefaultModel(selectedRecordAModel);
>>> >
>>> >        // ************* Select  Group *************
>>> >
>>> >        selectGroup = new WebMarkupContainer("selectGroup");
>>> >        selectForm = new Form("selectForm");
>>> >
>>> >        recordAs = new DropDownChoice<RecordA>("recordAs");
>>> >        recordAs.setModel(selectedRecordAModel);
>>> >        recordAs.setChoices(recordAsModel);
>>> >        recordAs.setChoiceRenderer(new RecordARenderer());
>>> >
>>> >        //            recordAs = (DropDownChoice<RecordA>) new
>>> > DropDownChoice<RecordA>("recordAs",
>>> >        //                    new PropertyModel<RecordA>(this,
>>> > "selectedRecordA"),
>>> >        //                    recordAsModel,
>>> >        //                    new RecordARenderer());
>>> >
>>> >        recordAs.setNullValid(false);
>>> >
>>> >        selectForm.add(recordAs);
>>> >
>>> >        add = new Button("add")
>>> >        {
>>> >            private static final long serialVersionUID = 1L;
>>> >
>>> >            public void onSubmit()
>>> >            {
>>> >                setSelectedRecordA(new RecordA());
>>> >                isNew = true;
>>> >                editLegend = "New";
>>> >                editGroup.setVisible(true);
>>> >                selectGroup.setVisible(false);
>>> >            }
>>> >        };
>>> >
>>> >        selectForm.add(add);
>>> >
>>> >        edit = new Button("edit")
>>> >        {
>>> >            private static final long serialVersionUID = 1L;
>>> >
>>> >            public void onSubmit()
>>> >            {
>>> >                if (selectedRecordA == null)
>>> >                {
>>> >                    info("You must select a record to edit.");
>>> >                }
>>> >                else
>>> >                {
>>> >                    unmodifiedRecordA = selectedRecordA.getName();
>>> >                    isNew = false;
>>> >                    editLegend = "Edit";
>>> >                    editGroup.setVisible(true);
>>> >                    selectGroup.setVisible(false);
>>> >                }
>>> >            }
>>> >        };
>>> >
>>> >        selectForm.add(edit);
>>> >
>>> >        delete = new Button("delete")
>>> >        {
>>> >            private static final long serialVersionUID = 1L;
>>> >
>>> >            public void onSubmit()
>>> >            {
>>> >                if (selectedRecordA == null)
>>> >                {
>>> >                    info("You must select a record to delete.");
>>> >                }
>>> >                else
>>> >                {
>>> >                    // Delete the selected record
>>> >                    unmodifiedRecordA = selectedRecordA.getName();
>>> >                    recordAService.delete(selectedRecordA.getName());
>>> >                    selectedRecordA = null;
>>> >                    info("Deleted '" + unmodifiedRecordA + "'");
>>> >
>>> >                    // Force refresh of records list
>>> >                    RecordAPanel.this.recordAsModel.detach();
>>> >                }
>>> >            }
>>> >        };
>>> >
>>> >        // Add confirmation dialog box
>>> >        delete.add(new SimpleAttributeModifier("onclick",
>>> >                "if (!confirm('Please confirm you want to delete this
>>> > record') ){ return false; }"));
>>> >
>>> >        selectForm.add(delete);
>>> >        selectGroup.add(selectForm);
>>> >
>>> >        this.add(selectGroup);
>>> >
>>> >        // ************* Edit Group *************
>>> >
>>> >        editGroup = new WebMarkupContainer("editGroup");
>>> >
>>> >        editLegendLabel = new Label("editLegend", new
>>> PropertyModel(this,
>>> >                "editLegend"));
>>> >
>>> >        editGroup.add(editLegendLabel);
>>> >
>>> >        editForm = new Form("editForm");
>>> >
>>> >        recordALabel = new Label("recordALabel", "Record A");
>>> >        editForm.add(recordALabel);
>>> >
>>> >        recordBLabel = new Label("recordBLabel", "Record B");
>>> >        editForm.add(recordBLabel);
>>> >
>>> >        recordAText = new RequiredTextField("recordAText",
>>> >                new PropertyModel(selectedRecordAModel, "name"));
>>> >
>>> >        editForm.add(recordAText);
>>> >
>>> >        recordBs = new DropDownChoice<RecordB>("recordBs");
>>> >        recordBs.setModel(new PropertyModel(selectedRecordAModel,
>>> > "recordB"));
>>> >        recordBs.setChoices(RecordAPanel.this.getRecordBs());
>>> >        recordBs.setChoiceRenderer(new RecordBRenderer());
>>> >
>>> >        editForm.add(recordBs);
>>> >
>>> >        save = new Button("save")
>>> >        {
>>> >            private static final long serialVersionUID = 1L;
>>> >
>>> >            @Override
>>> >            public void onSubmit()
>>> >            {
>>> >                if (isNew)
>>> >                {
>>> >
>>> > recordAService.create(RecordAPanel.this.selectedRecordA);
>>> >                        info("Created '"
>>> >                                +
>>> > RecordAPanel.this.selectedRecordA.getName()
>>> >                                + "'");
>>> >                }
>>> >                else
>>> >                {
>>> >                        recordAService.update(unmodifiedRecordA,
>>> >                                RecordAPanel.this.selectedRecordA);
>>> >                        info("Updated '"
>>> >                                +
>>> > RecordAPanel.this.selectedRecordA.getName()
>>> >                                + "'");
>>> >                }
>>> >
>>> >                // TODO Update the dropdown list?
>>> >
>>> >                editGroup.setVisible(false);
>>> >                selectGroup.setVisible(true);
>>> >            }
>>> >        };
>>> >
>>> >        editForm.add(save);
>>> >
>>> >        cancel = new Button("cancel")
>>> >        {
>>> >            private static final long serialVersionUID = 1L;
>>> >
>>> >            public void onSubmit()
>>> >            {
>>> >                RecordAPanel.this.selectedRecordA = null;
>>> >                editGroup.setVisible(false);
>>> >                selectGroup.setVisible(true);
>>> >            }
>>> >        };
>>> >
>>> >        cancel.setDefaultFormProcessing(false);
>>> >        editForm.add(cancel);
>>> >
>>> >        editGroup.add(editForm);
>>> >
>>> >        editGroup.setVisible(false);
>>> >        this.add(editGroup);
>>> >    }
>>> >
>>> >    public RecordA getSelectedRecordA()
>>> >    {
>>> >        return selectedRecordA;
>>> >    }
>>> >
>>> >    public void setSelectedRecordA(RecordA selectedRecordA)
>>> >    {
>>> >        this.selectedRecordA = selectedRecordA;
>>> >    }
>>> >
>>> >    public LoadableDetachableModel<List<RecordA>> recordAsModel = new
>>> > LoadableDetachableModel<List<RecordA>>()
>>> >    {
>>> >        private static final long serialVersionUID = 1L;
>>> >
>>> >        @Override
>>> >        protected List<RecordA> load()
>>> >        {
>>> >            return recordAService.getList();
>>> >        }
>>> >
>>> >        public void detach()
>>> >        {
>>> >            super.detach();
>>> >        }
>>> >    };
>>> >
>>> >    // TODO change this to LDM?
>>> >    List<RecordB> getRecordBs()
>>> >    {
>>> >        return recordBService.getList();
>>> >    }
>>> >
>>> >    class RecordARenderer implements IChoiceRenderer<RecordA>
>>> >    {
>>> >        private static final long serialVersionUID = 1L;
>>> >
>>> >        public Object getDisplayValue(RecordA recordA)
>>> >        {
>>> >            return recordA.getName();
>>> >        }
>>> >
>>> >        public String getIdValue(RecordA recordA, int index)
>>> >        {
>>> >            return recordA.getName();
>>> >        }
>>> >    }
>>> >
>>> >    class RecordBRenderer implements IChoiceRenderer<RecordB>
>>> >    {
>>> >        private static final long serialVersionUID = 1L;
>>> >
>>> >        public Object getDisplayValue(RecordB recordB)
>>> >        {
>>> >            return recordB.getName();
>>> >        }
>>> >
>>> >        public String getIdValue(RecordB recordB, int index)
>>> >        {
>>> >            return recordB.getName();
>>> >        }
>>> >    }
>>> > }
>>> >
>>> > >
>>> > > Shelli
>>> > >
>>> > > -----Original Message-----
>>> > > From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
>>> > > Sent: Tuesday, October 12, 2010 10:38 AM
>>> > > To: users@wicket.apache.org
>>> > > Subject: Re: PropertyModel Not Refreshing
>>> > >
>>> > > here are the tweaks you need to make this work:
>>> > >
>>> > > selectedRecordAModel = new PropertyModel<RecordA>(this,
>>> > "selectedRecordA");
>>> > >
>>> > > recordAText = new RequiredTextField("recordAText",
>>> > >                new PropertyModel(selectedRecordAModel, "name"));
>>> > >
>>> > >  recordBs.setModel(new PropertyModel(selectedRecordAModel,
>>> "recordB"));
>>> > >
>>> > > have fun
>>> > >
>>> > > -igor
>>> > >
>>> > > On Tue, Oct 12, 2010 at 9:03 AM, Shelli Orton <Sh...@sjrb.ca>
>>> > wrote:
>>> > >> I've been able to create a sample application that exhibits the
>>> > >> same/similar problems to mine.  The sample makes use of an
>>> in-memory
>>> > >> list for the data versus accessing a database and so there's some
>>> > >> differences.  However, I believe the problems that this sample
>>> exhibits
>>> > >> have the same root cause as my project (which I believe have
>>> something
>>> > >> to do with how my models are set up...).
>>> > >>
>>> > >> Issues this sample exhibits:
>>> > >>
>>> > >> 1. Choose to edit an existing record, then cancel the edit.  Choose
>>> > >> another/the same record to edit and the selected record is null
>>> (error
>>> > >> message "You must select a record to edit" is displayed).  Must
>>> > >> close/open session to reset.
>>> > >>
>>> > >> 2. Choose to edit an existing record and save the edit.  Choose
>>> > >> another/the same record to edit and you get a NPE:
>>> > >>
>>> > >>    WicketMessage: Method onFormSubmitted of interface
>>> > >> org.apache.wicket.markup.html.form.IFormSubmitListener targeted at
>>> > >> component [MarkupContainer [Component id = selectForm]] threw an
>>> > >> exception
>>> > >>
>>> > >>    Root cause:
>>> > >>
>>> > >>    java.lang.NullPointerException
>>> > >>    at
>>> > >>
>>> org.apache.wicket.markup.html.form.AbstractSingleSelectChoice.convertCho
>>> > >> iceIdToChoice(AbstractSingleSelectChoice.java:247)
>>> > >>
>>> > >> 3. Create a new record and try to save it and get
>>> > >> WicketRuntimeException:
>>> > >>
>>> > >>    WicketMessage: Attempted to set property value on a null object.
>>> > >> Property expression: name Value: New One
>>> > >>
>>> > >>    Root cause:
>>> > >>
>>> > >>    org.apache.wicket.WicketRuntimeException: Attempted to set
>>> property
>>> > >> value on a null object. Property expression: name Value: New One
>>> > >>    at
>>> > >>
>>> org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.j
>>> > >> ava:125)
>>> > >>
>>> > >> 4. Create a new record and then cancel the add, Choose an existing
>>> > >> record to edit and the selected record is null (error message "You
>>> must
>>> > >> select a record to edit" is displayed).  Must close/open session to
>>> > >> reset.
>>> > >>
>>> > >> As always, all help is greatly appreciated as I am stumped.
>>> > >>
>>> > >> Thanks,
>>> > >> Shelli
>>> > >>
>>> > >> -----Original Message-----
>>> > >> From: jcgarciam [mailto:jcgarciam@gmail.com]
>>> > >> Sent: Friday, October 08, 2010 1:41 PM
>>> > >> To: users@wicket.apache.org
>>> > >> Subject: Re: PropertyModel Not Refreshing
>>> > >>
>>> > >>
>>> > >> The attachment didn't make it,
>>> > >>
>>> > >> Can you try to extract out the relevant part and creates a
>>> quickstart
>>> > >> project that actually reproduces your issue?
>>> > >>
>>> > >>
>>> > >> On Fri, Oct 8, 2010 at 1:41 PM, Shelli Orton [via Apache Wicket] <
>>> > >>
>>> ml-node+2968688-305091622-65838@n4.nabble.com<ml...@n4.nabble.com>
>>> <ml-node%2B2968688-30509162
>>> 2-65838@n4.nabble.com>
>>> > <ml-node%2B2968688-30509162
>>> > >> 2-65838@n4.nabble.com>
>>> > >>> wrote:
>>> > >>
>>> > >>> Hi,
>>> > >>>
>>> > >>> I have been trying different things to see if I could get my code
>>> to
>>> > >> work
>>> > >>> (and understand Wicket models better), but am still stuck.  I have
>>> a
>>> > >>> attached the (latest) panel class code which I hope is sufficient
>>> to
>>> > >> help.
>>> > >>>
>>> > >>> I was reading about different models (both online and the Wicket
>>> in
>>> > >> Action
>>> > >>> book) and thought that perhaps using a CompoundPropertyModel was
>>> more
>>> > >>> appropriate and may help with my issues.  Originally, I only
>>> declared
>>> > >>> selectedRecordA (line 40) but didn't instantiate it.  The select
>>> group
>>> > >>> displayed properly but when I chose a record from the list and
>>> tried
>>> > >> to edit
>>> > >>> it, this exception was thrown:
>>> > >>>
>>> > >>>     WicketMessage: Attempted to set property value on a null
>>> object.
>>> > >>> Property expression: recordA Value: Name=A-One
>>> > >>>     Root cause:
>>> > >>>
>>> > >>>     org.apache.wicket.WicketRuntimeException: Attempted to set
>>> > >> property
>>> > >>> value on a null object. Property expression: recordA Value:
>>> Name=A-One
>>> > >>>         at
>>> > >>>
>>> > >>
>>> org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.j
>>> > >> ava:125)
>>> > >>>
>>> > >>>         at
>>> > >>>
>>> > >>
>>> org.apache.wicket.model.AbstractPropertyModel.setObject(AbstractProperty
>>> > >> Model.java:169)
>>> > >>>
>>> > >>>         at
>>> > >>>
>>> org.apache.wicket.Component.setDefaultModelObject(Component.java:3125)
>>> > >>>         ....
>>> > >>>
>>> > >>> I set breakpoints on the getSelectedRecordA and setSelectedRecordA
>>> > >> methods,
>>> > >>> but these aren't called when during the request cycle when the
>>> edit
>>> > >> button
>>> > >>> is clicked.
>>> > >>>
>>> > >>> I then changed the class so that selectedRecordA is initialized to
>>> an
>>> > >> empty
>>> > >>> instance of RecordA. This got rid of the above error.  However, I
>>> > >> cannot
>>> > >>> save the edit changes because the selectedRecordA is still the
>>> empty
>>> > >>> instance that was created in the initialization and the
>>> persistence
>>> > >> layer
>>> > >>> throws an exception.  This same problem exists if I try to add a
>>> new
>>> > >> RecordA
>>> > >>> or try to delete an existing one.
>>> > >>>
>>> > >>> If I choose to cancel the edit and then select another record to
>>> edit,
>>> > >> I
>>> > >>> get the message "You must select a record to edit" (line 131).
>>> This
>>> > >> is
>>> > >>> because the cancel onSubmit sets selectedRecordA to null and
>>> choosing
>>> > >> the
>>> > >>> record from the DDC is not setting it to the chosen record.
>>> > >>>
>>> > >>> Clearly I am not setting up this CompoundPropertyModel properly so
>>> > >> that the
>>> > >>> selectedARecord is set by the model.  Can someone tell me what I'm
>>> > >> doing
>>> > >>> wrong?
>>> > >>>
>>> > >>> All help is greatly appreciated,
>>> > >>>
>>> > >>> Shelli
>>> > >>>
>>> > >>>
>>> > >>> -----Original Message-----
>>> > >>> From: Igor Vaynberg [mailto:[hidden
>>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=0>]
>>> > >>>
>>> > >>> Sent: Thursday, October 07, 2010 11:27 AM
>>> > >>> To: [hidden email]
>>> > >> <http://user/SendEmail.jtp?type=node&node=2968688&i=1>
>>> > >>> Subject: Re: PropertyModel Not Refreshing
>>> > >>>
>>> > >>> you have posted an incomplete piece of code and somehow from that
>>> we
>>> > >>> are supposed to guess what is not working? create a quickstart and
>>> > >>> provide that.
>>> > >>>
>>> > >>> -igor
>>> > >>>
>>> > >>> On Thu, Oct 7, 2010 at 10:15 AM, Shelli Orton <[hidden
>>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=2>>
>>> > >>> wrote:
>>> > >>>
>>> > >>> > Does nobody have any suggestions?  If I can't get this fixed,
>>> I'm
>>> > >> going
>>> > >>> > to have to write the app in another framework (possibly GWT) and
>>> I'd
>>> > >>> > really rather not have to do that.
>>> > >>> >
>>> > >>> > Shelli
>>> > >>> >
>>> > >>> > -----Original Message-----
>>> > >>> > From: Shelli Orton
>>> > >>> > Sent: Wednesday, October 06, 2010 3:52 PM
>>> > >>> > To: [hidden
>>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=3>
>>> > >>> > Subject: PropertyModel Not Refreshing
>>> > >>> >
>>> > >>> > Hi,
>>> > >>> >
>>> > >>> > First, thanks to all who have been helping me as I am new to
>>> Wicket.
>>> > >> I
>>> > >>> > am splitting out two issues I am dealing with to try to keep
>>> things
>>> > >>> > clear.
>>> > >>> >
>>> > >>> > I am trying to write a simple app that does CRUD operations on
>>> > >> database
>>> > >>> > records.  The goal is for the app to make use of a tab panel
>>> where
>>> > >> each
>>> > >>> > tab encapsulates one table from the database.  Each tab panel
>>> has
>>> > >> two
>>> > >>> > groups (WebMarkupContainer).  The first, selectGroup, displays a
>>> > >> list
>>> > >>> > (DDC) of the current items, and three buttons, add, edit and
>>> delete.
>>> > >>> > The second, editGroup, is displayed when either the add or edit
>>> > >> button
>>> > >>> > was clicked on the select group, displays the record attributes
>>> and
>>> > >> save
>>> > >>> > and cancel buttons.  The tab panel has a "selectedRecord" which
>>> is
>>> > >> used
>>> > >>> > by both groups' components via PropertyModels. Very basic stuff.
>>> > >>> >
>>> > >>> > When I choose a record and click the edit button, the record is
>>> > >>> > displayed in the edit group properly.  If I then choose cancel,
>>> the
>>> > >> edit
>>> > >>> > group is no longer displayed and the select group DDC selection
>>> is
>>> > >> null
>>> > >>> > as expected. I then choose another record from the list and
>>> click
>>> > >> the
>>> > >>> > edit button and the previous record information is displayed in
>>> the
>>> > >> edit
>>> > >>> > group even though the select group DDC shows the
>>> correct/selected
>>> > >>> > record.
>>> > >>> >
>>> > >>> > This problem also occurs if I first choose to add a new record
>>> and
>>> > >> then
>>> > >>> > cancel the add and then choose to edit a different record.  The
>>> DDC
>>> > >>> > shows the correct/selected record, but all the attributes in the
>>> > >> edit
>>> > >>> > group are null/defaults for a new record.
>>> > >>> >
>>> > >>> > If I remove the call to setDefaultFormProcessing(false) on the
>>> > >> cancel
>>> > >>> > button, selecting other records for edit works correctly, but I
>>> > >> can't
>>> > >>> > cancel a creating a new record if I use a RequiredTextField
>>> because
>>> > >> the
>>> > >>> > form validation fails.
>>> > >>> >
>>> > >>> > If I select a record for editing or save the newly created
>>> record, I
>>> > >> can
>>> > >>> > select a different record for edit or create another one
>>> correctly.
>>> > >> So
>>> > >>> > I must be doing something wrong in the cancel logic. My editForm
>>> > >>> > (created in the EditGroup constructor) looks like this:
>>> > >>> >
>>> > >>> >            Form editForm = new Form("editForm");
>>> > >>> >
>>> > >>> >            editForm.add(new Label("nameLabel", "Name"));
>>> > >>> >
>>> > >>> >            editForm.add(new Label("attributeLabel",
>>> "Attribute"));
>>> > >>> >
>>> > >>> >            editForm.add(new
>>> > >> RequiredTextField<String>("recordNameText",
>>> > >>> >                    new PropertyModel<String>(MyRecordPanel.this,
>>> > >>> >                            "selectedRecord.name")));
>>> > >>> >
>>> > >>> >            editForm.add(new DropDownChoice<Lir>("attributes",
>>> > >>> >                    new
>>> PropertyModel<Attribute>(MyRecordPanel.this,
>>> > >>> >                            "selectedRecord.attribute"),
>>> > >>> >                    RateCentrePanel.this.getAttributes(),
>>> > >>> >                    new AttributeRenderer()));
>>> > >>> >
>>> > >>> >            ....
>>> > >>> >
>>> > >>> >            editForm.add(new Button("cancel")
>>> > >>> >            {
>>> > >>> >                private static final long serialVersionUID = 1L;
>>> > >>> >
>>> > >>> >                public void onSubmit()
>>> > >>> >                {
>>> > >>> >                    MyRecordPanel.this.selectedRecord = null;
>>> > >>> >                    editGroup.setVisible(false);
>>> > >>> >                    selectGroup.setVisible(true);
>>> > >>> >                }
>>> > >>> >            }.setDefaultFormProcessing(false));
>>> > >>> >
>>> > >>> >            add(editForm);
>>> > >>> >
>>> > >>> > Other than setting the selectedRecord to null, what should I be
>>> > >> doing
>>> > >>> > differently?
>>> > >>> >
>>> > >>> > Thanks in advance!
>>> > >>> >
>>> > >>> > Shelli
>>> > >>> >
>>> > >>> >
>>> > >>
>>> ---------------------------------------------------------------------
>>> > >>> > To unsubscribe, e-mail: [hidden
>>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=4>
>>> > >>> > For additional commands, e-mail: [hidden
>>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=5>
>>> > >>> >
>>> > >>> >
>>> > >>> >
>>> > >>
>>> ---------------------------------------------------------------------
>>> > >>> > To unsubscribe, e-mail: [hidden
>>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=6>
>>> > >>> > For additional commands, e-mail: [hidden
>>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=7>
>>> > >>> >
>>> > >>> >
>>> > >>>
>>> ---------------------------------------------------------------------
>>> > >>> To unsubscribe, e-mail: [hidden
>>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=8>
>>> > >>> For additional commands, e-mail: [hidden
>>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=9>
>>> > >>>
>>> > >>>
>>> > >>>
>>> > >>>
>>> > >>>
>>> ---------------------------------------------------------------------
>>> > >>> To unsubscribe, e-mail: [hidden
>>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=10>
>>> > >>> For additional commands, e-mail: [hidden
>>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=11>
>>> > >>>
>>> > >>> ------------------------------
>>> > >>>  View message @
>>> > >>>
>>> > >>
>>> >
>>> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
>>> > >> n-tp2955144p2968688.html
>>> > >>> To start a new topic under Apache Wicket, email
>>> > >>>
>>> > >>
>>> ml-node+1842946-398011874-65838@n4.nabble.com<ml...@n4.nabble.com>
>>> <ml-node%2B1842946-39801187
>>> 4-65838@n4.nabble.com>
>>> > <ml-node%2B1842946-39801187
>>> > >> 4-65838@n4.nabble.com>
>>> > >>> To unsubscribe from Apache Wicket, click
>>> > >>
>>> here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp
>>> > ?
>>> > >>
>>> tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
>>> > >> QyOTQ2fDEyNTYxMzc3ODY=>.
>>> > >>>
>>> > >>>
>>> > >>>
>>> > >>
>>> > >>
>>> > >> --
>>> > >> Sincerely,
>>> > >> JC (http://www.linkedin.com/in/jcgarciam)
>>> > >> Work smarter, not harder!.
>>> > >>
>>> > >> --
>>> > >> View this message in context:
>>> > >>
>>> >
>>> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
>>> > >> n-tp2955144p2968936.html
>>> > >> Sent from the Users forum mailing list archive at Nabble.com.
>>> > >>
>>> > >>
>>> ---------------------------------------------------------------------
>>> > >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> > >> For additional commands, e-mail: users-help@wicket.apache.org
>>> > >>
>>> > >>
>>> > >>
>>> > >>
>>> ---------------------------------------------------------------------
>>> > >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> > >> For additional commands, e-mail: users-help@wicket.apache.org
>>> > >>
>>> > >
>>> > >
>>> ---------------------------------------------------------------------
>>> > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> > > For additional commands, e-mail: users-help@wicket.apache.org
>>> > >
>>> > >
>>> > >
>>> ---------------------------------------------------------------------
>>> > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> > > For additional commands, e-mail: users-help@wicket.apache.org
>>> > >
>>> > >
>>> >
>>> > ---------------------------------------------------------------------
>>> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> > For additional commands, e-mail: users-help@wicket.apache.org
>>> >
>>> >
>>> > ---------------------------------------------------------------------
>>> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> > For additional commands, e-mail: users-help@wicket.apache.org
>>> >
>>> >
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>

Re: PropertyModel Not Refreshing

Posted by nino martinez wael <ni...@gmail.com>.
hmm getting a lot of errors on the services not implementing
serialization...

But does seem theres a difference between calling :

selectedRecordAModel.getObject().getName() and
RecordAPanel.this.selectedRecordA

2010/10/12 nino martinez wael <ni...@gmail.com>

> sorry.. Did'nt see it attached.. So did igor provide you with an fixed
> quickstart (working on his system).. That did not work on glassfish?
>
>
> 2010/10/12 Shelli Orton <Sh...@sjrb.ca>
>
>> The quickstart was sent to the list this morning at 10:04 MST.  Does it
>> need to be resent?
>>
>> Shelli
>>
>> -----Original Message-----
>> From: nino martinez wael [mailto:nino.martinez.wael@gmail.com]
>> Sent: Tuesday, October 12, 2010 11:52 AM
>> To: users@wicket.apache.org
>> Subject: Re: PropertyModel Not Refreshing
>>
>> No dont think so.. Please provide a quickstart.. I have had property
>> models
>> working in 1.2, 1.3, 1.4 and 1.5 so must be error 42:)
>>
>> 2010/10/12 Shelli Orton <Sh...@sjrb.ca>
>>
>> > Hi,
>> >
>> > Thanks for file.  Your first email was missing these changes:
>> >
>> >    IModel<RecordA> selectedRecordAModel;  (I had set mine to
>> > PropertyModel<RecordA> selectedRecordAModel;)
>> >    recordAs.setModel(selectedRecordAModel)
>> >
>> > However, even with those changes applied, I still get the same issue
>> of the
>> > selected record not updating in the edit group.
>> >
>> > I am deploying in Glassfish v3.  Could that have anything to do with
>> my
>> > problems?
>> >
>> > Shelli
>> >
>> > -----Original Message-----
>> > From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
>> > Sent: Tuesday, October 12, 2010 11:35 AM
>> > To: users@wicket.apache.org
>> > Subject: Re: PropertyModel Not Refreshing
>> >
>> > On Tue, Oct 12, 2010 at 10:30 AM, Shelli Orton <Sh...@sjrb.ca>
>> > wrote:
>> > > Thanks for the help.  Your changes got rid of the errors and I can
>> delete
>> > records now (and the list is updated).
>> > >
>> > > However, once a record has been selected for edit and either saved
>> or
>> > cancelled, that same record is always displayed in the edit group when
>> I
>> > choose another record to edit or even when I try to create a new one.
>> I can
>> > even delete the chosen record and it still displays in the edit group.
>> >
>> > works fine here, meaning you did not completely/propery apply my
>> > changes. below is the complete file.
>> >
>> > -igor
>> >
>> > public class RecordAPanel extends Panel
>> > {
>> >    private static final long serialVersionUID = 1L;
>> >
>> >    RecordAService recordAService;
>> >    RecordBService recordBService;
>> >
>> >    RecordA selectedRecordA = new RecordA();
>> >    IModel<RecordA> selectedRecordAModel;
>> >    String unmodifiedRecordA;
>> >
>> >    boolean isNew = false;
>> >
>> >    WebMarkupContainer selectGroup;
>> >    WebMarkupContainer editGroup;
>> >
>> >    Form selectForm;
>> >    Form editForm;
>> >
>> >    DropDownChoice<RecordA> recordAs;
>> >    DropDownChoice<RecordB> recordBs;
>> >
>> >    Button add;
>> >    Button edit;
>> >    Button save;
>> >    Button delete;
>> >    Button cancel;
>> >
>> >    Label editLegendLabel;
>> >    String editLegend;
>> >    Label recordALabel;
>> >    Label recordBLabel;
>> >
>> >    RequiredTextField recordAText;
>> >
>> >    @SuppressWarnings({ "rawtypes", "unchecked" })
>> >    public RecordAPanel(String id)
>> >    {
>> >        super(id);
>> >
>> >        recordAService = ((Application)
>> > RequestCycle.get().getApplication()).getRecordAService();
>> >        recordBService = ((Application)
>> > RequestCycle.get().getApplication()).getRecordBService();
>> >
>> >        selectedRecordAModel = new PropertyModel<RecordA>(this,
>> > "selectedRecordA");
>> >        this.setDefaultModel(selectedRecordAModel);
>> >
>> >        // ************* Select  Group *************
>> >
>> >        selectGroup = new WebMarkupContainer("selectGroup");
>> >        selectForm = new Form("selectForm");
>> >
>> >        recordAs = new DropDownChoice<RecordA>("recordAs");
>> >        recordAs.setModel(selectedRecordAModel);
>> >        recordAs.setChoices(recordAsModel);
>> >        recordAs.setChoiceRenderer(new RecordARenderer());
>> >
>> >        //            recordAs = (DropDownChoice<RecordA>) new
>> > DropDownChoice<RecordA>("recordAs",
>> >        //                    new PropertyModel<RecordA>(this,
>> > "selectedRecordA"),
>> >        //                    recordAsModel,
>> >        //                    new RecordARenderer());
>> >
>> >        recordAs.setNullValid(false);
>> >
>> >        selectForm.add(recordAs);
>> >
>> >        add = new Button("add")
>> >        {
>> >            private static final long serialVersionUID = 1L;
>> >
>> >            public void onSubmit()
>> >            {
>> >                setSelectedRecordA(new RecordA());
>> >                isNew = true;
>> >                editLegend = "New";
>> >                editGroup.setVisible(true);
>> >                selectGroup.setVisible(false);
>> >            }
>> >        };
>> >
>> >        selectForm.add(add);
>> >
>> >        edit = new Button("edit")
>> >        {
>> >            private static final long serialVersionUID = 1L;
>> >
>> >            public void onSubmit()
>> >            {
>> >                if (selectedRecordA == null)
>> >                {
>> >                    info("You must select a record to edit.");
>> >                }
>> >                else
>> >                {
>> >                    unmodifiedRecordA = selectedRecordA.getName();
>> >                    isNew = false;
>> >                    editLegend = "Edit";
>> >                    editGroup.setVisible(true);
>> >                    selectGroup.setVisible(false);
>> >                }
>> >            }
>> >        };
>> >
>> >        selectForm.add(edit);
>> >
>> >        delete = new Button("delete")
>> >        {
>> >            private static final long serialVersionUID = 1L;
>> >
>> >            public void onSubmit()
>> >            {
>> >                if (selectedRecordA == null)
>> >                {
>> >                    info("You must select a record to delete.");
>> >                }
>> >                else
>> >                {
>> >                    // Delete the selected record
>> >                    unmodifiedRecordA = selectedRecordA.getName();
>> >                    recordAService.delete(selectedRecordA.getName());
>> >                    selectedRecordA = null;
>> >                    info("Deleted '" + unmodifiedRecordA + "'");
>> >
>> >                    // Force refresh of records list
>> >                    RecordAPanel.this.recordAsModel.detach();
>> >                }
>> >            }
>> >        };
>> >
>> >        // Add confirmation dialog box
>> >        delete.add(new SimpleAttributeModifier("onclick",
>> >                "if (!confirm('Please confirm you want to delete this
>> > record') ){ return false; }"));
>> >
>> >        selectForm.add(delete);
>> >        selectGroup.add(selectForm);
>> >
>> >        this.add(selectGroup);
>> >
>> >        // ************* Edit Group *************
>> >
>> >        editGroup = new WebMarkupContainer("editGroup");
>> >
>> >        editLegendLabel = new Label("editLegend", new
>> PropertyModel(this,
>> >                "editLegend"));
>> >
>> >        editGroup.add(editLegendLabel);
>> >
>> >        editForm = new Form("editForm");
>> >
>> >        recordALabel = new Label("recordALabel", "Record A");
>> >        editForm.add(recordALabel);
>> >
>> >        recordBLabel = new Label("recordBLabel", "Record B");
>> >        editForm.add(recordBLabel);
>> >
>> >        recordAText = new RequiredTextField("recordAText",
>> >                new PropertyModel(selectedRecordAModel, "name"));
>> >
>> >        editForm.add(recordAText);
>> >
>> >        recordBs = new DropDownChoice<RecordB>("recordBs");
>> >        recordBs.setModel(new PropertyModel(selectedRecordAModel,
>> > "recordB"));
>> >        recordBs.setChoices(RecordAPanel.this.getRecordBs());
>> >        recordBs.setChoiceRenderer(new RecordBRenderer());
>> >
>> >        editForm.add(recordBs);
>> >
>> >        save = new Button("save")
>> >        {
>> >            private static final long serialVersionUID = 1L;
>> >
>> >            @Override
>> >            public void onSubmit()
>> >            {
>> >                if (isNew)
>> >                {
>> >
>> > recordAService.create(RecordAPanel.this.selectedRecordA);
>> >                        info("Created '"
>> >                                +
>> > RecordAPanel.this.selectedRecordA.getName()
>> >                                + "'");
>> >                }
>> >                else
>> >                {
>> >                        recordAService.update(unmodifiedRecordA,
>> >                                RecordAPanel.this.selectedRecordA);
>> >                        info("Updated '"
>> >                                +
>> > RecordAPanel.this.selectedRecordA.getName()
>> >                                + "'");
>> >                }
>> >
>> >                // TODO Update the dropdown list?
>> >
>> >                editGroup.setVisible(false);
>> >                selectGroup.setVisible(true);
>> >            }
>> >        };
>> >
>> >        editForm.add(save);
>> >
>> >        cancel = new Button("cancel")
>> >        {
>> >            private static final long serialVersionUID = 1L;
>> >
>> >            public void onSubmit()
>> >            {
>> >                RecordAPanel.this.selectedRecordA = null;
>> >                editGroup.setVisible(false);
>> >                selectGroup.setVisible(true);
>> >            }
>> >        };
>> >
>> >        cancel.setDefaultFormProcessing(false);
>> >        editForm.add(cancel);
>> >
>> >        editGroup.add(editForm);
>> >
>> >        editGroup.setVisible(false);
>> >        this.add(editGroup);
>> >    }
>> >
>> >    public RecordA getSelectedRecordA()
>> >    {
>> >        return selectedRecordA;
>> >    }
>> >
>> >    public void setSelectedRecordA(RecordA selectedRecordA)
>> >    {
>> >        this.selectedRecordA = selectedRecordA;
>> >    }
>> >
>> >    public LoadableDetachableModel<List<RecordA>> recordAsModel = new
>> > LoadableDetachableModel<List<RecordA>>()
>> >    {
>> >        private static final long serialVersionUID = 1L;
>> >
>> >        @Override
>> >        protected List<RecordA> load()
>> >        {
>> >            return recordAService.getList();
>> >        }
>> >
>> >        public void detach()
>> >        {
>> >            super.detach();
>> >        }
>> >    };
>> >
>> >    // TODO change this to LDM?
>> >    List<RecordB> getRecordBs()
>> >    {
>> >        return recordBService.getList();
>> >    }
>> >
>> >    class RecordARenderer implements IChoiceRenderer<RecordA>
>> >    {
>> >        private static final long serialVersionUID = 1L;
>> >
>> >        public Object getDisplayValue(RecordA recordA)
>> >        {
>> >            return recordA.getName();
>> >        }
>> >
>> >        public String getIdValue(RecordA recordA, int index)
>> >        {
>> >            return recordA.getName();
>> >        }
>> >    }
>> >
>> >    class RecordBRenderer implements IChoiceRenderer<RecordB>
>> >    {
>> >        private static final long serialVersionUID = 1L;
>> >
>> >        public Object getDisplayValue(RecordB recordB)
>> >        {
>> >            return recordB.getName();
>> >        }
>> >
>> >        public String getIdValue(RecordB recordB, int index)
>> >        {
>> >            return recordB.getName();
>> >        }
>> >    }
>> > }
>> >
>> > >
>> > > Shelli
>> > >
>> > > -----Original Message-----
>> > > From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
>> > > Sent: Tuesday, October 12, 2010 10:38 AM
>> > > To: users@wicket.apache.org
>> > > Subject: Re: PropertyModel Not Refreshing
>> > >
>> > > here are the tweaks you need to make this work:
>> > >
>> > > selectedRecordAModel = new PropertyModel<RecordA>(this,
>> > "selectedRecordA");
>> > >
>> > > recordAText = new RequiredTextField("recordAText",
>> > >                new PropertyModel(selectedRecordAModel, "name"));
>> > >
>> > >  recordBs.setModel(new PropertyModel(selectedRecordAModel,
>> "recordB"));
>> > >
>> > > have fun
>> > >
>> > > -igor
>> > >
>> > > On Tue, Oct 12, 2010 at 9:03 AM, Shelli Orton <Sh...@sjrb.ca>
>> > wrote:
>> > >> I've been able to create a sample application that exhibits the
>> > >> same/similar problems to mine.  The sample makes use of an
>> in-memory
>> > >> list for the data versus accessing a database and so there's some
>> > >> differences.  However, I believe the problems that this sample
>> exhibits
>> > >> have the same root cause as my project (which I believe have
>> something
>> > >> to do with how my models are set up...).
>> > >>
>> > >> Issues this sample exhibits:
>> > >>
>> > >> 1. Choose to edit an existing record, then cancel the edit.  Choose
>> > >> another/the same record to edit and the selected record is null
>> (error
>> > >> message "You must select a record to edit" is displayed).  Must
>> > >> close/open session to reset.
>> > >>
>> > >> 2. Choose to edit an existing record and save the edit.  Choose
>> > >> another/the same record to edit and you get a NPE:
>> > >>
>> > >>    WicketMessage: Method onFormSubmitted of interface
>> > >> org.apache.wicket.markup.html.form.IFormSubmitListener targeted at
>> > >> component [MarkupContainer [Component id = selectForm]] threw an
>> > >> exception
>> > >>
>> > >>    Root cause:
>> > >>
>> > >>    java.lang.NullPointerException
>> > >>    at
>> > >>
>> org.apache.wicket.markup.html.form.AbstractSingleSelectChoice.convertCho
>> > >> iceIdToChoice(AbstractSingleSelectChoice.java:247)
>> > >>
>> > >> 3. Create a new record and try to save it and get
>> > >> WicketRuntimeException:
>> > >>
>> > >>    WicketMessage: Attempted to set property value on a null object.
>> > >> Property expression: name Value: New One
>> > >>
>> > >>    Root cause:
>> > >>
>> > >>    org.apache.wicket.WicketRuntimeException: Attempted to set
>> property
>> > >> value on a null object. Property expression: name Value: New One
>> > >>    at
>> > >>
>> org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.j
>> > >> ava:125)
>> > >>
>> > >> 4. Create a new record and then cancel the add, Choose an existing
>> > >> record to edit and the selected record is null (error message "You
>> must
>> > >> select a record to edit" is displayed).  Must close/open session to
>> > >> reset.
>> > >>
>> > >> As always, all help is greatly appreciated as I am stumped.
>> > >>
>> > >> Thanks,
>> > >> Shelli
>> > >>
>> > >> -----Original Message-----
>> > >> From: jcgarciam [mailto:jcgarciam@gmail.com]
>> > >> Sent: Friday, October 08, 2010 1:41 PM
>> > >> To: users@wicket.apache.org
>> > >> Subject: Re: PropertyModel Not Refreshing
>> > >>
>> > >>
>> > >> The attachment didn't make it,
>> > >>
>> > >> Can you try to extract out the relevant part and creates a
>> quickstart
>> > >> project that actually reproduces your issue?
>> > >>
>> > >>
>> > >> On Fri, Oct 8, 2010 at 1:41 PM, Shelli Orton [via Apache Wicket] <
>> > >>
>> ml-node+2968688-305091622-65838@n4.nabble.com<ml...@n4.nabble.com>
>> <ml-node%2B2968688-30509162
>> 2-65838@n4.nabble.com>
>> > <ml-node%2B2968688-30509162
>> > >> 2-65838@n4.nabble.com>
>> > >>> wrote:
>> > >>
>> > >>> Hi,
>> > >>>
>> > >>> I have been trying different things to see if I could get my code
>> to
>> > >> work
>> > >>> (and understand Wicket models better), but am still stuck.  I have
>> a
>> > >>> attached the (latest) panel class code which I hope is sufficient
>> to
>> > >> help.
>> > >>>
>> > >>> I was reading about different models (both online and the Wicket
>> in
>> > >> Action
>> > >>> book) and thought that perhaps using a CompoundPropertyModel was
>> more
>> > >>> appropriate and may help with my issues.  Originally, I only
>> declared
>> > >>> selectedRecordA (line 40) but didn't instantiate it.  The select
>> group
>> > >>> displayed properly but when I chose a record from the list and
>> tried
>> > >> to edit
>> > >>> it, this exception was thrown:
>> > >>>
>> > >>>     WicketMessage: Attempted to set property value on a null
>> object.
>> > >>> Property expression: recordA Value: Name=A-One
>> > >>>     Root cause:
>> > >>>
>> > >>>     org.apache.wicket.WicketRuntimeException: Attempted to set
>> > >> property
>> > >>> value on a null object. Property expression: recordA Value:
>> Name=A-One
>> > >>>         at
>> > >>>
>> > >>
>> org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.j
>> > >> ava:125)
>> > >>>
>> > >>>         at
>> > >>>
>> > >>
>> org.apache.wicket.model.AbstractPropertyModel.setObject(AbstractProperty
>> > >> Model.java:169)
>> > >>>
>> > >>>         at
>> > >>>
>> org.apache.wicket.Component.setDefaultModelObject(Component.java:3125)
>> > >>>         ....
>> > >>>
>> > >>> I set breakpoints on the getSelectedRecordA and setSelectedRecordA
>> > >> methods,
>> > >>> but these aren't called when during the request cycle when the
>> edit
>> > >> button
>> > >>> is clicked.
>> > >>>
>> > >>> I then changed the class so that selectedRecordA is initialized to
>> an
>> > >> empty
>> > >>> instance of RecordA. This got rid of the above error.  However, I
>> > >> cannot
>> > >>> save the edit changes because the selectedRecordA is still the
>> empty
>> > >>> instance that was created in the initialization and the
>> persistence
>> > >> layer
>> > >>> throws an exception.  This same problem exists if I try to add a
>> new
>> > >> RecordA
>> > >>> or try to delete an existing one.
>> > >>>
>> > >>> If I choose to cancel the edit and then select another record to
>> edit,
>> > >> I
>> > >>> get the message "You must select a record to edit" (line 131).
>> This
>> > >> is
>> > >>> because the cancel onSubmit sets selectedRecordA to null and
>> choosing
>> > >> the
>> > >>> record from the DDC is not setting it to the chosen record.
>> > >>>
>> > >>> Clearly I am not setting up this CompoundPropertyModel properly so
>> > >> that the
>> > >>> selectedARecord is set by the model.  Can someone tell me what I'm
>> > >> doing
>> > >>> wrong?
>> > >>>
>> > >>> All help is greatly appreciated,
>> > >>>
>> > >>> Shelli
>> > >>>
>> > >>>
>> > >>> -----Original Message-----
>> > >>> From: Igor Vaynberg [mailto:[hidden
>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=0>]
>> > >>>
>> > >>> Sent: Thursday, October 07, 2010 11:27 AM
>> > >>> To: [hidden email]
>> > >> <http://user/SendEmail.jtp?type=node&node=2968688&i=1>
>> > >>> Subject: Re: PropertyModel Not Refreshing
>> > >>>
>> > >>> you have posted an incomplete piece of code and somehow from that
>> we
>> > >>> are supposed to guess what is not working? create a quickstart and
>> > >>> provide that.
>> > >>>
>> > >>> -igor
>> > >>>
>> > >>> On Thu, Oct 7, 2010 at 10:15 AM, Shelli Orton <[hidden
>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=2>>
>> > >>> wrote:
>> > >>>
>> > >>> > Does nobody have any suggestions?  If I can't get this fixed,
>> I'm
>> > >> going
>> > >>> > to have to write the app in another framework (possibly GWT) and
>> I'd
>> > >>> > really rather not have to do that.
>> > >>> >
>> > >>> > Shelli
>> > >>> >
>> > >>> > -----Original Message-----
>> > >>> > From: Shelli Orton
>> > >>> > Sent: Wednesday, October 06, 2010 3:52 PM
>> > >>> > To: [hidden
>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=3>
>> > >>> > Subject: PropertyModel Not Refreshing
>> > >>> >
>> > >>> > Hi,
>> > >>> >
>> > >>> > First, thanks to all who have been helping me as I am new to
>> Wicket.
>> > >> I
>> > >>> > am splitting out two issues I am dealing with to try to keep
>> things
>> > >>> > clear.
>> > >>> >
>> > >>> > I am trying to write a simple app that does CRUD operations on
>> > >> database
>> > >>> > records.  The goal is for the app to make use of a tab panel
>> where
>> > >> each
>> > >>> > tab encapsulates one table from the database.  Each tab panel
>> has
>> > >> two
>> > >>> > groups (WebMarkupContainer).  The first, selectGroup, displays a
>> > >> list
>> > >>> > (DDC) of the current items, and three buttons, add, edit and
>> delete.
>> > >>> > The second, editGroup, is displayed when either the add or edit
>> > >> button
>> > >>> > was clicked on the select group, displays the record attributes
>> and
>> > >> save
>> > >>> > and cancel buttons.  The tab panel has a "selectedRecord" which
>> is
>> > >> used
>> > >>> > by both groups' components via PropertyModels. Very basic stuff.
>> > >>> >
>> > >>> > When I choose a record and click the edit button, the record is
>> > >>> > displayed in the edit group properly.  If I then choose cancel,
>> the
>> > >> edit
>> > >>> > group is no longer displayed and the select group DDC selection
>> is
>> > >> null
>> > >>> > as expected. I then choose another record from the list and
>> click
>> > >> the
>> > >>> > edit button and the previous record information is displayed in
>> the
>> > >> edit
>> > >>> > group even though the select group DDC shows the
>> correct/selected
>> > >>> > record.
>> > >>> >
>> > >>> > This problem also occurs if I first choose to add a new record
>> and
>> > >> then
>> > >>> > cancel the add and then choose to edit a different record.  The
>> DDC
>> > >>> > shows the correct/selected record, but all the attributes in the
>> > >> edit
>> > >>> > group are null/defaults for a new record.
>> > >>> >
>> > >>> > If I remove the call to setDefaultFormProcessing(false) on the
>> > >> cancel
>> > >>> > button, selecting other records for edit works correctly, but I
>> > >> can't
>> > >>> > cancel a creating a new record if I use a RequiredTextField
>> because
>> > >> the
>> > >>> > form validation fails.
>> > >>> >
>> > >>> > If I select a record for editing or save the newly created
>> record, I
>> > >> can
>> > >>> > select a different record for edit or create another one
>> correctly.
>> > >> So
>> > >>> > I must be doing something wrong in the cancel logic. My editForm
>> > >>> > (created in the EditGroup constructor) looks like this:
>> > >>> >
>> > >>> >            Form editForm = new Form("editForm");
>> > >>> >
>> > >>> >            editForm.add(new Label("nameLabel", "Name"));
>> > >>> >
>> > >>> >            editForm.add(new Label("attributeLabel",
>> "Attribute"));
>> > >>> >
>> > >>> >            editForm.add(new
>> > >> RequiredTextField<String>("recordNameText",
>> > >>> >                    new PropertyModel<String>(MyRecordPanel.this,
>> > >>> >                            "selectedRecord.name")));
>> > >>> >
>> > >>> >            editForm.add(new DropDownChoice<Lir>("attributes",
>> > >>> >                    new
>> PropertyModel<Attribute>(MyRecordPanel.this,
>> > >>> >                            "selectedRecord.attribute"),
>> > >>> >                    RateCentrePanel.this.getAttributes(),
>> > >>> >                    new AttributeRenderer()));
>> > >>> >
>> > >>> >            ....
>> > >>> >
>> > >>> >            editForm.add(new Button("cancel")
>> > >>> >            {
>> > >>> >                private static final long serialVersionUID = 1L;
>> > >>> >
>> > >>> >                public void onSubmit()
>> > >>> >                {
>> > >>> >                    MyRecordPanel.this.selectedRecord = null;
>> > >>> >                    editGroup.setVisible(false);
>> > >>> >                    selectGroup.setVisible(true);
>> > >>> >                }
>> > >>> >            }.setDefaultFormProcessing(false));
>> > >>> >
>> > >>> >            add(editForm);
>> > >>> >
>> > >>> > Other than setting the selectedRecord to null, what should I be
>> > >> doing
>> > >>> > differently?
>> > >>> >
>> > >>> > Thanks in advance!
>> > >>> >
>> > >>> > Shelli
>> > >>> >
>> > >>> >
>> > >>
>> ---------------------------------------------------------------------
>> > >>> > To unsubscribe, e-mail: [hidden
>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=4>
>> > >>> > For additional commands, e-mail: [hidden
>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=5>
>> > >>> >
>> > >>> >
>> > >>> >
>> > >>
>> ---------------------------------------------------------------------
>> > >>> > To unsubscribe, e-mail: [hidden
>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=6>
>> > >>> > For additional commands, e-mail: [hidden
>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=7>
>> > >>> >
>> > >>> >
>> > >>>
>> ---------------------------------------------------------------------
>> > >>> To unsubscribe, e-mail: [hidden
>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=8>
>> > >>> For additional commands, e-mail: [hidden
>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=9>
>> > >>>
>> > >>>
>> > >>>
>> > >>>
>> > >>>
>> ---------------------------------------------------------------------
>> > >>> To unsubscribe, e-mail: [hidden
>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=10>
>> > >>> For additional commands, e-mail: [hidden
>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=11>
>> > >>>
>> > >>> ------------------------------
>> > >>>  View message @
>> > >>>
>> > >>
>> >
>> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
>> > >> n-tp2955144p2968688.html
>> > >>> To start a new topic under Apache Wicket, email
>> > >>>
>> > >>
>> ml-node+1842946-398011874-65838@n4.nabble.com<ml...@n4.nabble.com>
>> <ml-node%2B1842946-39801187
>> 4-65838@n4.nabble.com>
>> > <ml-node%2B1842946-39801187
>> > >> 4-65838@n4.nabble.com>
>> > >>> To unsubscribe from Apache Wicket, click
>> > >>
>> here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp
>> > ?
>> > >>
>> tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
>> > >> QyOTQ2fDEyNTYxMzc3ODY=>.
>> > >>>
>> > >>>
>> > >>>
>> > >>
>> > >>
>> > >> --
>> > >> Sincerely,
>> > >> JC (http://www.linkedin.com/in/jcgarciam)
>> > >> Work smarter, not harder!.
>> > >>
>> > >> --
>> > >> View this message in context:
>> > >>
>> >
>> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
>> > >> n-tp2955144p2968936.html
>> > >> Sent from the Users forum mailing list archive at Nabble.com.
>> > >>
>> > >>
>> ---------------------------------------------------------------------
>> > >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> > >> For additional commands, e-mail: users-help@wicket.apache.org
>> > >>
>> > >>
>> > >>
>> > >>
>> ---------------------------------------------------------------------
>> > >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> > >> For additional commands, e-mail: users-help@wicket.apache.org
>> > >>
>> > >
>> > >
>> ---------------------------------------------------------------------
>> > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> > > For additional commands, e-mail: users-help@wicket.apache.org
>> > >
>> > >
>> > >
>> ---------------------------------------------------------------------
>> > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> > > For additional commands, e-mail: users-help@wicket.apache.org
>> > >
>> > >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> > For additional commands, e-mail: users-help@wicket.apache.org
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> > For additional commands, e-mail: users-help@wicket.apache.org
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>

RE: PropertyModel Not Refreshing

Posted by Shelli Orton <Sh...@sjrb.ca>.
Hi,

Sorry about the serialization errors.  My "real" code is using JPA
services/entities and they are serialized.  

There's a number of tabs that need to be written, but I was just trying
to get the one to work before starting the others.  I set up the recordB
panel to make sure I was creating the tabs correctly.  Eventually it's
where recordBs will be CRUDed.

Shelli

-----Original Message-----
From: nino martinez wael [mailto:nino.martinez.wael@gmail.com] 
Sent: Tuesday, October 12, 2010 12:19 PM
To: users@wicket.apache.org
Subject: Re: PropertyModel Not Refreshing

I can confirm the edit issue.. Also what's supposed to happen in recordb
panel?

I might have a chance to look at it a little later..

2010/10/12 Shelli Orton <Sh...@sjrb.ca>

> He provided an updated RecordAPanel.java class that works on his
system.
> I updated mine to match his, but still have an issue where once a
record
> has been selected for edit, that's the only record that is displayed
in
> the edit group regardless of which record is chosen from the list in
the
> select group or if I choose to create a new record.
>
> If it's not the code, I was thinking that it might be the app server
> doing some caching, but honestly, I'm grasping at straws.
>
> Shelli
>
> -----Original Message-----
> From: nino martinez wael [mailto:nino.martinez.wael@gmail.com]
> Sent: Tuesday, October 12, 2010 11:58 AM
> To: users@wicket.apache.org
> Subject: Re: PropertyModel Not Refreshing
>
> sorry.. Did'nt see it attached.. So did igor provide you with an fixed
> quickstart (working on his system).. That did not work on glassfish?
>
> 2010/10/12 Shelli Orton <Sh...@sjrb.ca>
>
> > The quickstart was sent to the list this morning at 10:04 MST.  Does
> it
> > need to be resent?
> >
> > Shelli
> >
> > -----Original Message-----
> > From: nino martinez wael [mailto:nino.martinez.wael@gmail.com]
> > Sent: Tuesday, October 12, 2010 11:52 AM
> > To: users@wicket.apache.org
> > Subject: Re: PropertyModel Not Refreshing
> >
> > No dont think so.. Please provide a quickstart.. I have had property
> > models
> > working in 1.2, 1.3, 1.4 and 1.5 so must be error 42:)
> >
> > 2010/10/12 Shelli Orton <Sh...@sjrb.ca>
> >
> > > Hi,
> > >
> > > Thanks for file.  Your first email was missing these changes:
> > >
> > >    IModel<RecordA> selectedRecordAModel;  (I had set mine to
> > > PropertyModel<RecordA> selectedRecordAModel;)
> > >    recordAs.setModel(selectedRecordAModel)
> > >
> > > However, even with those changes applied, I still get the same
issue
> > of the
> > > selected record not updating in the edit group.
> > >
> > > I am deploying in Glassfish v3.  Could that have anything to do
with
> > my
> > > problems?
> > >
> > > Shelli
> > >
> > > -----Original Message-----
> > > From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
> > > Sent: Tuesday, October 12, 2010 11:35 AM
> > > To: users@wicket.apache.org
> > > Subject: Re: PropertyModel Not Refreshing
> > >
> > > On Tue, Oct 12, 2010 at 10:30 AM, Shelli Orton
> <Sh...@sjrb.ca>
> > > wrote:
> > > > Thanks for the help.  Your changes got rid of the errors and I
can
> > delete
> > > records now (and the list is updated).
> > > >
> > > > However, once a record has been selected for edit and either
saved
> > or
> > > cancelled, that same record is always displayed in the edit group
> when
> > I
> > > choose another record to edit or even when I try to create a new
> one.
> > I can
> > > even delete the chosen record and it still displays in the edit
> group.
> > >
> > > works fine here, meaning you did not completely/propery apply my
> > > changes. below is the complete file.
> > >
> > > -igor
> > >
> > > public class RecordAPanel extends Panel
> > > {
> > >    private static final long serialVersionUID = 1L;
> > >
> > >    RecordAService recordAService;
> > >    RecordBService recordBService;
> > >
> > >    RecordA selectedRecordA = new RecordA();
> > >    IModel<RecordA> selectedRecordAModel;
> > >    String unmodifiedRecordA;
> > >
> > >    boolean isNew = false;
> > >
> > >    WebMarkupContainer selectGroup;
> > >    WebMarkupContainer editGroup;
> > >
> > >    Form selectForm;
> > >    Form editForm;
> > >
> > >    DropDownChoice<RecordA> recordAs;
> > >    DropDownChoice<RecordB> recordBs;
> > >
> > >    Button add;
> > >    Button edit;
> > >    Button save;
> > >    Button delete;
> > >    Button cancel;
> > >
> > >    Label editLegendLabel;
> > >    String editLegend;
> > >    Label recordALabel;
> > >    Label recordBLabel;
> > >
> > >    RequiredTextField recordAText;
> > >
> > >    @SuppressWarnings({ "rawtypes", "unchecked" })
> > >    public RecordAPanel(String id)
> > >    {
> > >        super(id);
> > >
> > >        recordAService = ((Application)
> > > RequestCycle.get().getApplication()).getRecordAService();
> > >        recordBService = ((Application)
> > > RequestCycle.get().getApplication()).getRecordBService();
> > >
> > >        selectedRecordAModel = new PropertyModel<RecordA>(this,
> > > "selectedRecordA");
> > >        this.setDefaultModel(selectedRecordAModel);
> > >
> > >        // ************* Select  Group *************
> > >
> > >        selectGroup = new WebMarkupContainer("selectGroup");
> > >        selectForm = new Form("selectForm");
> > >
> > >        recordAs = new DropDownChoice<RecordA>("recordAs");
> > >        recordAs.setModel(selectedRecordAModel);
> > >        recordAs.setChoices(recordAsModel);
> > >        recordAs.setChoiceRenderer(new RecordARenderer());
> > >
> > >        //            recordAs = (DropDownChoice<RecordA>) new
> > > DropDownChoice<RecordA>("recordAs",
> > >        //                    new PropertyModel<RecordA>(this,
> > > "selectedRecordA"),
> > >        //                    recordAsModel,
> > >        //                    new RecordARenderer());
> > >
> > >        recordAs.setNullValid(false);
> > >
> > >        selectForm.add(recordAs);
> > >
> > >        add = new Button("add")
> > >        {
> > >            private static final long serialVersionUID = 1L;
> > >
> > >            public void onSubmit()
> > >            {
> > >                setSelectedRecordA(new RecordA());
> > >                isNew = true;
> > >                editLegend = "New";
> > >                editGroup.setVisible(true);
> > >                selectGroup.setVisible(false);
> > >            }
> > >        };
> > >
> > >        selectForm.add(add);
> > >
> > >        edit = new Button("edit")
> > >        {
> > >            private static final long serialVersionUID = 1L;
> > >
> > >            public void onSubmit()
> > >            {
> > >                if (selectedRecordA == null)
> > >                {
> > >                    info("You must select a record to edit.");
> > >                }
> > >                else
> > >                {
> > >                    unmodifiedRecordA = selectedRecordA.getName();
> > >                    isNew = false;
> > >                    editLegend = "Edit";
> > >                    editGroup.setVisible(true);
> > >                    selectGroup.setVisible(false);
> > >                }
> > >            }
> > >        };
> > >
> > >        selectForm.add(edit);
> > >
> > >        delete = new Button("delete")
> > >        {
> > >            private static final long serialVersionUID = 1L;
> > >
> > >            public void onSubmit()
> > >            {
> > >                if (selectedRecordA == null)
> > >                {
> > >                    info("You must select a record to delete.");
> > >                }
> > >                else
> > >                {
> > >                    // Delete the selected record
> > >                    unmodifiedRecordA = selectedRecordA.getName();
> > >
recordAService.delete(selectedRecordA.getName());
> > >                    selectedRecordA = null;
> > >                    info("Deleted '" + unmodifiedRecordA + "'");
> > >
> > >                    // Force refresh of records list
> > >                    RecordAPanel.this.recordAsModel.detach();
> > >                }
> > >            }
> > >        };
> > >
> > >        // Add confirmation dialog box
> > >        delete.add(new SimpleAttributeModifier("onclick",
> > >                "if (!confirm('Please confirm you want to delete
this
> > > record') ){ return false; }"));
> > >
> > >        selectForm.add(delete);
> > >        selectGroup.add(selectForm);
> > >
> > >        this.add(selectGroup);
> > >
> > >        // ************* Edit Group *************
> > >
> > >        editGroup = new WebMarkupContainer("editGroup");
> > >
> > >        editLegendLabel = new Label("editLegend", new
> > PropertyModel(this,
> > >                "editLegend"));
> > >
> > >        editGroup.add(editLegendLabel);
> > >
> > >        editForm = new Form("editForm");
> > >
> > >        recordALabel = new Label("recordALabel", "Record A");
> > >        editForm.add(recordALabel);
> > >
> > >        recordBLabel = new Label("recordBLabel", "Record B");
> > >        editForm.add(recordBLabel);
> > >
> > >        recordAText = new RequiredTextField("recordAText",
> > >                new PropertyModel(selectedRecordAModel, "name"));
> > >
> > >        editForm.add(recordAText);
> > >
> > >        recordBs = new DropDownChoice<RecordB>("recordBs");
> > >        recordBs.setModel(new PropertyModel(selectedRecordAModel,
> > > "recordB"));
> > >        recordBs.setChoices(RecordAPanel.this.getRecordBs());
> > >        recordBs.setChoiceRenderer(new RecordBRenderer());
> > >
> > >        editForm.add(recordBs);
> > >
> > >        save = new Button("save")
> > >        {
> > >            private static final long serialVersionUID = 1L;
> > >
> > >            @Override
> > >            public void onSubmit()
> > >            {
> > >                if (isNew)
> > >                {
> > >
> > > recordAService.create(RecordAPanel.this.selectedRecordA);
> > >                        info("Created '"
> > >                                +
> > > RecordAPanel.this.selectedRecordA.getName()
> > >                                + "'");
> > >                }
> > >                else
> > >                {
> > >                        recordAService.update(unmodifiedRecordA,
> > >                                RecordAPanel.this.selectedRecordA);
> > >                        info("Updated '"
> > >                                +
> > > RecordAPanel.this.selectedRecordA.getName()
> > >                                + "'");
> > >                }
> > >
> > >                // TODO Update the dropdown list?
> > >
> > >                editGroup.setVisible(false);
> > >                selectGroup.setVisible(true);
> > >            }
> > >        };
> > >
> > >        editForm.add(save);
> > >
> > >        cancel = new Button("cancel")
> > >        {
> > >            private static final long serialVersionUID = 1L;
> > >
> > >            public void onSubmit()
> > >            {
> > >                RecordAPanel.this.selectedRecordA = null;
> > >                editGroup.setVisible(false);
> > >                selectGroup.setVisible(true);
> > >            }
> > >        };
> > >
> > >        cancel.setDefaultFormProcessing(false);
> > >        editForm.add(cancel);
> > >
> > >        editGroup.add(editForm);
> > >
> > >        editGroup.setVisible(false);
> > >        this.add(editGroup);
> > >    }
> > >
> > >    public RecordA getSelectedRecordA()
> > >    {
> > >        return selectedRecordA;
> > >    }
> > >
> > >    public void setSelectedRecordA(RecordA selectedRecordA)
> > >    {
> > >        this.selectedRecordA = selectedRecordA;
> > >    }
> > >
> > >    public LoadableDetachableModel<List<RecordA>> recordAsModel =
new
> > > LoadableDetachableModel<List<RecordA>>()
> > >    {
> > >        private static final long serialVersionUID = 1L;
> > >
> > >        @Override
> > >        protected List<RecordA> load()
> > >        {
> > >            return recordAService.getList();
> > >        }
> > >
> > >        public void detach()
> > >        {
> > >            super.detach();
> > >        }
> > >    };
> > >
> > >    // TODO change this to LDM?
> > >    List<RecordB> getRecordBs()
> > >    {
> > >        return recordBService.getList();
> > >    }
> > >
> > >    class RecordARenderer implements IChoiceRenderer<RecordA>
> > >    {
> > >        private static final long serialVersionUID = 1L;
> > >
> > >        public Object getDisplayValue(RecordA recordA)
> > >        {
> > >            return recordA.getName();
> > >        }
> > >
> > >        public String getIdValue(RecordA recordA, int index)
> > >        {
> > >            return recordA.getName();
> > >        }
> > >    }
> > >
> > >    class RecordBRenderer implements IChoiceRenderer<RecordB>
> > >    {
> > >        private static final long serialVersionUID = 1L;
> > >
> > >        public Object getDisplayValue(RecordB recordB)
> > >        {
> > >            return recordB.getName();
> > >        }
> > >
> > >        public String getIdValue(RecordB recordB, int index)
> > >        {
> > >            return recordB.getName();
> > >        }
> > >    }
> > > }
> > >
> > > >
> > > > Shelli
> > > >
> > > > -----Original Message-----
> > > > From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
> > > > Sent: Tuesday, October 12, 2010 10:38 AM
> > > > To: users@wicket.apache.org
> > > > Subject: Re: PropertyModel Not Refreshing
> > > >
> > > > here are the tweaks you need to make this work:
> > > >
> > > > selectedRecordAModel = new PropertyModel<RecordA>(this,
> > > "selectedRecordA");
> > > >
> > > > recordAText = new RequiredTextField("recordAText",
> > > >                new PropertyModel(selectedRecordAModel, "name"));
> > > >
> > > >  recordBs.setModel(new PropertyModel(selectedRecordAModel,
> > "recordB"));
> > > >
> > > > have fun
> > > >
> > > > -igor
> > > >
> > > > On Tue, Oct 12, 2010 at 9:03 AM, Shelli Orton
> <Sh...@sjrb.ca>
> > > wrote:
> > > >> I've been able to create a sample application that exhibits the
> > > >> same/similar problems to mine.  The sample makes use of an
> > in-memory
> > > >> list for the data versus accessing a database and so there's
some
> > > >> differences.  However, I believe the problems that this sample
> > exhibits
> > > >> have the same root cause as my project (which I believe have
> > something
> > > >> to do with how my models are set up...).
> > > >>
> > > >> Issues this sample exhibits:
> > > >>
> > > >> 1. Choose to edit an existing record, then cancel the edit.
> Choose
> > > >> another/the same record to edit and the selected record is null
> > (error
> > > >> message "You must select a record to edit" is displayed).  Must
> > > >> close/open session to reset.
> > > >>
> > > >> 2. Choose to edit an existing record and save the edit.  Choose
> > > >> another/the same record to edit and you get a NPE:
> > > >>
> > > >>    WicketMessage: Method onFormSubmitted of interface
> > > >> org.apache.wicket.markup.html.form.IFormSubmitListener targeted
> at
> > > >> component [MarkupContainer [Component id = selectForm]] threw
an
> > > >> exception
> > > >>
> > > >>    Root cause:
> > > >>
> > > >>    java.lang.NullPointerException
> > > >>    at
> > > >>
> >
>
org.apache.wicket.markup.html.form.AbstractSingleSelectChoice.convertCho
> > > >> iceIdToChoice(AbstractSingleSelectChoice.java:247)
> > > >>
> > > >> 3. Create a new record and try to save it and get
> > > >> WicketRuntimeException:
> > > >>
> > > >>    WicketMessage: Attempted to set property value on a null
> object.
> > > >> Property expression: name Value: New One
> > > >>
> > > >>    Root cause:
> > > >>
> > > >>    org.apache.wicket.WicketRuntimeException: Attempted to set
> > property
> > > >> value on a null object. Property expression: name Value: New
One
> > > >>    at
> > > >>
> >
>
org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.j
> > > >> ava:125)
> > > >>
> > > >> 4. Create a new record and then cancel the add, Choose an
> existing
> > > >> record to edit and the selected record is null (error message
> "You
> > must
> > > >> select a record to edit" is displayed).  Must close/open
session
> to
> > > >> reset.
> > > >>
> > > >> As always, all help is greatly appreciated as I am stumped.
> > > >>
> > > >> Thanks,
> > > >> Shelli
> > > >>
> > > >> -----Original Message-----
> > > >> From: jcgarciam [mailto:jcgarciam@gmail.com]
> > > >> Sent: Friday, October 08, 2010 1:41 PM
> > > >> To: users@wicket.apache.org
> > > >> Subject: Re: PropertyModel Not Refreshing
> > > >>
> > > >>
> > > >> The attachment didn't make it,
> > > >>
> > > >> Can you try to extract out the relevant part and creates a
> > quickstart
> > > >> project that actually reproduces your issue?
> > > >>
> > > >>
> > > >> On Fri, Oct 8, 2010 at 1:41 PM, Shelli Orton [via Apache
Wicket]
> <
> > > >>
> >
>
ml-node+2968688-305091622-65838@n4.nabble.com<ml-node%2B2968688-30509162
2-65838@n4.nabble.com>
> <ml-node%2B2968688-30509162
> 2-65838@n4.nabble.com>
> > <ml-node%2B2968688-30509162
> > 2-65838@n4.nabble.com>
> > > <ml-node%2B2968688-30509162
> > > >> 2-65838@n4.nabble.com>
> > > >>> wrote:
> > > >>
> > > >>> Hi,
> > > >>>
> > > >>> I have been trying different things to see if I could get my
> code
> > to
> > > >> work
> > > >>> (and understand Wicket models better), but am still stuck.  I
> have
> > a
> > > >>> attached the (latest) panel class code which I hope is
> sufficient
> > to
> > > >> help.
> > > >>>
> > > >>> I was reading about different models (both online and the
Wicket
> > in
> > > >> Action
> > > >>> book) and thought that perhaps using a CompoundPropertyModel
was
> > more
> > > >>> appropriate and may help with my issues.  Originally, I only
> > declared
> > > >>> selectedRecordA (line 40) but didn't instantiate it.  The
select
> > group
> > > >>> displayed properly but when I chose a record from the list and
> > tried
> > > >> to edit
> > > >>> it, this exception was thrown:
> > > >>>
> > > >>>     WicketMessage: Attempted to set property value on a null
> > object.
> > > >>> Property expression: recordA Value: Name=A-One
> > > >>>     Root cause:
> > > >>>
> > > >>>     org.apache.wicket.WicketRuntimeException: Attempted to set
> > > >> property
> > > >>> value on a null object. Property expression: recordA Value:
> > Name=A-One
> > > >>>         at
> > > >>>
> > > >>
> >
>
org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.j
> > > >> ava:125)
> > > >>>
> > > >>>         at
> > > >>>
> > > >>
> >
>
org.apache.wicket.model.AbstractPropertyModel.setObject(AbstractProperty
> > > >> Model.java:169)
> > > >>>
> > > >>>         at
> > > >>>
> >
org.apache.wicket.Component.setDefaultModelObject(Component.java:3125)
> > > >>>         ....
> > > >>>
> > > >>> I set breakpoints on the getSelectedRecordA and
> setSelectedRecordA
> > > >> methods,
> > > >>> but these aren't called when during the request cycle when the
> > edit
> > > >> button
> > > >>> is clicked.
> > > >>>
> > > >>> I then changed the class so that selectedRecordA is
initialized
> to
> > an
> > > >> empty
> > > >>> instance of RecordA. This got rid of the above error.
However,
> I
> > > >> cannot
> > > >>> save the edit changes because the selectedRecordA is still the
> > empty
> > > >>> instance that was created in the initialization and the
> > persistence
> > > >> layer
> > > >>> throws an exception.  This same problem exists if I try to add
a
> > new
> > > >> RecordA
> > > >>> or try to delete an existing one.
> > > >>>
> > > >>> If I choose to cancel the edit and then select another record
to
> > edit,
> > > >> I
> > > >>> get the message "You must select a record to edit" (line 131).
> > This
> > > >> is
> > > >>> because the cancel onSubmit sets selectedRecordA to null and
> > choosing
> > > >> the
> > > >>> record from the DDC is not setting it to the chosen record.
> > > >>>
> > > >>> Clearly I am not setting up this CompoundPropertyModel
properly
> so
> > > >> that the
> > > >>> selectedARecord is set by the model.  Can someone tell me what
> I'm
> > > >> doing
> > > >>> wrong?
> > > >>>
> > > >>> All help is greatly appreciated,
> > > >>>
> > > >>> Shelli
> > > >>>
> > > >>>
> > > >>> -----Original Message-----
> > > >>> From: Igor Vaynberg [mailto:[hidden
> > > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=0>]
> > > >>>
> > > >>> Sent: Thursday, October 07, 2010 11:27 AM
> > > >>> To: [hidden email]
> > > >> <http://user/SendEmail.jtp?type=node&node=2968688&i=1>
> > > >>> Subject: Re: PropertyModel Not Refreshing
> > > >>>
> > > >>> you have posted an incomplete piece of code and somehow from
> that
> > we
> > > >>> are supposed to guess what is not working? create a quickstart
> and
> > > >>> provide that.
> > > >>>
> > > >>> -igor
> > > >>>
> > > >>> On Thu, Oct 7, 2010 at 10:15 AM, Shelli Orton <[hidden
> > > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=2>>
> > > >>> wrote:
> > > >>>
> > > >>> > Does nobody have any suggestions?  If I can't get this
fixed,
> > I'm
> > > >> going
> > > >>> > to have to write the app in another framework (possibly GWT)
> and
> > I'd
> > > >>> > really rather not have to do that.
> > > >>> >
> > > >>> > Shelli
> > > >>> >
> > > >>> > -----Original Message-----
> > > >>> > From: Shelli Orton
> > > >>> > Sent: Wednesday, October 06, 2010 3:52 PM
> > > >>> > To: [hidden
> > > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=3>
> > > >>> > Subject: PropertyModel Not Refreshing
> > > >>> >
> > > >>> > Hi,
> > > >>> >
> > > >>> > First, thanks to all who have been helping me as I am new to
> > Wicket.
> > > >> I
> > > >>> > am splitting out two issues I am dealing with to try to keep
> > things
> > > >>> > clear.
> > > >>> >
> > > >>> > I am trying to write a simple app that does CRUD operations
on
> > > >> database
> > > >>> > records.  The goal is for the app to make use of a tab panel
> > where
> > > >> each
> > > >>> > tab encapsulates one table from the database.  Each tab
panel
> > has
> > > >> two
> > > >>> > groups (WebMarkupContainer).  The first, selectGroup,
displays
> a
> > > >> list
> > > >>> > (DDC) of the current items, and three buttons, add, edit and
> > delete.
> > > >>> > The second, editGroup, is displayed when either the add or
> edit
> > > >> button
> > > >>> > was clicked on the select group, displays the record
> attributes
> > and
> > > >> save
> > > >>> > and cancel buttons.  The tab panel has a "selectedRecord"
> which
> > is
> > > >> used
> > > >>> > by both groups' components via PropertyModels. Very basic
> stuff.
> > > >>> >
> > > >>> > When I choose a record and click the edit button, the record
> is
> > > >>> > displayed in the edit group properly.  If I then choose
> cancel,
> > the
> > > >> edit
> > > >>> > group is no longer displayed and the select group DDC
> selection
> > is
> > > >> null
> > > >>> > as expected. I then choose another record from the list and
> > click
> > > >> the
> > > >>> > edit button and the previous record information is displayed
> in
> > the
> > > >> edit
> > > >>> > group even though the select group DDC shows the
> > correct/selected
> > > >>> > record.
> > > >>> >
> > > >>> > This problem also occurs if I first choose to add a new
record
> > and
> > > >> then
> > > >>> > cancel the add and then choose to edit a different record.
> The
> > DDC
> > > >>> > shows the correct/selected record, but all the attributes in
> the
> > > >> edit
> > > >>> > group are null/defaults for a new record.
> > > >>> >
> > > >>> > If I remove the call to setDefaultFormProcessing(false) on
the
> > > >> cancel
> > > >>> > button, selecting other records for edit works correctly,
but
> I
> > > >> can't
> > > >>> > cancel a creating a new record if I use a RequiredTextField
> > because
> > > >> the
> > > >>> > form validation fails.
> > > >>> >
> > > >>> > If I select a record for editing or save the newly created
> > record, I
> > > >> can
> > > >>> > select a different record for edit or create another one
> > correctly.
> > > >> So
> > > >>> > I must be doing something wrong in the cancel logic. My
> editForm
> > > >>> > (created in the EditGroup constructor) looks like this:
> > > >>> >
> > > >>> >            Form editForm = new Form("editForm");
> > > >>> >
> > > >>> >            editForm.add(new Label("nameLabel", "Name"));
> > > >>> >
> > > >>> >            editForm.add(new Label("attributeLabel",
> > "Attribute"));
> > > >>> >
> > > >>> >            editForm.add(new
> > > >> RequiredTextField<String>("recordNameText",
> > > >>> >                    new
> PropertyModel<String>(MyRecordPanel.this,
> > > >>> >                            "selectedRecord.name")));
> > > >>> >
> > > >>> >            editForm.add(new
DropDownChoice<Lir>("attributes",
> > > >>> >                    new
> > PropertyModel<Attribute>(MyRecordPanel.this,
> > > >>> >                            "selectedRecord.attribute"),
> > > >>> >                    RateCentrePanel.this.getAttributes(),
> > > >>> >                    new AttributeRenderer()));
> > > >>> >
> > > >>> >            ....
> > > >>> >
> > > >>> >            editForm.add(new Button("cancel")
> > > >>> >            {
> > > >>> >                private static final long serialVersionUID =
> 1L;
> > > >>> >
> > > >>> >                public void onSubmit()
> > > >>> >                {
> > > >>> >                    MyRecordPanel.this.selectedRecord = null;
> > > >>> >                    editGroup.setVisible(false);
> > > >>> >                    selectGroup.setVisible(true);
> > > >>> >                }
> > > >>> >            }.setDefaultFormProcessing(false));
> > > >>> >
> > > >>> >            add(editForm);
> > > >>> >
> > > >>> > Other than setting the selectedRecord to null, what should I
> be
> > > >> doing
> > > >>> > differently?
> > > >>> >
> > > >>> > Thanks in advance!
> > > >>> >
> > > >>> > Shelli
> > > >>> >
> > > >>> >
> > > >>
> >
---------------------------------------------------------------------
> > > >>> > To unsubscribe, e-mail: [hidden
> > > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=4>
> > > >>> > For additional commands, e-mail: [hidden
> > > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=5>
> > > >>> >
> > > >>> >
> > > >>> >
> > > >>
> >
---------------------------------------------------------------------
> > > >>> > To unsubscribe, e-mail: [hidden
> > > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=6>
> > > >>> > For additional commands, e-mail: [hidden
> > > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=7>
> > > >>> >
> > > >>> >
> > > >>>
> >
---------------------------------------------------------------------
> > > >>> To unsubscribe, e-mail: [hidden
> > > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=8>
> > > >>> For additional commands, e-mail: [hidden
> > > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=9>
> > > >>>
> > > >>>
> > > >>>
> > > >>>
> > > >>>
> >
---------------------------------------------------------------------
> > > >>> To unsubscribe, e-mail: [hidden
> > > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=10>
> > > >>> For additional commands, e-mail: [hidden
> > > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=11>
> > > >>>
> > > >>> ------------------------------
> > > >>>  View message @
> > > >>>
> > > >>
> > >
> >
>
http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
> > > >> n-tp2955144p2968688.html
> > > >>> To start a new topic under Apache Wicket, email
> > > >>>
> > > >>
> >
>
ml-node+1842946-398011874-65838@n4.nabble.com<ml-node%2B1842946-39801187
4-65838@n4.nabble.com>
> <ml-node%2B1842946-39801187
> 4-65838@n4.nabble.com>
> > <ml-node%2B1842946-39801187
> > 4-65838@n4.nabble.com>
> > > <ml-node%2B1842946-39801187
> > > >> 4-65838@n4.nabble.com>
> > > >>> To unsubscribe from Apache Wicket, click
> > > >>
> >
>
here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp
> > > ?
> > > >>
> >
>
tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
> > > >> QyOTQ2fDEyNTYxMzc3ODY=>.
> > > >>>
> > > >>>
> > > >>>
> > > >>
> > > >>
> > > >> --
> > > >> Sincerely,
> > > >> JC (http://www.linkedin.com/in/jcgarciam)
> > > >> Work smarter, not harder!.
> > > >>
> > > >> --
> > > >> View this message in context:
> > > >>
> > >
> >
>
http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
> > > >> n-tp2955144p2968936.html
> > > >> Sent from the Users forum mailing list archive at Nabble.com.
> > > >>
> > > >>
> >
---------------------------------------------------------------------
> > > >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > > >> For additional commands, e-mail: users-help@wicket.apache.org
> > > >>
> > > >>
> > > >>
> > > >>
> >
---------------------------------------------------------------------
> > > >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > > >> For additional commands, e-mail: users-help@wicket.apache.org
> > > >>
> > > >
> > > >
> >
---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > > > For additional commands, e-mail: users-help@wicket.apache.org
> > > >
> > > >
> > > >
> >
---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > > > For additional commands, e-mail: users-help@wicket.apache.org
> > > >
> > > >
> > >
> > >
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > > For additional commands, e-mail: users-help@wicket.apache.org
> > >
> > >
> > >
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > > For additional commands, e-mail: users-help@wicket.apache.org
> > >
> > >
> >
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: PropertyModel Not Refreshing

Posted by nino martinez wael <ni...@gmail.com>.
I can confirm the edit issue.. Also what's supposed to happen in recordb
panel?

I might have a chance to look at it a little later..

2010/10/12 Shelli Orton <Sh...@sjrb.ca>

> He provided an updated RecordAPanel.java class that works on his system.
> I updated mine to match his, but still have an issue where once a record
> has been selected for edit, that's the only record that is displayed in
> the edit group regardless of which record is chosen from the list in the
> select group or if I choose to create a new record.
>
> If it's not the code, I was thinking that it might be the app server
> doing some caching, but honestly, I'm grasping at straws.
>
> Shelli
>
> -----Original Message-----
> From: nino martinez wael [mailto:nino.martinez.wael@gmail.com]
> Sent: Tuesday, October 12, 2010 11:58 AM
> To: users@wicket.apache.org
> Subject: Re: PropertyModel Not Refreshing
>
> sorry.. Did'nt see it attached.. So did igor provide you with an fixed
> quickstart (working on his system).. That did not work on glassfish?
>
> 2010/10/12 Shelli Orton <Sh...@sjrb.ca>
>
> > The quickstart was sent to the list this morning at 10:04 MST.  Does
> it
> > need to be resent?
> >
> > Shelli
> >
> > -----Original Message-----
> > From: nino martinez wael [mailto:nino.martinez.wael@gmail.com]
> > Sent: Tuesday, October 12, 2010 11:52 AM
> > To: users@wicket.apache.org
> > Subject: Re: PropertyModel Not Refreshing
> >
> > No dont think so.. Please provide a quickstart.. I have had property
> > models
> > working in 1.2, 1.3, 1.4 and 1.5 so must be error 42:)
> >
> > 2010/10/12 Shelli Orton <Sh...@sjrb.ca>
> >
> > > Hi,
> > >
> > > Thanks for file.  Your first email was missing these changes:
> > >
> > >    IModel<RecordA> selectedRecordAModel;  (I had set mine to
> > > PropertyModel<RecordA> selectedRecordAModel;)
> > >    recordAs.setModel(selectedRecordAModel)
> > >
> > > However, even with those changes applied, I still get the same issue
> > of the
> > > selected record not updating in the edit group.
> > >
> > > I am deploying in Glassfish v3.  Could that have anything to do with
> > my
> > > problems?
> > >
> > > Shelli
> > >
> > > -----Original Message-----
> > > From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
> > > Sent: Tuesday, October 12, 2010 11:35 AM
> > > To: users@wicket.apache.org
> > > Subject: Re: PropertyModel Not Refreshing
> > >
> > > On Tue, Oct 12, 2010 at 10:30 AM, Shelli Orton
> <Sh...@sjrb.ca>
> > > wrote:
> > > > Thanks for the help.  Your changes got rid of the errors and I can
> > delete
> > > records now (and the list is updated).
> > > >
> > > > However, once a record has been selected for edit and either saved
> > or
> > > cancelled, that same record is always displayed in the edit group
> when
> > I
> > > choose another record to edit or even when I try to create a new
> one.
> > I can
> > > even delete the chosen record and it still displays in the edit
> group.
> > >
> > > works fine here, meaning you did not completely/propery apply my
> > > changes. below is the complete file.
> > >
> > > -igor
> > >
> > > public class RecordAPanel extends Panel
> > > {
> > >    private static final long serialVersionUID = 1L;
> > >
> > >    RecordAService recordAService;
> > >    RecordBService recordBService;
> > >
> > >    RecordA selectedRecordA = new RecordA();
> > >    IModel<RecordA> selectedRecordAModel;
> > >    String unmodifiedRecordA;
> > >
> > >    boolean isNew = false;
> > >
> > >    WebMarkupContainer selectGroup;
> > >    WebMarkupContainer editGroup;
> > >
> > >    Form selectForm;
> > >    Form editForm;
> > >
> > >    DropDownChoice<RecordA> recordAs;
> > >    DropDownChoice<RecordB> recordBs;
> > >
> > >    Button add;
> > >    Button edit;
> > >    Button save;
> > >    Button delete;
> > >    Button cancel;
> > >
> > >    Label editLegendLabel;
> > >    String editLegend;
> > >    Label recordALabel;
> > >    Label recordBLabel;
> > >
> > >    RequiredTextField recordAText;
> > >
> > >    @SuppressWarnings({ "rawtypes", "unchecked" })
> > >    public RecordAPanel(String id)
> > >    {
> > >        super(id);
> > >
> > >        recordAService = ((Application)
> > > RequestCycle.get().getApplication()).getRecordAService();
> > >        recordBService = ((Application)
> > > RequestCycle.get().getApplication()).getRecordBService();
> > >
> > >        selectedRecordAModel = new PropertyModel<RecordA>(this,
> > > "selectedRecordA");
> > >        this.setDefaultModel(selectedRecordAModel);
> > >
> > >        // ************* Select  Group *************
> > >
> > >        selectGroup = new WebMarkupContainer("selectGroup");
> > >        selectForm = new Form("selectForm");
> > >
> > >        recordAs = new DropDownChoice<RecordA>("recordAs");
> > >        recordAs.setModel(selectedRecordAModel);
> > >        recordAs.setChoices(recordAsModel);
> > >        recordAs.setChoiceRenderer(new RecordARenderer());
> > >
> > >        //            recordAs = (DropDownChoice<RecordA>) new
> > > DropDownChoice<RecordA>("recordAs",
> > >        //                    new PropertyModel<RecordA>(this,
> > > "selectedRecordA"),
> > >        //                    recordAsModel,
> > >        //                    new RecordARenderer());
> > >
> > >        recordAs.setNullValid(false);
> > >
> > >        selectForm.add(recordAs);
> > >
> > >        add = new Button("add")
> > >        {
> > >            private static final long serialVersionUID = 1L;
> > >
> > >            public void onSubmit()
> > >            {
> > >                setSelectedRecordA(new RecordA());
> > >                isNew = true;
> > >                editLegend = "New";
> > >                editGroup.setVisible(true);
> > >                selectGroup.setVisible(false);
> > >            }
> > >        };
> > >
> > >        selectForm.add(add);
> > >
> > >        edit = new Button("edit")
> > >        {
> > >            private static final long serialVersionUID = 1L;
> > >
> > >            public void onSubmit()
> > >            {
> > >                if (selectedRecordA == null)
> > >                {
> > >                    info("You must select a record to edit.");
> > >                }
> > >                else
> > >                {
> > >                    unmodifiedRecordA = selectedRecordA.getName();
> > >                    isNew = false;
> > >                    editLegend = "Edit";
> > >                    editGroup.setVisible(true);
> > >                    selectGroup.setVisible(false);
> > >                }
> > >            }
> > >        };
> > >
> > >        selectForm.add(edit);
> > >
> > >        delete = new Button("delete")
> > >        {
> > >            private static final long serialVersionUID = 1L;
> > >
> > >            public void onSubmit()
> > >            {
> > >                if (selectedRecordA == null)
> > >                {
> > >                    info("You must select a record to delete.");
> > >                }
> > >                else
> > >                {
> > >                    // Delete the selected record
> > >                    unmodifiedRecordA = selectedRecordA.getName();
> > >                    recordAService.delete(selectedRecordA.getName());
> > >                    selectedRecordA = null;
> > >                    info("Deleted '" + unmodifiedRecordA + "'");
> > >
> > >                    // Force refresh of records list
> > >                    RecordAPanel.this.recordAsModel.detach();
> > >                }
> > >            }
> > >        };
> > >
> > >        // Add confirmation dialog box
> > >        delete.add(new SimpleAttributeModifier("onclick",
> > >                "if (!confirm('Please confirm you want to delete this
> > > record') ){ return false; }"));
> > >
> > >        selectForm.add(delete);
> > >        selectGroup.add(selectForm);
> > >
> > >        this.add(selectGroup);
> > >
> > >        // ************* Edit Group *************
> > >
> > >        editGroup = new WebMarkupContainer("editGroup");
> > >
> > >        editLegendLabel = new Label("editLegend", new
> > PropertyModel(this,
> > >                "editLegend"));
> > >
> > >        editGroup.add(editLegendLabel);
> > >
> > >        editForm = new Form("editForm");
> > >
> > >        recordALabel = new Label("recordALabel", "Record A");
> > >        editForm.add(recordALabel);
> > >
> > >        recordBLabel = new Label("recordBLabel", "Record B");
> > >        editForm.add(recordBLabel);
> > >
> > >        recordAText = new RequiredTextField("recordAText",
> > >                new PropertyModel(selectedRecordAModel, "name"));
> > >
> > >        editForm.add(recordAText);
> > >
> > >        recordBs = new DropDownChoice<RecordB>("recordBs");
> > >        recordBs.setModel(new PropertyModel(selectedRecordAModel,
> > > "recordB"));
> > >        recordBs.setChoices(RecordAPanel.this.getRecordBs());
> > >        recordBs.setChoiceRenderer(new RecordBRenderer());
> > >
> > >        editForm.add(recordBs);
> > >
> > >        save = new Button("save")
> > >        {
> > >            private static final long serialVersionUID = 1L;
> > >
> > >            @Override
> > >            public void onSubmit()
> > >            {
> > >                if (isNew)
> > >                {
> > >
> > > recordAService.create(RecordAPanel.this.selectedRecordA);
> > >                        info("Created '"
> > >                                +
> > > RecordAPanel.this.selectedRecordA.getName()
> > >                                + "'");
> > >                }
> > >                else
> > >                {
> > >                        recordAService.update(unmodifiedRecordA,
> > >                                RecordAPanel.this.selectedRecordA);
> > >                        info("Updated '"
> > >                                +
> > > RecordAPanel.this.selectedRecordA.getName()
> > >                                + "'");
> > >                }
> > >
> > >                // TODO Update the dropdown list?
> > >
> > >                editGroup.setVisible(false);
> > >                selectGroup.setVisible(true);
> > >            }
> > >        };
> > >
> > >        editForm.add(save);
> > >
> > >        cancel = new Button("cancel")
> > >        {
> > >            private static final long serialVersionUID = 1L;
> > >
> > >            public void onSubmit()
> > >            {
> > >                RecordAPanel.this.selectedRecordA = null;
> > >                editGroup.setVisible(false);
> > >                selectGroup.setVisible(true);
> > >            }
> > >        };
> > >
> > >        cancel.setDefaultFormProcessing(false);
> > >        editForm.add(cancel);
> > >
> > >        editGroup.add(editForm);
> > >
> > >        editGroup.setVisible(false);
> > >        this.add(editGroup);
> > >    }
> > >
> > >    public RecordA getSelectedRecordA()
> > >    {
> > >        return selectedRecordA;
> > >    }
> > >
> > >    public void setSelectedRecordA(RecordA selectedRecordA)
> > >    {
> > >        this.selectedRecordA = selectedRecordA;
> > >    }
> > >
> > >    public LoadableDetachableModel<List<RecordA>> recordAsModel = new
> > > LoadableDetachableModel<List<RecordA>>()
> > >    {
> > >        private static final long serialVersionUID = 1L;
> > >
> > >        @Override
> > >        protected List<RecordA> load()
> > >        {
> > >            return recordAService.getList();
> > >        }
> > >
> > >        public void detach()
> > >        {
> > >            super.detach();
> > >        }
> > >    };
> > >
> > >    // TODO change this to LDM?
> > >    List<RecordB> getRecordBs()
> > >    {
> > >        return recordBService.getList();
> > >    }
> > >
> > >    class RecordARenderer implements IChoiceRenderer<RecordA>
> > >    {
> > >        private static final long serialVersionUID = 1L;
> > >
> > >        public Object getDisplayValue(RecordA recordA)
> > >        {
> > >            return recordA.getName();
> > >        }
> > >
> > >        public String getIdValue(RecordA recordA, int index)
> > >        {
> > >            return recordA.getName();
> > >        }
> > >    }
> > >
> > >    class RecordBRenderer implements IChoiceRenderer<RecordB>
> > >    {
> > >        private static final long serialVersionUID = 1L;
> > >
> > >        public Object getDisplayValue(RecordB recordB)
> > >        {
> > >            return recordB.getName();
> > >        }
> > >
> > >        public String getIdValue(RecordB recordB, int index)
> > >        {
> > >            return recordB.getName();
> > >        }
> > >    }
> > > }
> > >
> > > >
> > > > Shelli
> > > >
> > > > -----Original Message-----
> > > > From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
> > > > Sent: Tuesday, October 12, 2010 10:38 AM
> > > > To: users@wicket.apache.org
> > > > Subject: Re: PropertyModel Not Refreshing
> > > >
> > > > here are the tweaks you need to make this work:
> > > >
> > > > selectedRecordAModel = new PropertyModel<RecordA>(this,
> > > "selectedRecordA");
> > > >
> > > > recordAText = new RequiredTextField("recordAText",
> > > >                new PropertyModel(selectedRecordAModel, "name"));
> > > >
> > > >  recordBs.setModel(new PropertyModel(selectedRecordAModel,
> > "recordB"));
> > > >
> > > > have fun
> > > >
> > > > -igor
> > > >
> > > > On Tue, Oct 12, 2010 at 9:03 AM, Shelli Orton
> <Sh...@sjrb.ca>
> > > wrote:
> > > >> I've been able to create a sample application that exhibits the
> > > >> same/similar problems to mine.  The sample makes use of an
> > in-memory
> > > >> list for the data versus accessing a database and so there's some
> > > >> differences.  However, I believe the problems that this sample
> > exhibits
> > > >> have the same root cause as my project (which I believe have
> > something
> > > >> to do with how my models are set up...).
> > > >>
> > > >> Issues this sample exhibits:
> > > >>
> > > >> 1. Choose to edit an existing record, then cancel the edit.
> Choose
> > > >> another/the same record to edit and the selected record is null
> > (error
> > > >> message "You must select a record to edit" is displayed).  Must
> > > >> close/open session to reset.
> > > >>
> > > >> 2. Choose to edit an existing record and save the edit.  Choose
> > > >> another/the same record to edit and you get a NPE:
> > > >>
> > > >>    WicketMessage: Method onFormSubmitted of interface
> > > >> org.apache.wicket.markup.html.form.IFormSubmitListener targeted
> at
> > > >> component [MarkupContainer [Component id = selectForm]] threw an
> > > >> exception
> > > >>
> > > >>    Root cause:
> > > >>
> > > >>    java.lang.NullPointerException
> > > >>    at
> > > >>
> >
> org.apache.wicket.markup.html.form.AbstractSingleSelectChoice.convertCho
> > > >> iceIdToChoice(AbstractSingleSelectChoice.java:247)
> > > >>
> > > >> 3. Create a new record and try to save it and get
> > > >> WicketRuntimeException:
> > > >>
> > > >>    WicketMessage: Attempted to set property value on a null
> object.
> > > >> Property expression: name Value: New One
> > > >>
> > > >>    Root cause:
> > > >>
> > > >>    org.apache.wicket.WicketRuntimeException: Attempted to set
> > property
> > > >> value on a null object. Property expression: name Value: New One
> > > >>    at
> > > >>
> >
> org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.j
> > > >> ava:125)
> > > >>
> > > >> 4. Create a new record and then cancel the add, Choose an
> existing
> > > >> record to edit and the selected record is null (error message
> "You
> > must
> > > >> select a record to edit" is displayed).  Must close/open session
> to
> > > >> reset.
> > > >>
> > > >> As always, all help is greatly appreciated as I am stumped.
> > > >>
> > > >> Thanks,
> > > >> Shelli
> > > >>
> > > >> -----Original Message-----
> > > >> From: jcgarciam [mailto:jcgarciam@gmail.com]
> > > >> Sent: Friday, October 08, 2010 1:41 PM
> > > >> To: users@wicket.apache.org
> > > >> Subject: Re: PropertyModel Not Refreshing
> > > >>
> > > >>
> > > >> The attachment didn't make it,
> > > >>
> > > >> Can you try to extract out the relevant part and creates a
> > quickstart
> > > >> project that actually reproduces your issue?
> > > >>
> > > >>
> > > >> On Fri, Oct 8, 2010 at 1:41 PM, Shelli Orton [via Apache Wicket]
> <
> > > >>
> >
> ml-node+2968688-305091622-65838@n4.nabble.com<ml...@n4.nabble.com>
> <ml-node%2B2968688-30509162
> 2-65838@n4.nabble.com>
> > <ml-node%2B2968688-30509162
> > 2-65838@n4.nabble.com>
> > > <ml-node%2B2968688-30509162
> > > >> 2-65838@n4.nabble.com>
> > > >>> wrote:
> > > >>
> > > >>> Hi,
> > > >>>
> > > >>> I have been trying different things to see if I could get my
> code
> > to
> > > >> work
> > > >>> (and understand Wicket models better), but am still stuck.  I
> have
> > a
> > > >>> attached the (latest) panel class code which I hope is
> sufficient
> > to
> > > >> help.
> > > >>>
> > > >>> I was reading about different models (both online and the Wicket
> > in
> > > >> Action
> > > >>> book) and thought that perhaps using a CompoundPropertyModel was
> > more
> > > >>> appropriate and may help with my issues.  Originally, I only
> > declared
> > > >>> selectedRecordA (line 40) but didn't instantiate it.  The select
> > group
> > > >>> displayed properly but when I chose a record from the list and
> > tried
> > > >> to edit
> > > >>> it, this exception was thrown:
> > > >>>
> > > >>>     WicketMessage: Attempted to set property value on a null
> > object.
> > > >>> Property expression: recordA Value: Name=A-One
> > > >>>     Root cause:
> > > >>>
> > > >>>     org.apache.wicket.WicketRuntimeException: Attempted to set
> > > >> property
> > > >>> value on a null object. Property expression: recordA Value:
> > Name=A-One
> > > >>>         at
> > > >>>
> > > >>
> >
> org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.j
> > > >> ava:125)
> > > >>>
> > > >>>         at
> > > >>>
> > > >>
> >
> org.apache.wicket.model.AbstractPropertyModel.setObject(AbstractProperty
> > > >> Model.java:169)
> > > >>>
> > > >>>         at
> > > >>>
> > org.apache.wicket.Component.setDefaultModelObject(Component.java:3125)
> > > >>>         ....
> > > >>>
> > > >>> I set breakpoints on the getSelectedRecordA and
> setSelectedRecordA
> > > >> methods,
> > > >>> but these aren't called when during the request cycle when the
> > edit
> > > >> button
> > > >>> is clicked.
> > > >>>
> > > >>> I then changed the class so that selectedRecordA is initialized
> to
> > an
> > > >> empty
> > > >>> instance of RecordA. This got rid of the above error.  However,
> I
> > > >> cannot
> > > >>> save the edit changes because the selectedRecordA is still the
> > empty
> > > >>> instance that was created in the initialization and the
> > persistence
> > > >> layer
> > > >>> throws an exception.  This same problem exists if I try to add a
> > new
> > > >> RecordA
> > > >>> or try to delete an existing one.
> > > >>>
> > > >>> If I choose to cancel the edit and then select another record to
> > edit,
> > > >> I
> > > >>> get the message "You must select a record to edit" (line 131).
> > This
> > > >> is
> > > >>> because the cancel onSubmit sets selectedRecordA to null and
> > choosing
> > > >> the
> > > >>> record from the DDC is not setting it to the chosen record.
> > > >>>
> > > >>> Clearly I am not setting up this CompoundPropertyModel properly
> so
> > > >> that the
> > > >>> selectedARecord is set by the model.  Can someone tell me what
> I'm
> > > >> doing
> > > >>> wrong?
> > > >>>
> > > >>> All help is greatly appreciated,
> > > >>>
> > > >>> Shelli
> > > >>>
> > > >>>
> > > >>> -----Original Message-----
> > > >>> From: Igor Vaynberg [mailto:[hidden
> > > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=0>]
> > > >>>
> > > >>> Sent: Thursday, October 07, 2010 11:27 AM
> > > >>> To: [hidden email]
> > > >> <http://user/SendEmail.jtp?type=node&node=2968688&i=1>
> > > >>> Subject: Re: PropertyModel Not Refreshing
> > > >>>
> > > >>> you have posted an incomplete piece of code and somehow from
> that
> > we
> > > >>> are supposed to guess what is not working? create a quickstart
> and
> > > >>> provide that.
> > > >>>
> > > >>> -igor
> > > >>>
> > > >>> On Thu, Oct 7, 2010 at 10:15 AM, Shelli Orton <[hidden
> > > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=2>>
> > > >>> wrote:
> > > >>>
> > > >>> > Does nobody have any suggestions?  If I can't get this fixed,
> > I'm
> > > >> going
> > > >>> > to have to write the app in another framework (possibly GWT)
> and
> > I'd
> > > >>> > really rather not have to do that.
> > > >>> >
> > > >>> > Shelli
> > > >>> >
> > > >>> > -----Original Message-----
> > > >>> > From: Shelli Orton
> > > >>> > Sent: Wednesday, October 06, 2010 3:52 PM
> > > >>> > To: [hidden
> > > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=3>
> > > >>> > Subject: PropertyModel Not Refreshing
> > > >>> >
> > > >>> > Hi,
> > > >>> >
> > > >>> > First, thanks to all who have been helping me as I am new to
> > Wicket.
> > > >> I
> > > >>> > am splitting out two issues I am dealing with to try to keep
> > things
> > > >>> > clear.
> > > >>> >
> > > >>> > I am trying to write a simple app that does CRUD operations on
> > > >> database
> > > >>> > records.  The goal is for the app to make use of a tab panel
> > where
> > > >> each
> > > >>> > tab encapsulates one table from the database.  Each tab panel
> > has
> > > >> two
> > > >>> > groups (WebMarkupContainer).  The first, selectGroup, displays
> a
> > > >> list
> > > >>> > (DDC) of the current items, and three buttons, add, edit and
> > delete.
> > > >>> > The second, editGroup, is displayed when either the add or
> edit
> > > >> button
> > > >>> > was clicked on the select group, displays the record
> attributes
> > and
> > > >> save
> > > >>> > and cancel buttons.  The tab panel has a "selectedRecord"
> which
> > is
> > > >> used
> > > >>> > by both groups' components via PropertyModels. Very basic
> stuff.
> > > >>> >
> > > >>> > When I choose a record and click the edit button, the record
> is
> > > >>> > displayed in the edit group properly.  If I then choose
> cancel,
> > the
> > > >> edit
> > > >>> > group is no longer displayed and the select group DDC
> selection
> > is
> > > >> null
> > > >>> > as expected. I then choose another record from the list and
> > click
> > > >> the
> > > >>> > edit button and the previous record information is displayed
> in
> > the
> > > >> edit
> > > >>> > group even though the select group DDC shows the
> > correct/selected
> > > >>> > record.
> > > >>> >
> > > >>> > This problem also occurs if I first choose to add a new record
> > and
> > > >> then
> > > >>> > cancel the add and then choose to edit a different record.
> The
> > DDC
> > > >>> > shows the correct/selected record, but all the attributes in
> the
> > > >> edit
> > > >>> > group are null/defaults for a new record.
> > > >>> >
> > > >>> > If I remove the call to setDefaultFormProcessing(false) on the
> > > >> cancel
> > > >>> > button, selecting other records for edit works correctly, but
> I
> > > >> can't
> > > >>> > cancel a creating a new record if I use a RequiredTextField
> > because
> > > >> the
> > > >>> > form validation fails.
> > > >>> >
> > > >>> > If I select a record for editing or save the newly created
> > record, I
> > > >> can
> > > >>> > select a different record for edit or create another one
> > correctly.
> > > >> So
> > > >>> > I must be doing something wrong in the cancel logic. My
> editForm
> > > >>> > (created in the EditGroup constructor) looks like this:
> > > >>> >
> > > >>> >            Form editForm = new Form("editForm");
> > > >>> >
> > > >>> >            editForm.add(new Label("nameLabel", "Name"));
> > > >>> >
> > > >>> >            editForm.add(new Label("attributeLabel",
> > "Attribute"));
> > > >>> >
> > > >>> >            editForm.add(new
> > > >> RequiredTextField<String>("recordNameText",
> > > >>> >                    new
> PropertyModel<String>(MyRecordPanel.this,
> > > >>> >                            "selectedRecord.name")));
> > > >>> >
> > > >>> >            editForm.add(new DropDownChoice<Lir>("attributes",
> > > >>> >                    new
> > PropertyModel<Attribute>(MyRecordPanel.this,
> > > >>> >                            "selectedRecord.attribute"),
> > > >>> >                    RateCentrePanel.this.getAttributes(),
> > > >>> >                    new AttributeRenderer()));
> > > >>> >
> > > >>> >            ....
> > > >>> >
> > > >>> >            editForm.add(new Button("cancel")
> > > >>> >            {
> > > >>> >                private static final long serialVersionUID =
> 1L;
> > > >>> >
> > > >>> >                public void onSubmit()
> > > >>> >                {
> > > >>> >                    MyRecordPanel.this.selectedRecord = null;
> > > >>> >                    editGroup.setVisible(false);
> > > >>> >                    selectGroup.setVisible(true);
> > > >>> >                }
> > > >>> >            }.setDefaultFormProcessing(false));
> > > >>> >
> > > >>> >            add(editForm);
> > > >>> >
> > > >>> > Other than setting the selectedRecord to null, what should I
> be
> > > >> doing
> > > >>> > differently?
> > > >>> >
> > > >>> > Thanks in advance!
> > > >>> >
> > > >>> > Shelli
> > > >>> >
> > > >>> >
> > > >>
> > ---------------------------------------------------------------------
> > > >>> > To unsubscribe, e-mail: [hidden
> > > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=4>
> > > >>> > For additional commands, e-mail: [hidden
> > > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=5>
> > > >>> >
> > > >>> >
> > > >>> >
> > > >>
> > ---------------------------------------------------------------------
> > > >>> > To unsubscribe, e-mail: [hidden
> > > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=6>
> > > >>> > For additional commands, e-mail: [hidden
> > > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=7>
> > > >>> >
> > > >>> >
> > > >>>
> > ---------------------------------------------------------------------
> > > >>> To unsubscribe, e-mail: [hidden
> > > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=8>
> > > >>> For additional commands, e-mail: [hidden
> > > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=9>
> > > >>>
> > > >>>
> > > >>>
> > > >>>
> > > >>>
> > ---------------------------------------------------------------------
> > > >>> To unsubscribe, e-mail: [hidden
> > > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=10>
> > > >>> For additional commands, e-mail: [hidden
> > > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=11>
> > > >>>
> > > >>> ------------------------------
> > > >>>  View message @
> > > >>>
> > > >>
> > >
> >
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
> > > >> n-tp2955144p2968688.html
> > > >>> To start a new topic under Apache Wicket, email
> > > >>>
> > > >>
> >
> ml-node+1842946-398011874-65838@n4.nabble.com<ml...@n4.nabble.com>
> <ml-node%2B1842946-39801187
> 4-65838@n4.nabble.com>
> > <ml-node%2B1842946-39801187
> > 4-65838@n4.nabble.com>
> > > <ml-node%2B1842946-39801187
> > > >> 4-65838@n4.nabble.com>
> > > >>> To unsubscribe from Apache Wicket, click
> > > >>
> >
> here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp
> > > ?
> > > >>
> >
> tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
> > > >> QyOTQ2fDEyNTYxMzc3ODY=>.
> > > >>>
> > > >>>
> > > >>>
> > > >>
> > > >>
> > > >> --
> > > >> Sincerely,
> > > >> JC (http://www.linkedin.com/in/jcgarciam)
> > > >> Work smarter, not harder!.
> > > >>
> > > >> --
> > > >> View this message in context:
> > > >>
> > >
> >
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
> > > >> n-tp2955144p2968936.html
> > > >> Sent from the Users forum mailing list archive at Nabble.com.
> > > >>
> > > >>
> > ---------------------------------------------------------------------
> > > >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > > >> For additional commands, e-mail: users-help@wicket.apache.org
> > > >>
> > > >>
> > > >>
> > > >>
> > ---------------------------------------------------------------------
> > > >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > > >> For additional commands, e-mail: users-help@wicket.apache.org
> > > >>
> > > >
> > > >
> > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > > > For additional commands, e-mail: users-help@wicket.apache.org
> > > >
> > > >
> > > >
> > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > > > For additional commands, e-mail: users-help@wicket.apache.org
> > > >
> > > >
> > >
> > >
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > > For additional commands, e-mail: users-help@wicket.apache.org
> > >
> > >
> > >
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > > For additional commands, e-mail: users-help@wicket.apache.org
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

RE: PropertyModel Not Refreshing

Posted by Shelli Orton <Sh...@sjrb.ca>.
He provided an updated RecordAPanel.java class that works on his system.
I updated mine to match his, but still have an issue where once a record
has been selected for edit, that's the only record that is displayed in
the edit group regardless of which record is chosen from the list in the
select group or if I choose to create a new record.

If it's not the code, I was thinking that it might be the app server
doing some caching, but honestly, I'm grasping at straws.

Shelli

-----Original Message-----
From: nino martinez wael [mailto:nino.martinez.wael@gmail.com] 
Sent: Tuesday, October 12, 2010 11:58 AM
To: users@wicket.apache.org
Subject: Re: PropertyModel Not Refreshing

sorry.. Did'nt see it attached.. So did igor provide you with an fixed
quickstart (working on his system).. That did not work on glassfish?

2010/10/12 Shelli Orton <Sh...@sjrb.ca>

> The quickstart was sent to the list this morning at 10:04 MST.  Does
it
> need to be resent?
>
> Shelli
>
> -----Original Message-----
> From: nino martinez wael [mailto:nino.martinez.wael@gmail.com]
> Sent: Tuesday, October 12, 2010 11:52 AM
> To: users@wicket.apache.org
> Subject: Re: PropertyModel Not Refreshing
>
> No dont think so.. Please provide a quickstart.. I have had property
> models
> working in 1.2, 1.3, 1.4 and 1.5 so must be error 42:)
>
> 2010/10/12 Shelli Orton <Sh...@sjrb.ca>
>
> > Hi,
> >
> > Thanks for file.  Your first email was missing these changes:
> >
> >    IModel<RecordA> selectedRecordAModel;  (I had set mine to
> > PropertyModel<RecordA> selectedRecordAModel;)
> >    recordAs.setModel(selectedRecordAModel)
> >
> > However, even with those changes applied, I still get the same issue
> of the
> > selected record not updating in the edit group.
> >
> > I am deploying in Glassfish v3.  Could that have anything to do with
> my
> > problems?
> >
> > Shelli
> >
> > -----Original Message-----
> > From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
> > Sent: Tuesday, October 12, 2010 11:35 AM
> > To: users@wicket.apache.org
> > Subject: Re: PropertyModel Not Refreshing
> >
> > On Tue, Oct 12, 2010 at 10:30 AM, Shelli Orton
<Sh...@sjrb.ca>
> > wrote:
> > > Thanks for the help.  Your changes got rid of the errors and I can
> delete
> > records now (and the list is updated).
> > >
> > > However, once a record has been selected for edit and either saved
> or
> > cancelled, that same record is always displayed in the edit group
when
> I
> > choose another record to edit or even when I try to create a new
one.
> I can
> > even delete the chosen record and it still displays in the edit
group.
> >
> > works fine here, meaning you did not completely/propery apply my
> > changes. below is the complete file.
> >
> > -igor
> >
> > public class RecordAPanel extends Panel
> > {
> >    private static final long serialVersionUID = 1L;
> >
> >    RecordAService recordAService;
> >    RecordBService recordBService;
> >
> >    RecordA selectedRecordA = new RecordA();
> >    IModel<RecordA> selectedRecordAModel;
> >    String unmodifiedRecordA;
> >
> >    boolean isNew = false;
> >
> >    WebMarkupContainer selectGroup;
> >    WebMarkupContainer editGroup;
> >
> >    Form selectForm;
> >    Form editForm;
> >
> >    DropDownChoice<RecordA> recordAs;
> >    DropDownChoice<RecordB> recordBs;
> >
> >    Button add;
> >    Button edit;
> >    Button save;
> >    Button delete;
> >    Button cancel;
> >
> >    Label editLegendLabel;
> >    String editLegend;
> >    Label recordALabel;
> >    Label recordBLabel;
> >
> >    RequiredTextField recordAText;
> >
> >    @SuppressWarnings({ "rawtypes", "unchecked" })
> >    public RecordAPanel(String id)
> >    {
> >        super(id);
> >
> >        recordAService = ((Application)
> > RequestCycle.get().getApplication()).getRecordAService();
> >        recordBService = ((Application)
> > RequestCycle.get().getApplication()).getRecordBService();
> >
> >        selectedRecordAModel = new PropertyModel<RecordA>(this,
> > "selectedRecordA");
> >        this.setDefaultModel(selectedRecordAModel);
> >
> >        // ************* Select  Group *************
> >
> >        selectGroup = new WebMarkupContainer("selectGroup");
> >        selectForm = new Form("selectForm");
> >
> >        recordAs = new DropDownChoice<RecordA>("recordAs");
> >        recordAs.setModel(selectedRecordAModel);
> >        recordAs.setChoices(recordAsModel);
> >        recordAs.setChoiceRenderer(new RecordARenderer());
> >
> >        //            recordAs = (DropDownChoice<RecordA>) new
> > DropDownChoice<RecordA>("recordAs",
> >        //                    new PropertyModel<RecordA>(this,
> > "selectedRecordA"),
> >        //                    recordAsModel,
> >        //                    new RecordARenderer());
> >
> >        recordAs.setNullValid(false);
> >
> >        selectForm.add(recordAs);
> >
> >        add = new Button("add")
> >        {
> >            private static final long serialVersionUID = 1L;
> >
> >            public void onSubmit()
> >            {
> >                setSelectedRecordA(new RecordA());
> >                isNew = true;
> >                editLegend = "New";
> >                editGroup.setVisible(true);
> >                selectGroup.setVisible(false);
> >            }
> >        };
> >
> >        selectForm.add(add);
> >
> >        edit = new Button("edit")
> >        {
> >            private static final long serialVersionUID = 1L;
> >
> >            public void onSubmit()
> >            {
> >                if (selectedRecordA == null)
> >                {
> >                    info("You must select a record to edit.");
> >                }
> >                else
> >                {
> >                    unmodifiedRecordA = selectedRecordA.getName();
> >                    isNew = false;
> >                    editLegend = "Edit";
> >                    editGroup.setVisible(true);
> >                    selectGroup.setVisible(false);
> >                }
> >            }
> >        };
> >
> >        selectForm.add(edit);
> >
> >        delete = new Button("delete")
> >        {
> >            private static final long serialVersionUID = 1L;
> >
> >            public void onSubmit()
> >            {
> >                if (selectedRecordA == null)
> >                {
> >                    info("You must select a record to delete.");
> >                }
> >                else
> >                {
> >                    // Delete the selected record
> >                    unmodifiedRecordA = selectedRecordA.getName();
> >                    recordAService.delete(selectedRecordA.getName());
> >                    selectedRecordA = null;
> >                    info("Deleted '" + unmodifiedRecordA + "'");
> >
> >                    // Force refresh of records list
> >                    RecordAPanel.this.recordAsModel.detach();
> >                }
> >            }
> >        };
> >
> >        // Add confirmation dialog box
> >        delete.add(new SimpleAttributeModifier("onclick",
> >                "if (!confirm('Please confirm you want to delete this
> > record') ){ return false; }"));
> >
> >        selectForm.add(delete);
> >        selectGroup.add(selectForm);
> >
> >        this.add(selectGroup);
> >
> >        // ************* Edit Group *************
> >
> >        editGroup = new WebMarkupContainer("editGroup");
> >
> >        editLegendLabel = new Label("editLegend", new
> PropertyModel(this,
> >                "editLegend"));
> >
> >        editGroup.add(editLegendLabel);
> >
> >        editForm = new Form("editForm");
> >
> >        recordALabel = new Label("recordALabel", "Record A");
> >        editForm.add(recordALabel);
> >
> >        recordBLabel = new Label("recordBLabel", "Record B");
> >        editForm.add(recordBLabel);
> >
> >        recordAText = new RequiredTextField("recordAText",
> >                new PropertyModel(selectedRecordAModel, "name"));
> >
> >        editForm.add(recordAText);
> >
> >        recordBs = new DropDownChoice<RecordB>("recordBs");
> >        recordBs.setModel(new PropertyModel(selectedRecordAModel,
> > "recordB"));
> >        recordBs.setChoices(RecordAPanel.this.getRecordBs());
> >        recordBs.setChoiceRenderer(new RecordBRenderer());
> >
> >        editForm.add(recordBs);
> >
> >        save = new Button("save")
> >        {
> >            private static final long serialVersionUID = 1L;
> >
> >            @Override
> >            public void onSubmit()
> >            {
> >                if (isNew)
> >                {
> >
> > recordAService.create(RecordAPanel.this.selectedRecordA);
> >                        info("Created '"
> >                                +
> > RecordAPanel.this.selectedRecordA.getName()
> >                                + "'");
> >                }
> >                else
> >                {
> >                        recordAService.update(unmodifiedRecordA,
> >                                RecordAPanel.this.selectedRecordA);
> >                        info("Updated '"
> >                                +
> > RecordAPanel.this.selectedRecordA.getName()
> >                                + "'");
> >                }
> >
> >                // TODO Update the dropdown list?
> >
> >                editGroup.setVisible(false);
> >                selectGroup.setVisible(true);
> >            }
> >        };
> >
> >        editForm.add(save);
> >
> >        cancel = new Button("cancel")
> >        {
> >            private static final long serialVersionUID = 1L;
> >
> >            public void onSubmit()
> >            {
> >                RecordAPanel.this.selectedRecordA = null;
> >                editGroup.setVisible(false);
> >                selectGroup.setVisible(true);
> >            }
> >        };
> >
> >        cancel.setDefaultFormProcessing(false);
> >        editForm.add(cancel);
> >
> >        editGroup.add(editForm);
> >
> >        editGroup.setVisible(false);
> >        this.add(editGroup);
> >    }
> >
> >    public RecordA getSelectedRecordA()
> >    {
> >        return selectedRecordA;
> >    }
> >
> >    public void setSelectedRecordA(RecordA selectedRecordA)
> >    {
> >        this.selectedRecordA = selectedRecordA;
> >    }
> >
> >    public LoadableDetachableModel<List<RecordA>> recordAsModel = new
> > LoadableDetachableModel<List<RecordA>>()
> >    {
> >        private static final long serialVersionUID = 1L;
> >
> >        @Override
> >        protected List<RecordA> load()
> >        {
> >            return recordAService.getList();
> >        }
> >
> >        public void detach()
> >        {
> >            super.detach();
> >        }
> >    };
> >
> >    // TODO change this to LDM?
> >    List<RecordB> getRecordBs()
> >    {
> >        return recordBService.getList();
> >    }
> >
> >    class RecordARenderer implements IChoiceRenderer<RecordA>
> >    {
> >        private static final long serialVersionUID = 1L;
> >
> >        public Object getDisplayValue(RecordA recordA)
> >        {
> >            return recordA.getName();
> >        }
> >
> >        public String getIdValue(RecordA recordA, int index)
> >        {
> >            return recordA.getName();
> >        }
> >    }
> >
> >    class RecordBRenderer implements IChoiceRenderer<RecordB>
> >    {
> >        private static final long serialVersionUID = 1L;
> >
> >        public Object getDisplayValue(RecordB recordB)
> >        {
> >            return recordB.getName();
> >        }
> >
> >        public String getIdValue(RecordB recordB, int index)
> >        {
> >            return recordB.getName();
> >        }
> >    }
> > }
> >
> > >
> > > Shelli
> > >
> > > -----Original Message-----
> > > From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
> > > Sent: Tuesday, October 12, 2010 10:38 AM
> > > To: users@wicket.apache.org
> > > Subject: Re: PropertyModel Not Refreshing
> > >
> > > here are the tweaks you need to make this work:
> > >
> > > selectedRecordAModel = new PropertyModel<RecordA>(this,
> > "selectedRecordA");
> > >
> > > recordAText = new RequiredTextField("recordAText",
> > >                new PropertyModel(selectedRecordAModel, "name"));
> > >
> > >  recordBs.setModel(new PropertyModel(selectedRecordAModel,
> "recordB"));
> > >
> > > have fun
> > >
> > > -igor
> > >
> > > On Tue, Oct 12, 2010 at 9:03 AM, Shelli Orton
<Sh...@sjrb.ca>
> > wrote:
> > >> I've been able to create a sample application that exhibits the
> > >> same/similar problems to mine.  The sample makes use of an
> in-memory
> > >> list for the data versus accessing a database and so there's some
> > >> differences.  However, I believe the problems that this sample
> exhibits
> > >> have the same root cause as my project (which I believe have
> something
> > >> to do with how my models are set up...).
> > >>
> > >> Issues this sample exhibits:
> > >>
> > >> 1. Choose to edit an existing record, then cancel the edit.
Choose
> > >> another/the same record to edit and the selected record is null
> (error
> > >> message "You must select a record to edit" is displayed).  Must
> > >> close/open session to reset.
> > >>
> > >> 2. Choose to edit an existing record and save the edit.  Choose
> > >> another/the same record to edit and you get a NPE:
> > >>
> > >>    WicketMessage: Method onFormSubmitted of interface
> > >> org.apache.wicket.markup.html.form.IFormSubmitListener targeted
at
> > >> component [MarkupContainer [Component id = selectForm]] threw an
> > >> exception
> > >>
> > >>    Root cause:
> > >>
> > >>    java.lang.NullPointerException
> > >>    at
> > >>
>
org.apache.wicket.markup.html.form.AbstractSingleSelectChoice.convertCho
> > >> iceIdToChoice(AbstractSingleSelectChoice.java:247)
> > >>
> > >> 3. Create a new record and try to save it and get
> > >> WicketRuntimeException:
> > >>
> > >>    WicketMessage: Attempted to set property value on a null
object.
> > >> Property expression: name Value: New One
> > >>
> > >>    Root cause:
> > >>
> > >>    org.apache.wicket.WicketRuntimeException: Attempted to set
> property
> > >> value on a null object. Property expression: name Value: New One
> > >>    at
> > >>
>
org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.j
> > >> ava:125)
> > >>
> > >> 4. Create a new record and then cancel the add, Choose an
existing
> > >> record to edit and the selected record is null (error message
"You
> must
> > >> select a record to edit" is displayed).  Must close/open session
to
> > >> reset.
> > >>
> > >> As always, all help is greatly appreciated as I am stumped.
> > >>
> > >> Thanks,
> > >> Shelli
> > >>
> > >> -----Original Message-----
> > >> From: jcgarciam [mailto:jcgarciam@gmail.com]
> > >> Sent: Friday, October 08, 2010 1:41 PM
> > >> To: users@wicket.apache.org
> > >> Subject: Re: PropertyModel Not Refreshing
> > >>
> > >>
> > >> The attachment didn't make it,
> > >>
> > >> Can you try to extract out the relevant part and creates a
> quickstart
> > >> project that actually reproduces your issue?
> > >>
> > >>
> > >> On Fri, Oct 8, 2010 at 1:41 PM, Shelli Orton [via Apache Wicket]
<
> > >>
>
ml-node+2968688-305091622-65838@n4.nabble.com<ml-node%2B2968688-30509162
2-65838@n4.nabble.com>
> <ml-node%2B2968688-30509162
> 2-65838@n4.nabble.com>
> > <ml-node%2B2968688-30509162
> > >> 2-65838@n4.nabble.com>
> > >>> wrote:
> > >>
> > >>> Hi,
> > >>>
> > >>> I have been trying different things to see if I could get my
code
> to
> > >> work
> > >>> (and understand Wicket models better), but am still stuck.  I
have
> a
> > >>> attached the (latest) panel class code which I hope is
sufficient
> to
> > >> help.
> > >>>
> > >>> I was reading about different models (both online and the Wicket
> in
> > >> Action
> > >>> book) and thought that perhaps using a CompoundPropertyModel was
> more
> > >>> appropriate and may help with my issues.  Originally, I only
> declared
> > >>> selectedRecordA (line 40) but didn't instantiate it.  The select
> group
> > >>> displayed properly but when I chose a record from the list and
> tried
> > >> to edit
> > >>> it, this exception was thrown:
> > >>>
> > >>>     WicketMessage: Attempted to set property value on a null
> object.
> > >>> Property expression: recordA Value: Name=A-One
> > >>>     Root cause:
> > >>>
> > >>>     org.apache.wicket.WicketRuntimeException: Attempted to set
> > >> property
> > >>> value on a null object. Property expression: recordA Value:
> Name=A-One
> > >>>         at
> > >>>
> > >>
>
org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.j
> > >> ava:125)
> > >>>
> > >>>         at
> > >>>
> > >>
>
org.apache.wicket.model.AbstractPropertyModel.setObject(AbstractProperty
> > >> Model.java:169)
> > >>>
> > >>>         at
> > >>>
> org.apache.wicket.Component.setDefaultModelObject(Component.java:3125)
> > >>>         ....
> > >>>
> > >>> I set breakpoints on the getSelectedRecordA and
setSelectedRecordA
> > >> methods,
> > >>> but these aren't called when during the request cycle when the
> edit
> > >> button
> > >>> is clicked.
> > >>>
> > >>> I then changed the class so that selectedRecordA is initialized
to
> an
> > >> empty
> > >>> instance of RecordA. This got rid of the above error.  However,
I
> > >> cannot
> > >>> save the edit changes because the selectedRecordA is still the
> empty
> > >>> instance that was created in the initialization and the
> persistence
> > >> layer
> > >>> throws an exception.  This same problem exists if I try to add a
> new
> > >> RecordA
> > >>> or try to delete an existing one.
> > >>>
> > >>> If I choose to cancel the edit and then select another record to
> edit,
> > >> I
> > >>> get the message "You must select a record to edit" (line 131).
> This
> > >> is
> > >>> because the cancel onSubmit sets selectedRecordA to null and
> choosing
> > >> the
> > >>> record from the DDC is not setting it to the chosen record.
> > >>>
> > >>> Clearly I am not setting up this CompoundPropertyModel properly
so
> > >> that the
> > >>> selectedARecord is set by the model.  Can someone tell me what
I'm
> > >> doing
> > >>> wrong?
> > >>>
> > >>> All help is greatly appreciated,
> > >>>
> > >>> Shelli
> > >>>
> > >>>
> > >>> -----Original Message-----
> > >>> From: Igor Vaynberg [mailto:[hidden
> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=0>]
> > >>>
> > >>> Sent: Thursday, October 07, 2010 11:27 AM
> > >>> To: [hidden email]
> > >> <http://user/SendEmail.jtp?type=node&node=2968688&i=1>
> > >>> Subject: Re: PropertyModel Not Refreshing
> > >>>
> > >>> you have posted an incomplete piece of code and somehow from
that
> we
> > >>> are supposed to guess what is not working? create a quickstart
and
> > >>> provide that.
> > >>>
> > >>> -igor
> > >>>
> > >>> On Thu, Oct 7, 2010 at 10:15 AM, Shelli Orton <[hidden
> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=2>>
> > >>> wrote:
> > >>>
> > >>> > Does nobody have any suggestions?  If I can't get this fixed,
> I'm
> > >> going
> > >>> > to have to write the app in another framework (possibly GWT)
and
> I'd
> > >>> > really rather not have to do that.
> > >>> >
> > >>> > Shelli
> > >>> >
> > >>> > -----Original Message-----
> > >>> > From: Shelli Orton
> > >>> > Sent: Wednesday, October 06, 2010 3:52 PM
> > >>> > To: [hidden
> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=3>
> > >>> > Subject: PropertyModel Not Refreshing
> > >>> >
> > >>> > Hi,
> > >>> >
> > >>> > First, thanks to all who have been helping me as I am new to
> Wicket.
> > >> I
> > >>> > am splitting out two issues I am dealing with to try to keep
> things
> > >>> > clear.
> > >>> >
> > >>> > I am trying to write a simple app that does CRUD operations on
> > >> database
> > >>> > records.  The goal is for the app to make use of a tab panel
> where
> > >> each
> > >>> > tab encapsulates one table from the database.  Each tab panel
> has
> > >> two
> > >>> > groups (WebMarkupContainer).  The first, selectGroup, displays
a
> > >> list
> > >>> > (DDC) of the current items, and three buttons, add, edit and
> delete.
> > >>> > The second, editGroup, is displayed when either the add or
edit
> > >> button
> > >>> > was clicked on the select group, displays the record
attributes
> and
> > >> save
> > >>> > and cancel buttons.  The tab panel has a "selectedRecord"
which
> is
> > >> used
> > >>> > by both groups' components via PropertyModels. Very basic
stuff.
> > >>> >
> > >>> > When I choose a record and click the edit button, the record
is
> > >>> > displayed in the edit group properly.  If I then choose
cancel,
> the
> > >> edit
> > >>> > group is no longer displayed and the select group DDC
selection
> is
> > >> null
> > >>> > as expected. I then choose another record from the list and
> click
> > >> the
> > >>> > edit button and the previous record information is displayed
in
> the
> > >> edit
> > >>> > group even though the select group DDC shows the
> correct/selected
> > >>> > record.
> > >>> >
> > >>> > This problem also occurs if I first choose to add a new record
> and
> > >> then
> > >>> > cancel the add and then choose to edit a different record.
The
> DDC
> > >>> > shows the correct/selected record, but all the attributes in
the
> > >> edit
> > >>> > group are null/defaults for a new record.
> > >>> >
> > >>> > If I remove the call to setDefaultFormProcessing(false) on the
> > >> cancel
> > >>> > button, selecting other records for edit works correctly, but
I
> > >> can't
> > >>> > cancel a creating a new record if I use a RequiredTextField
> because
> > >> the
> > >>> > form validation fails.
> > >>> >
> > >>> > If I select a record for editing or save the newly created
> record, I
> > >> can
> > >>> > select a different record for edit or create another one
> correctly.
> > >> So
> > >>> > I must be doing something wrong in the cancel logic. My
editForm
> > >>> > (created in the EditGroup constructor) looks like this:
> > >>> >
> > >>> >            Form editForm = new Form("editForm");
> > >>> >
> > >>> >            editForm.add(new Label("nameLabel", "Name"));
> > >>> >
> > >>> >            editForm.add(new Label("attributeLabel",
> "Attribute"));
> > >>> >
> > >>> >            editForm.add(new
> > >> RequiredTextField<String>("recordNameText",
> > >>> >                    new
PropertyModel<String>(MyRecordPanel.this,
> > >>> >                            "selectedRecord.name")));
> > >>> >
> > >>> >            editForm.add(new DropDownChoice<Lir>("attributes",
> > >>> >                    new
> PropertyModel<Attribute>(MyRecordPanel.this,
> > >>> >                            "selectedRecord.attribute"),
> > >>> >                    RateCentrePanel.this.getAttributes(),
> > >>> >                    new AttributeRenderer()));
> > >>> >
> > >>> >            ....
> > >>> >
> > >>> >            editForm.add(new Button("cancel")
> > >>> >            {
> > >>> >                private static final long serialVersionUID =
1L;
> > >>> >
> > >>> >                public void onSubmit()
> > >>> >                {
> > >>> >                    MyRecordPanel.this.selectedRecord = null;
> > >>> >                    editGroup.setVisible(false);
> > >>> >                    selectGroup.setVisible(true);
> > >>> >                }
> > >>> >            }.setDefaultFormProcessing(false));
> > >>> >
> > >>> >            add(editForm);
> > >>> >
> > >>> > Other than setting the selectedRecord to null, what should I
be
> > >> doing
> > >>> > differently?
> > >>> >
> > >>> > Thanks in advance!
> > >>> >
> > >>> > Shelli
> > >>> >
> > >>> >
> > >>
> ---------------------------------------------------------------------
> > >>> > To unsubscribe, e-mail: [hidden
> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=4>
> > >>> > For additional commands, e-mail: [hidden
> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=5>
> > >>> >
> > >>> >
> > >>> >
> > >>
> ---------------------------------------------------------------------
> > >>> > To unsubscribe, e-mail: [hidden
> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=6>
> > >>> > For additional commands, e-mail: [hidden
> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=7>
> > >>> >
> > >>> >
> > >>>
> ---------------------------------------------------------------------
> > >>> To unsubscribe, e-mail: [hidden
> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=8>
> > >>> For additional commands, e-mail: [hidden
> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=9>
> > >>>
> > >>>
> > >>>
> > >>>
> > >>>
> ---------------------------------------------------------------------
> > >>> To unsubscribe, e-mail: [hidden
> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=10>
> > >>> For additional commands, e-mail: [hidden
> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=11>
> > >>>
> > >>> ------------------------------
> > >>>  View message @
> > >>>
> > >>
> >
>
http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
> > >> n-tp2955144p2968688.html
> > >>> To start a new topic under Apache Wicket, email
> > >>>
> > >>
>
ml-node+1842946-398011874-65838@n4.nabble.com<ml-node%2B1842946-39801187
4-65838@n4.nabble.com>
> <ml-node%2B1842946-39801187
> 4-65838@n4.nabble.com>
> > <ml-node%2B1842946-39801187
> > >> 4-65838@n4.nabble.com>
> > >>> To unsubscribe from Apache Wicket, click
> > >>
>
here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp
> > ?
> > >>
>
tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
> > >> QyOTQ2fDEyNTYxMzc3ODY=>.
> > >>>
> > >>>
> > >>>
> > >>
> > >>
> > >> --
> > >> Sincerely,
> > >> JC (http://www.linkedin.com/in/jcgarciam)
> > >> Work smarter, not harder!.
> > >>
> > >> --
> > >> View this message in context:
> > >>
> >
>
http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
> > >> n-tp2955144p2968936.html
> > >> Sent from the Users forum mailing list archive at Nabble.com.
> > >>
> > >>
> ---------------------------------------------------------------------
> > >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > >> For additional commands, e-mail: users-help@wicket.apache.org
> > >>
> > >>
> > >>
> > >>
> ---------------------------------------------------------------------
> > >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > >> For additional commands, e-mail: users-help@wicket.apache.org
> > >>
> > >
> > >
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > > For additional commands, e-mail: users-help@wicket.apache.org
> > >
> > >
> > >
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > > For additional commands, e-mail: users-help@wicket.apache.org
> > >
> > >
> >
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: PropertyModel Not Refreshing

Posted by nino martinez wael <ni...@gmail.com>.
sorry.. Did'nt see it attached.. So did igor provide you with an fixed
quickstart (working on his system).. That did not work on glassfish?

2010/10/12 Shelli Orton <Sh...@sjrb.ca>

> The quickstart was sent to the list this morning at 10:04 MST.  Does it
> need to be resent?
>
> Shelli
>
> -----Original Message-----
> From: nino martinez wael [mailto:nino.martinez.wael@gmail.com]
> Sent: Tuesday, October 12, 2010 11:52 AM
> To: users@wicket.apache.org
> Subject: Re: PropertyModel Not Refreshing
>
> No dont think so.. Please provide a quickstart.. I have had property
> models
> working in 1.2, 1.3, 1.4 and 1.5 so must be error 42:)
>
> 2010/10/12 Shelli Orton <Sh...@sjrb.ca>
>
> > Hi,
> >
> > Thanks for file.  Your first email was missing these changes:
> >
> >    IModel<RecordA> selectedRecordAModel;  (I had set mine to
> > PropertyModel<RecordA> selectedRecordAModel;)
> >    recordAs.setModel(selectedRecordAModel)
> >
> > However, even with those changes applied, I still get the same issue
> of the
> > selected record not updating in the edit group.
> >
> > I am deploying in Glassfish v3.  Could that have anything to do with
> my
> > problems?
> >
> > Shelli
> >
> > -----Original Message-----
> > From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
> > Sent: Tuesday, October 12, 2010 11:35 AM
> > To: users@wicket.apache.org
> > Subject: Re: PropertyModel Not Refreshing
> >
> > On Tue, Oct 12, 2010 at 10:30 AM, Shelli Orton <Sh...@sjrb.ca>
> > wrote:
> > > Thanks for the help.  Your changes got rid of the errors and I can
> delete
> > records now (and the list is updated).
> > >
> > > However, once a record has been selected for edit and either saved
> or
> > cancelled, that same record is always displayed in the edit group when
> I
> > choose another record to edit or even when I try to create a new one.
> I can
> > even delete the chosen record and it still displays in the edit group.
> >
> > works fine here, meaning you did not completely/propery apply my
> > changes. below is the complete file.
> >
> > -igor
> >
> > public class RecordAPanel extends Panel
> > {
> >    private static final long serialVersionUID = 1L;
> >
> >    RecordAService recordAService;
> >    RecordBService recordBService;
> >
> >    RecordA selectedRecordA = new RecordA();
> >    IModel<RecordA> selectedRecordAModel;
> >    String unmodifiedRecordA;
> >
> >    boolean isNew = false;
> >
> >    WebMarkupContainer selectGroup;
> >    WebMarkupContainer editGroup;
> >
> >    Form selectForm;
> >    Form editForm;
> >
> >    DropDownChoice<RecordA> recordAs;
> >    DropDownChoice<RecordB> recordBs;
> >
> >    Button add;
> >    Button edit;
> >    Button save;
> >    Button delete;
> >    Button cancel;
> >
> >    Label editLegendLabel;
> >    String editLegend;
> >    Label recordALabel;
> >    Label recordBLabel;
> >
> >    RequiredTextField recordAText;
> >
> >    @SuppressWarnings({ "rawtypes", "unchecked" })
> >    public RecordAPanel(String id)
> >    {
> >        super(id);
> >
> >        recordAService = ((Application)
> > RequestCycle.get().getApplication()).getRecordAService();
> >        recordBService = ((Application)
> > RequestCycle.get().getApplication()).getRecordBService();
> >
> >        selectedRecordAModel = new PropertyModel<RecordA>(this,
> > "selectedRecordA");
> >        this.setDefaultModel(selectedRecordAModel);
> >
> >        // ************* Select  Group *************
> >
> >        selectGroup = new WebMarkupContainer("selectGroup");
> >        selectForm = new Form("selectForm");
> >
> >        recordAs = new DropDownChoice<RecordA>("recordAs");
> >        recordAs.setModel(selectedRecordAModel);
> >        recordAs.setChoices(recordAsModel);
> >        recordAs.setChoiceRenderer(new RecordARenderer());
> >
> >        //            recordAs = (DropDownChoice<RecordA>) new
> > DropDownChoice<RecordA>("recordAs",
> >        //                    new PropertyModel<RecordA>(this,
> > "selectedRecordA"),
> >        //                    recordAsModel,
> >        //                    new RecordARenderer());
> >
> >        recordAs.setNullValid(false);
> >
> >        selectForm.add(recordAs);
> >
> >        add = new Button("add")
> >        {
> >            private static final long serialVersionUID = 1L;
> >
> >            public void onSubmit()
> >            {
> >                setSelectedRecordA(new RecordA());
> >                isNew = true;
> >                editLegend = "New";
> >                editGroup.setVisible(true);
> >                selectGroup.setVisible(false);
> >            }
> >        };
> >
> >        selectForm.add(add);
> >
> >        edit = new Button("edit")
> >        {
> >            private static final long serialVersionUID = 1L;
> >
> >            public void onSubmit()
> >            {
> >                if (selectedRecordA == null)
> >                {
> >                    info("You must select a record to edit.");
> >                }
> >                else
> >                {
> >                    unmodifiedRecordA = selectedRecordA.getName();
> >                    isNew = false;
> >                    editLegend = "Edit";
> >                    editGroup.setVisible(true);
> >                    selectGroup.setVisible(false);
> >                }
> >            }
> >        };
> >
> >        selectForm.add(edit);
> >
> >        delete = new Button("delete")
> >        {
> >            private static final long serialVersionUID = 1L;
> >
> >            public void onSubmit()
> >            {
> >                if (selectedRecordA == null)
> >                {
> >                    info("You must select a record to delete.");
> >                }
> >                else
> >                {
> >                    // Delete the selected record
> >                    unmodifiedRecordA = selectedRecordA.getName();
> >                    recordAService.delete(selectedRecordA.getName());
> >                    selectedRecordA = null;
> >                    info("Deleted '" + unmodifiedRecordA + "'");
> >
> >                    // Force refresh of records list
> >                    RecordAPanel.this.recordAsModel.detach();
> >                }
> >            }
> >        };
> >
> >        // Add confirmation dialog box
> >        delete.add(new SimpleAttributeModifier("onclick",
> >                "if (!confirm('Please confirm you want to delete this
> > record') ){ return false; }"));
> >
> >        selectForm.add(delete);
> >        selectGroup.add(selectForm);
> >
> >        this.add(selectGroup);
> >
> >        // ************* Edit Group *************
> >
> >        editGroup = new WebMarkupContainer("editGroup");
> >
> >        editLegendLabel = new Label("editLegend", new
> PropertyModel(this,
> >                "editLegend"));
> >
> >        editGroup.add(editLegendLabel);
> >
> >        editForm = new Form("editForm");
> >
> >        recordALabel = new Label("recordALabel", "Record A");
> >        editForm.add(recordALabel);
> >
> >        recordBLabel = new Label("recordBLabel", "Record B");
> >        editForm.add(recordBLabel);
> >
> >        recordAText = new RequiredTextField("recordAText",
> >                new PropertyModel(selectedRecordAModel, "name"));
> >
> >        editForm.add(recordAText);
> >
> >        recordBs = new DropDownChoice<RecordB>("recordBs");
> >        recordBs.setModel(new PropertyModel(selectedRecordAModel,
> > "recordB"));
> >        recordBs.setChoices(RecordAPanel.this.getRecordBs());
> >        recordBs.setChoiceRenderer(new RecordBRenderer());
> >
> >        editForm.add(recordBs);
> >
> >        save = new Button("save")
> >        {
> >            private static final long serialVersionUID = 1L;
> >
> >            @Override
> >            public void onSubmit()
> >            {
> >                if (isNew)
> >                {
> >
> > recordAService.create(RecordAPanel.this.selectedRecordA);
> >                        info("Created '"
> >                                +
> > RecordAPanel.this.selectedRecordA.getName()
> >                                + "'");
> >                }
> >                else
> >                {
> >                        recordAService.update(unmodifiedRecordA,
> >                                RecordAPanel.this.selectedRecordA);
> >                        info("Updated '"
> >                                +
> > RecordAPanel.this.selectedRecordA.getName()
> >                                + "'");
> >                }
> >
> >                // TODO Update the dropdown list?
> >
> >                editGroup.setVisible(false);
> >                selectGroup.setVisible(true);
> >            }
> >        };
> >
> >        editForm.add(save);
> >
> >        cancel = new Button("cancel")
> >        {
> >            private static final long serialVersionUID = 1L;
> >
> >            public void onSubmit()
> >            {
> >                RecordAPanel.this.selectedRecordA = null;
> >                editGroup.setVisible(false);
> >                selectGroup.setVisible(true);
> >            }
> >        };
> >
> >        cancel.setDefaultFormProcessing(false);
> >        editForm.add(cancel);
> >
> >        editGroup.add(editForm);
> >
> >        editGroup.setVisible(false);
> >        this.add(editGroup);
> >    }
> >
> >    public RecordA getSelectedRecordA()
> >    {
> >        return selectedRecordA;
> >    }
> >
> >    public void setSelectedRecordA(RecordA selectedRecordA)
> >    {
> >        this.selectedRecordA = selectedRecordA;
> >    }
> >
> >    public LoadableDetachableModel<List<RecordA>> recordAsModel = new
> > LoadableDetachableModel<List<RecordA>>()
> >    {
> >        private static final long serialVersionUID = 1L;
> >
> >        @Override
> >        protected List<RecordA> load()
> >        {
> >            return recordAService.getList();
> >        }
> >
> >        public void detach()
> >        {
> >            super.detach();
> >        }
> >    };
> >
> >    // TODO change this to LDM?
> >    List<RecordB> getRecordBs()
> >    {
> >        return recordBService.getList();
> >    }
> >
> >    class RecordARenderer implements IChoiceRenderer<RecordA>
> >    {
> >        private static final long serialVersionUID = 1L;
> >
> >        public Object getDisplayValue(RecordA recordA)
> >        {
> >            return recordA.getName();
> >        }
> >
> >        public String getIdValue(RecordA recordA, int index)
> >        {
> >            return recordA.getName();
> >        }
> >    }
> >
> >    class RecordBRenderer implements IChoiceRenderer<RecordB>
> >    {
> >        private static final long serialVersionUID = 1L;
> >
> >        public Object getDisplayValue(RecordB recordB)
> >        {
> >            return recordB.getName();
> >        }
> >
> >        public String getIdValue(RecordB recordB, int index)
> >        {
> >            return recordB.getName();
> >        }
> >    }
> > }
> >
> > >
> > > Shelli
> > >
> > > -----Original Message-----
> > > From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
> > > Sent: Tuesday, October 12, 2010 10:38 AM
> > > To: users@wicket.apache.org
> > > Subject: Re: PropertyModel Not Refreshing
> > >
> > > here are the tweaks you need to make this work:
> > >
> > > selectedRecordAModel = new PropertyModel<RecordA>(this,
> > "selectedRecordA");
> > >
> > > recordAText = new RequiredTextField("recordAText",
> > >                new PropertyModel(selectedRecordAModel, "name"));
> > >
> > >  recordBs.setModel(new PropertyModel(selectedRecordAModel,
> "recordB"));
> > >
> > > have fun
> > >
> > > -igor
> > >
> > > On Tue, Oct 12, 2010 at 9:03 AM, Shelli Orton <Sh...@sjrb.ca>
> > wrote:
> > >> I've been able to create a sample application that exhibits the
> > >> same/similar problems to mine.  The sample makes use of an
> in-memory
> > >> list for the data versus accessing a database and so there's some
> > >> differences.  However, I believe the problems that this sample
> exhibits
> > >> have the same root cause as my project (which I believe have
> something
> > >> to do with how my models are set up...).
> > >>
> > >> Issues this sample exhibits:
> > >>
> > >> 1. Choose to edit an existing record, then cancel the edit.  Choose
> > >> another/the same record to edit and the selected record is null
> (error
> > >> message "You must select a record to edit" is displayed).  Must
> > >> close/open session to reset.
> > >>
> > >> 2. Choose to edit an existing record and save the edit.  Choose
> > >> another/the same record to edit and you get a NPE:
> > >>
> > >>    WicketMessage: Method onFormSubmitted of interface
> > >> org.apache.wicket.markup.html.form.IFormSubmitListener targeted at
> > >> component [MarkupContainer [Component id = selectForm]] threw an
> > >> exception
> > >>
> > >>    Root cause:
> > >>
> > >>    java.lang.NullPointerException
> > >>    at
> > >>
> org.apache.wicket.markup.html.form.AbstractSingleSelectChoice.convertCho
> > >> iceIdToChoice(AbstractSingleSelectChoice.java:247)
> > >>
> > >> 3. Create a new record and try to save it and get
> > >> WicketRuntimeException:
> > >>
> > >>    WicketMessage: Attempted to set property value on a null object.
> > >> Property expression: name Value: New One
> > >>
> > >>    Root cause:
> > >>
> > >>    org.apache.wicket.WicketRuntimeException: Attempted to set
> property
> > >> value on a null object. Property expression: name Value: New One
> > >>    at
> > >>
> org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.j
> > >> ava:125)
> > >>
> > >> 4. Create a new record and then cancel the add, Choose an existing
> > >> record to edit and the selected record is null (error message "You
> must
> > >> select a record to edit" is displayed).  Must close/open session to
> > >> reset.
> > >>
> > >> As always, all help is greatly appreciated as I am stumped.
> > >>
> > >> Thanks,
> > >> Shelli
> > >>
> > >> -----Original Message-----
> > >> From: jcgarciam [mailto:jcgarciam@gmail.com]
> > >> Sent: Friday, October 08, 2010 1:41 PM
> > >> To: users@wicket.apache.org
> > >> Subject: Re: PropertyModel Not Refreshing
> > >>
> > >>
> > >> The attachment didn't make it,
> > >>
> > >> Can you try to extract out the relevant part and creates a
> quickstart
> > >> project that actually reproduces your issue?
> > >>
> > >>
> > >> On Fri, Oct 8, 2010 at 1:41 PM, Shelli Orton [via Apache Wicket] <
> > >>
> ml-node+2968688-305091622-65838@n4.nabble.com<ml...@n4.nabble.com>
> <ml-node%2B2968688-30509162
> 2-65838@n4.nabble.com>
> > <ml-node%2B2968688-30509162
> > >> 2-65838@n4.nabble.com>
> > >>> wrote:
> > >>
> > >>> Hi,
> > >>>
> > >>> I have been trying different things to see if I could get my code
> to
> > >> work
> > >>> (and understand Wicket models better), but am still stuck.  I have
> a
> > >>> attached the (latest) panel class code which I hope is sufficient
> to
> > >> help.
> > >>>
> > >>> I was reading about different models (both online and the Wicket
> in
> > >> Action
> > >>> book) and thought that perhaps using a CompoundPropertyModel was
> more
> > >>> appropriate and may help with my issues.  Originally, I only
> declared
> > >>> selectedRecordA (line 40) but didn't instantiate it.  The select
> group
> > >>> displayed properly but when I chose a record from the list and
> tried
> > >> to edit
> > >>> it, this exception was thrown:
> > >>>
> > >>>     WicketMessage: Attempted to set property value on a null
> object.
> > >>> Property expression: recordA Value: Name=A-One
> > >>>     Root cause:
> > >>>
> > >>>     org.apache.wicket.WicketRuntimeException: Attempted to set
> > >> property
> > >>> value on a null object. Property expression: recordA Value:
> Name=A-One
> > >>>         at
> > >>>
> > >>
> org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.j
> > >> ava:125)
> > >>>
> > >>>         at
> > >>>
> > >>
> org.apache.wicket.model.AbstractPropertyModel.setObject(AbstractProperty
> > >> Model.java:169)
> > >>>
> > >>>         at
> > >>>
> org.apache.wicket.Component.setDefaultModelObject(Component.java:3125)
> > >>>         ....
> > >>>
> > >>> I set breakpoints on the getSelectedRecordA and setSelectedRecordA
> > >> methods,
> > >>> but these aren't called when during the request cycle when the
> edit
> > >> button
> > >>> is clicked.
> > >>>
> > >>> I then changed the class so that selectedRecordA is initialized to
> an
> > >> empty
> > >>> instance of RecordA. This got rid of the above error.  However, I
> > >> cannot
> > >>> save the edit changes because the selectedRecordA is still the
> empty
> > >>> instance that was created in the initialization and the
> persistence
> > >> layer
> > >>> throws an exception.  This same problem exists if I try to add a
> new
> > >> RecordA
> > >>> or try to delete an existing one.
> > >>>
> > >>> If I choose to cancel the edit and then select another record to
> edit,
> > >> I
> > >>> get the message "You must select a record to edit" (line 131).
> This
> > >> is
> > >>> because the cancel onSubmit sets selectedRecordA to null and
> choosing
> > >> the
> > >>> record from the DDC is not setting it to the chosen record.
> > >>>
> > >>> Clearly I am not setting up this CompoundPropertyModel properly so
> > >> that the
> > >>> selectedARecord is set by the model.  Can someone tell me what I'm
> > >> doing
> > >>> wrong?
> > >>>
> > >>> All help is greatly appreciated,
> > >>>
> > >>> Shelli
> > >>>
> > >>>
> > >>> -----Original Message-----
> > >>> From: Igor Vaynberg [mailto:[hidden
> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=0>]
> > >>>
> > >>> Sent: Thursday, October 07, 2010 11:27 AM
> > >>> To: [hidden email]
> > >> <http://user/SendEmail.jtp?type=node&node=2968688&i=1>
> > >>> Subject: Re: PropertyModel Not Refreshing
> > >>>
> > >>> you have posted an incomplete piece of code and somehow from that
> we
> > >>> are supposed to guess what is not working? create a quickstart and
> > >>> provide that.
> > >>>
> > >>> -igor
> > >>>
> > >>> On Thu, Oct 7, 2010 at 10:15 AM, Shelli Orton <[hidden
> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=2>>
> > >>> wrote:
> > >>>
> > >>> > Does nobody have any suggestions?  If I can't get this fixed,
> I'm
> > >> going
> > >>> > to have to write the app in another framework (possibly GWT) and
> I'd
> > >>> > really rather not have to do that.
> > >>> >
> > >>> > Shelli
> > >>> >
> > >>> > -----Original Message-----
> > >>> > From: Shelli Orton
> > >>> > Sent: Wednesday, October 06, 2010 3:52 PM
> > >>> > To: [hidden
> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=3>
> > >>> > Subject: PropertyModel Not Refreshing
> > >>> >
> > >>> > Hi,
> > >>> >
> > >>> > First, thanks to all who have been helping me as I am new to
> Wicket.
> > >> I
> > >>> > am splitting out two issues I am dealing with to try to keep
> things
> > >>> > clear.
> > >>> >
> > >>> > I am trying to write a simple app that does CRUD operations on
> > >> database
> > >>> > records.  The goal is for the app to make use of a tab panel
> where
> > >> each
> > >>> > tab encapsulates one table from the database.  Each tab panel
> has
> > >> two
> > >>> > groups (WebMarkupContainer).  The first, selectGroup, displays a
> > >> list
> > >>> > (DDC) of the current items, and three buttons, add, edit and
> delete.
> > >>> > The second, editGroup, is displayed when either the add or edit
> > >> button
> > >>> > was clicked on the select group, displays the record attributes
> and
> > >> save
> > >>> > and cancel buttons.  The tab panel has a "selectedRecord" which
> is
> > >> used
> > >>> > by both groups' components via PropertyModels. Very basic stuff.
> > >>> >
> > >>> > When I choose a record and click the edit button, the record is
> > >>> > displayed in the edit group properly.  If I then choose cancel,
> the
> > >> edit
> > >>> > group is no longer displayed and the select group DDC selection
> is
> > >> null
> > >>> > as expected. I then choose another record from the list and
> click
> > >> the
> > >>> > edit button and the previous record information is displayed in
> the
> > >> edit
> > >>> > group even though the select group DDC shows the
> correct/selected
> > >>> > record.
> > >>> >
> > >>> > This problem also occurs if I first choose to add a new record
> and
> > >> then
> > >>> > cancel the add and then choose to edit a different record.  The
> DDC
> > >>> > shows the correct/selected record, but all the attributes in the
> > >> edit
> > >>> > group are null/defaults for a new record.
> > >>> >
> > >>> > If I remove the call to setDefaultFormProcessing(false) on the
> > >> cancel
> > >>> > button, selecting other records for edit works correctly, but I
> > >> can't
> > >>> > cancel a creating a new record if I use a RequiredTextField
> because
> > >> the
> > >>> > form validation fails.
> > >>> >
> > >>> > If I select a record for editing or save the newly created
> record, I
> > >> can
> > >>> > select a different record for edit or create another one
> correctly.
> > >> So
> > >>> > I must be doing something wrong in the cancel logic. My editForm
> > >>> > (created in the EditGroup constructor) looks like this:
> > >>> >
> > >>> >            Form editForm = new Form("editForm");
> > >>> >
> > >>> >            editForm.add(new Label("nameLabel", "Name"));
> > >>> >
> > >>> >            editForm.add(new Label("attributeLabel",
> "Attribute"));
> > >>> >
> > >>> >            editForm.add(new
> > >> RequiredTextField<String>("recordNameText",
> > >>> >                    new PropertyModel<String>(MyRecordPanel.this,
> > >>> >                            "selectedRecord.name")));
> > >>> >
> > >>> >            editForm.add(new DropDownChoice<Lir>("attributes",
> > >>> >                    new
> PropertyModel<Attribute>(MyRecordPanel.this,
> > >>> >                            "selectedRecord.attribute"),
> > >>> >                    RateCentrePanel.this.getAttributes(),
> > >>> >                    new AttributeRenderer()));
> > >>> >
> > >>> >            ....
> > >>> >
> > >>> >            editForm.add(new Button("cancel")
> > >>> >            {
> > >>> >                private static final long serialVersionUID = 1L;
> > >>> >
> > >>> >                public void onSubmit()
> > >>> >                {
> > >>> >                    MyRecordPanel.this.selectedRecord = null;
> > >>> >                    editGroup.setVisible(false);
> > >>> >                    selectGroup.setVisible(true);
> > >>> >                }
> > >>> >            }.setDefaultFormProcessing(false));
> > >>> >
> > >>> >            add(editForm);
> > >>> >
> > >>> > Other than setting the selectedRecord to null, what should I be
> > >> doing
> > >>> > differently?
> > >>> >
> > >>> > Thanks in advance!
> > >>> >
> > >>> > Shelli
> > >>> >
> > >>> >
> > >>
> ---------------------------------------------------------------------
> > >>> > To unsubscribe, e-mail: [hidden
> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=4>
> > >>> > For additional commands, e-mail: [hidden
> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=5>
> > >>> >
> > >>> >
> > >>> >
> > >>
> ---------------------------------------------------------------------
> > >>> > To unsubscribe, e-mail: [hidden
> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=6>
> > >>> > For additional commands, e-mail: [hidden
> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=7>
> > >>> >
> > >>> >
> > >>>
> ---------------------------------------------------------------------
> > >>> To unsubscribe, e-mail: [hidden
> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=8>
> > >>> For additional commands, e-mail: [hidden
> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=9>
> > >>>
> > >>>
> > >>>
> > >>>
> > >>>
> ---------------------------------------------------------------------
> > >>> To unsubscribe, e-mail: [hidden
> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=10>
> > >>> For additional commands, e-mail: [hidden
> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=11>
> > >>>
> > >>> ------------------------------
> > >>>  View message @
> > >>>
> > >>
> >
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
> > >> n-tp2955144p2968688.html
> > >>> To start a new topic under Apache Wicket, email
> > >>>
> > >>
> ml-node+1842946-398011874-65838@n4.nabble.com<ml...@n4.nabble.com>
> <ml-node%2B1842946-39801187
> 4-65838@n4.nabble.com>
> > <ml-node%2B1842946-39801187
> > >> 4-65838@n4.nabble.com>
> > >>> To unsubscribe from Apache Wicket, click
> > >>
> here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp
> > ?
> > >>
> tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
> > >> QyOTQ2fDEyNTYxMzc3ODY=>.
> > >>>
> > >>>
> > >>>
> > >>
> > >>
> > >> --
> > >> Sincerely,
> > >> JC (http://www.linkedin.com/in/jcgarciam)
> > >> Work smarter, not harder!.
> > >>
> > >> --
> > >> View this message in context:
> > >>
> >
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
> > >> n-tp2955144p2968936.html
> > >> Sent from the Users forum mailing list archive at Nabble.com.
> > >>
> > >>
> ---------------------------------------------------------------------
> > >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > >> For additional commands, e-mail: users-help@wicket.apache.org
> > >>
> > >>
> > >>
> > >>
> ---------------------------------------------------------------------
> > >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > >> For additional commands, e-mail: users-help@wicket.apache.org
> > >>
> > >
> > >
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > > For additional commands, e-mail: users-help@wicket.apache.org
> > >
> > >
> > >
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > > For additional commands, e-mail: users-help@wicket.apache.org
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

RE: PropertyModel Not Refreshing

Posted by Shelli Orton <Sh...@sjrb.ca>.
The quickstart was sent to the list this morning at 10:04 MST.  Does it
need to be resent?

Shelli

-----Original Message-----
From: nino martinez wael [mailto:nino.martinez.wael@gmail.com] 
Sent: Tuesday, October 12, 2010 11:52 AM
To: users@wicket.apache.org
Subject: Re: PropertyModel Not Refreshing

No dont think so.. Please provide a quickstart.. I have had property
models
working in 1.2, 1.3, 1.4 and 1.5 so must be error 42:)

2010/10/12 Shelli Orton <Sh...@sjrb.ca>

> Hi,
>
> Thanks for file.  Your first email was missing these changes:
>
>    IModel<RecordA> selectedRecordAModel;  (I had set mine to
> PropertyModel<RecordA> selectedRecordAModel;)
>    recordAs.setModel(selectedRecordAModel)
>
> However, even with those changes applied, I still get the same issue
of the
> selected record not updating in the edit group.
>
> I am deploying in Glassfish v3.  Could that have anything to do with
my
> problems?
>
> Shelli
>
> -----Original Message-----
> From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
> Sent: Tuesday, October 12, 2010 11:35 AM
> To: users@wicket.apache.org
> Subject: Re: PropertyModel Not Refreshing
>
> On Tue, Oct 12, 2010 at 10:30 AM, Shelli Orton <Sh...@sjrb.ca>
> wrote:
> > Thanks for the help.  Your changes got rid of the errors and I can
delete
> records now (and the list is updated).
> >
> > However, once a record has been selected for edit and either saved
or
> cancelled, that same record is always displayed in the edit group when
I
> choose another record to edit or even when I try to create a new one.
I can
> even delete the chosen record and it still displays in the edit group.
>
> works fine here, meaning you did not completely/propery apply my
> changes. below is the complete file.
>
> -igor
>
> public class RecordAPanel extends Panel
> {
>    private static final long serialVersionUID = 1L;
>
>    RecordAService recordAService;
>    RecordBService recordBService;
>
>    RecordA selectedRecordA = new RecordA();
>    IModel<RecordA> selectedRecordAModel;
>    String unmodifiedRecordA;
>
>    boolean isNew = false;
>
>    WebMarkupContainer selectGroup;
>    WebMarkupContainer editGroup;
>
>    Form selectForm;
>    Form editForm;
>
>    DropDownChoice<RecordA> recordAs;
>    DropDownChoice<RecordB> recordBs;
>
>    Button add;
>    Button edit;
>    Button save;
>    Button delete;
>    Button cancel;
>
>    Label editLegendLabel;
>    String editLegend;
>    Label recordALabel;
>    Label recordBLabel;
>
>    RequiredTextField recordAText;
>
>    @SuppressWarnings({ "rawtypes", "unchecked" })
>    public RecordAPanel(String id)
>    {
>        super(id);
>
>        recordAService = ((Application)
> RequestCycle.get().getApplication()).getRecordAService();
>        recordBService = ((Application)
> RequestCycle.get().getApplication()).getRecordBService();
>
>        selectedRecordAModel = new PropertyModel<RecordA>(this,
> "selectedRecordA");
>        this.setDefaultModel(selectedRecordAModel);
>
>        // ************* Select  Group *************
>
>        selectGroup = new WebMarkupContainer("selectGroup");
>        selectForm = new Form("selectForm");
>
>        recordAs = new DropDownChoice<RecordA>("recordAs");
>        recordAs.setModel(selectedRecordAModel);
>        recordAs.setChoices(recordAsModel);
>        recordAs.setChoiceRenderer(new RecordARenderer());
>
>        //            recordAs = (DropDownChoice<RecordA>) new
> DropDownChoice<RecordA>("recordAs",
>        //                    new PropertyModel<RecordA>(this,
> "selectedRecordA"),
>        //                    recordAsModel,
>        //                    new RecordARenderer());
>
>        recordAs.setNullValid(false);
>
>        selectForm.add(recordAs);
>
>        add = new Button("add")
>        {
>            private static final long serialVersionUID = 1L;
>
>            public void onSubmit()
>            {
>                setSelectedRecordA(new RecordA());
>                isNew = true;
>                editLegend = "New";
>                editGroup.setVisible(true);
>                selectGroup.setVisible(false);
>            }
>        };
>
>        selectForm.add(add);
>
>        edit = new Button("edit")
>        {
>            private static final long serialVersionUID = 1L;
>
>            public void onSubmit()
>            {
>                if (selectedRecordA == null)
>                {
>                    info("You must select a record to edit.");
>                }
>                else
>                {
>                    unmodifiedRecordA = selectedRecordA.getName();
>                    isNew = false;
>                    editLegend = "Edit";
>                    editGroup.setVisible(true);
>                    selectGroup.setVisible(false);
>                }
>            }
>        };
>
>        selectForm.add(edit);
>
>        delete = new Button("delete")
>        {
>            private static final long serialVersionUID = 1L;
>
>            public void onSubmit()
>            {
>                if (selectedRecordA == null)
>                {
>                    info("You must select a record to delete.");
>                }
>                else
>                {
>                    // Delete the selected record
>                    unmodifiedRecordA = selectedRecordA.getName();
>                    recordAService.delete(selectedRecordA.getName());
>                    selectedRecordA = null;
>                    info("Deleted '" + unmodifiedRecordA + "'");
>
>                    // Force refresh of records list
>                    RecordAPanel.this.recordAsModel.detach();
>                }
>            }
>        };
>
>        // Add confirmation dialog box
>        delete.add(new SimpleAttributeModifier("onclick",
>                "if (!confirm('Please confirm you want to delete this
> record') ){ return false; }"));
>
>        selectForm.add(delete);
>        selectGroup.add(selectForm);
>
>        this.add(selectGroup);
>
>        // ************* Edit Group *************
>
>        editGroup = new WebMarkupContainer("editGroup");
>
>        editLegendLabel = new Label("editLegend", new
PropertyModel(this,
>                "editLegend"));
>
>        editGroup.add(editLegendLabel);
>
>        editForm = new Form("editForm");
>
>        recordALabel = new Label("recordALabel", "Record A");
>        editForm.add(recordALabel);
>
>        recordBLabel = new Label("recordBLabel", "Record B");
>        editForm.add(recordBLabel);
>
>        recordAText = new RequiredTextField("recordAText",
>                new PropertyModel(selectedRecordAModel, "name"));
>
>        editForm.add(recordAText);
>
>        recordBs = new DropDownChoice<RecordB>("recordBs");
>        recordBs.setModel(new PropertyModel(selectedRecordAModel,
> "recordB"));
>        recordBs.setChoices(RecordAPanel.this.getRecordBs());
>        recordBs.setChoiceRenderer(new RecordBRenderer());
>
>        editForm.add(recordBs);
>
>        save = new Button("save")
>        {
>            private static final long serialVersionUID = 1L;
>
>            @Override
>            public void onSubmit()
>            {
>                if (isNew)
>                {
>
> recordAService.create(RecordAPanel.this.selectedRecordA);
>                        info("Created '"
>                                +
> RecordAPanel.this.selectedRecordA.getName()
>                                + "'");
>                }
>                else
>                {
>                        recordAService.update(unmodifiedRecordA,
>                                RecordAPanel.this.selectedRecordA);
>                        info("Updated '"
>                                +
> RecordAPanel.this.selectedRecordA.getName()
>                                + "'");
>                }
>
>                // TODO Update the dropdown list?
>
>                editGroup.setVisible(false);
>                selectGroup.setVisible(true);
>            }
>        };
>
>        editForm.add(save);
>
>        cancel = new Button("cancel")
>        {
>            private static final long serialVersionUID = 1L;
>
>            public void onSubmit()
>            {
>                RecordAPanel.this.selectedRecordA = null;
>                editGroup.setVisible(false);
>                selectGroup.setVisible(true);
>            }
>        };
>
>        cancel.setDefaultFormProcessing(false);
>        editForm.add(cancel);
>
>        editGroup.add(editForm);
>
>        editGroup.setVisible(false);
>        this.add(editGroup);
>    }
>
>    public RecordA getSelectedRecordA()
>    {
>        return selectedRecordA;
>    }
>
>    public void setSelectedRecordA(RecordA selectedRecordA)
>    {
>        this.selectedRecordA = selectedRecordA;
>    }
>
>    public LoadableDetachableModel<List<RecordA>> recordAsModel = new
> LoadableDetachableModel<List<RecordA>>()
>    {
>        private static final long serialVersionUID = 1L;
>
>        @Override
>        protected List<RecordA> load()
>        {
>            return recordAService.getList();
>        }
>
>        public void detach()
>        {
>            super.detach();
>        }
>    };
>
>    // TODO change this to LDM?
>    List<RecordB> getRecordBs()
>    {
>        return recordBService.getList();
>    }
>
>    class RecordARenderer implements IChoiceRenderer<RecordA>
>    {
>        private static final long serialVersionUID = 1L;
>
>        public Object getDisplayValue(RecordA recordA)
>        {
>            return recordA.getName();
>        }
>
>        public String getIdValue(RecordA recordA, int index)
>        {
>            return recordA.getName();
>        }
>    }
>
>    class RecordBRenderer implements IChoiceRenderer<RecordB>
>    {
>        private static final long serialVersionUID = 1L;
>
>        public Object getDisplayValue(RecordB recordB)
>        {
>            return recordB.getName();
>        }
>
>        public String getIdValue(RecordB recordB, int index)
>        {
>            return recordB.getName();
>        }
>    }
> }
>
> >
> > Shelli
> >
> > -----Original Message-----
> > From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
> > Sent: Tuesday, October 12, 2010 10:38 AM
> > To: users@wicket.apache.org
> > Subject: Re: PropertyModel Not Refreshing
> >
> > here are the tweaks you need to make this work:
> >
> > selectedRecordAModel = new PropertyModel<RecordA>(this,
> "selectedRecordA");
> >
> > recordAText = new RequiredTextField("recordAText",
> >                new PropertyModel(selectedRecordAModel, "name"));
> >
> >  recordBs.setModel(new PropertyModel(selectedRecordAModel,
"recordB"));
> >
> > have fun
> >
> > -igor
> >
> > On Tue, Oct 12, 2010 at 9:03 AM, Shelli Orton <Sh...@sjrb.ca>
> wrote:
> >> I've been able to create a sample application that exhibits the
> >> same/similar problems to mine.  The sample makes use of an
in-memory
> >> list for the data versus accessing a database and so there's some
> >> differences.  However, I believe the problems that this sample
exhibits
> >> have the same root cause as my project (which I believe have
something
> >> to do with how my models are set up...).
> >>
> >> Issues this sample exhibits:
> >>
> >> 1. Choose to edit an existing record, then cancel the edit.  Choose
> >> another/the same record to edit and the selected record is null
(error
> >> message "You must select a record to edit" is displayed).  Must
> >> close/open session to reset.
> >>
> >> 2. Choose to edit an existing record and save the edit.  Choose
> >> another/the same record to edit and you get a NPE:
> >>
> >>    WicketMessage: Method onFormSubmitted of interface
> >> org.apache.wicket.markup.html.form.IFormSubmitListener targeted at
> >> component [MarkupContainer [Component id = selectForm]] threw an
> >> exception
> >>
> >>    Root cause:
> >>
> >>    java.lang.NullPointerException
> >>    at
> >>
org.apache.wicket.markup.html.form.AbstractSingleSelectChoice.convertCho
> >> iceIdToChoice(AbstractSingleSelectChoice.java:247)
> >>
> >> 3. Create a new record and try to save it and get
> >> WicketRuntimeException:
> >>
> >>    WicketMessage: Attempted to set property value on a null object.
> >> Property expression: name Value: New One
> >>
> >>    Root cause:
> >>
> >>    org.apache.wicket.WicketRuntimeException: Attempted to set
property
> >> value on a null object. Property expression: name Value: New One
> >>    at
> >>
org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.j
> >> ava:125)
> >>
> >> 4. Create a new record and then cancel the add, Choose an existing
> >> record to edit and the selected record is null (error message "You
must
> >> select a record to edit" is displayed).  Must close/open session to
> >> reset.
> >>
> >> As always, all help is greatly appreciated as I am stumped.
> >>
> >> Thanks,
> >> Shelli
> >>
> >> -----Original Message-----
> >> From: jcgarciam [mailto:jcgarciam@gmail.com]
> >> Sent: Friday, October 08, 2010 1:41 PM
> >> To: users@wicket.apache.org
> >> Subject: Re: PropertyModel Not Refreshing
> >>
> >>
> >> The attachment didn't make it,
> >>
> >> Can you try to extract out the relevant part and creates a
quickstart
> >> project that actually reproduces your issue?
> >>
> >>
> >> On Fri, Oct 8, 2010 at 1:41 PM, Shelli Orton [via Apache Wicket] <
> >>
ml-node+2968688-305091622-65838@n4.nabble.com<ml-node%2B2968688-30509162
2-65838@n4.nabble.com>
> <ml-node%2B2968688-30509162
> >> 2-65838@n4.nabble.com>
> >>> wrote:
> >>
> >>> Hi,
> >>>
> >>> I have been trying different things to see if I could get my code
to
> >> work
> >>> (and understand Wicket models better), but am still stuck.  I have
a
> >>> attached the (latest) panel class code which I hope is sufficient
to
> >> help.
> >>>
> >>> I was reading about different models (both online and the Wicket
in
> >> Action
> >>> book) and thought that perhaps using a CompoundPropertyModel was
more
> >>> appropriate and may help with my issues.  Originally, I only
declared
> >>> selectedRecordA (line 40) but didn't instantiate it.  The select
group
> >>> displayed properly but when I chose a record from the list and
tried
> >> to edit
> >>> it, this exception was thrown:
> >>>
> >>>     WicketMessage: Attempted to set property value on a null
object.
> >>> Property expression: recordA Value: Name=A-One
> >>>     Root cause:
> >>>
> >>>     org.apache.wicket.WicketRuntimeException: Attempted to set
> >> property
> >>> value on a null object. Property expression: recordA Value:
Name=A-One
> >>>         at
> >>>
> >>
org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.j
> >> ava:125)
> >>>
> >>>         at
> >>>
> >>
org.apache.wicket.model.AbstractPropertyModel.setObject(AbstractProperty
> >> Model.java:169)
> >>>
> >>>         at
> >>>
org.apache.wicket.Component.setDefaultModelObject(Component.java:3125)
> >>>         ....
> >>>
> >>> I set breakpoints on the getSelectedRecordA and setSelectedRecordA
> >> methods,
> >>> but these aren't called when during the request cycle when the
edit
> >> button
> >>> is clicked.
> >>>
> >>> I then changed the class so that selectedRecordA is initialized to
an
> >> empty
> >>> instance of RecordA. This got rid of the above error.  However, I
> >> cannot
> >>> save the edit changes because the selectedRecordA is still the
empty
> >>> instance that was created in the initialization and the
persistence
> >> layer
> >>> throws an exception.  This same problem exists if I try to add a
new
> >> RecordA
> >>> or try to delete an existing one.
> >>>
> >>> If I choose to cancel the edit and then select another record to
edit,
> >> I
> >>> get the message "You must select a record to edit" (line 131).
This
> >> is
> >>> because the cancel onSubmit sets selectedRecordA to null and
choosing
> >> the
> >>> record from the DDC is not setting it to the chosen record.
> >>>
> >>> Clearly I am not setting up this CompoundPropertyModel properly so
> >> that the
> >>> selectedARecord is set by the model.  Can someone tell me what I'm
> >> doing
> >>> wrong?
> >>>
> >>> All help is greatly appreciated,
> >>>
> >>> Shelli
> >>>
> >>>
> >>> -----Original Message-----
> >>> From: Igor Vaynberg [mailto:[hidden
> >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=0>]
> >>>
> >>> Sent: Thursday, October 07, 2010 11:27 AM
> >>> To: [hidden email]
> >> <http://user/SendEmail.jtp?type=node&node=2968688&i=1>
> >>> Subject: Re: PropertyModel Not Refreshing
> >>>
> >>> you have posted an incomplete piece of code and somehow from that
we
> >>> are supposed to guess what is not working? create a quickstart and
> >>> provide that.
> >>>
> >>> -igor
> >>>
> >>> On Thu, Oct 7, 2010 at 10:15 AM, Shelli Orton <[hidden
> >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=2>>
> >>> wrote:
> >>>
> >>> > Does nobody have any suggestions?  If I can't get this fixed,
I'm
> >> going
> >>> > to have to write the app in another framework (possibly GWT) and
I'd
> >>> > really rather not have to do that.
> >>> >
> >>> > Shelli
> >>> >
> >>> > -----Original Message-----
> >>> > From: Shelli Orton
> >>> > Sent: Wednesday, October 06, 2010 3:52 PM
> >>> > To: [hidden
> >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=3>
> >>> > Subject: PropertyModel Not Refreshing
> >>> >
> >>> > Hi,
> >>> >
> >>> > First, thanks to all who have been helping me as I am new to
Wicket.
> >> I
> >>> > am splitting out two issues I am dealing with to try to keep
things
> >>> > clear.
> >>> >
> >>> > I am trying to write a simple app that does CRUD operations on
> >> database
> >>> > records.  The goal is for the app to make use of a tab panel
where
> >> each
> >>> > tab encapsulates one table from the database.  Each tab panel
has
> >> two
> >>> > groups (WebMarkupContainer).  The first, selectGroup, displays a
> >> list
> >>> > (DDC) of the current items, and three buttons, add, edit and
delete.
> >>> > The second, editGroup, is displayed when either the add or edit
> >> button
> >>> > was clicked on the select group, displays the record attributes
and
> >> save
> >>> > and cancel buttons.  The tab panel has a "selectedRecord" which
is
> >> used
> >>> > by both groups' components via PropertyModels. Very basic stuff.
> >>> >
> >>> > When I choose a record and click the edit button, the record is
> >>> > displayed in the edit group properly.  If I then choose cancel,
the
> >> edit
> >>> > group is no longer displayed and the select group DDC selection
is
> >> null
> >>> > as expected. I then choose another record from the list and
click
> >> the
> >>> > edit button and the previous record information is displayed in
the
> >> edit
> >>> > group even though the select group DDC shows the
correct/selected
> >>> > record.
> >>> >
> >>> > This problem also occurs if I first choose to add a new record
and
> >> then
> >>> > cancel the add and then choose to edit a different record.  The
DDC
> >>> > shows the correct/selected record, but all the attributes in the
> >> edit
> >>> > group are null/defaults for a new record.
> >>> >
> >>> > If I remove the call to setDefaultFormProcessing(false) on the
> >> cancel
> >>> > button, selecting other records for edit works correctly, but I
> >> can't
> >>> > cancel a creating a new record if I use a RequiredTextField
because
> >> the
> >>> > form validation fails.
> >>> >
> >>> > If I select a record for editing or save the newly created
record, I
> >> can
> >>> > select a different record for edit or create another one
correctly.
> >> So
> >>> > I must be doing something wrong in the cancel logic. My editForm
> >>> > (created in the EditGroup constructor) looks like this:
> >>> >
> >>> >            Form editForm = new Form("editForm");
> >>> >
> >>> >            editForm.add(new Label("nameLabel", "Name"));
> >>> >
> >>> >            editForm.add(new Label("attributeLabel",
"Attribute"));
> >>> >
> >>> >            editForm.add(new
> >> RequiredTextField<String>("recordNameText",
> >>> >                    new PropertyModel<String>(MyRecordPanel.this,
> >>> >                            "selectedRecord.name")));
> >>> >
> >>> >            editForm.add(new DropDownChoice<Lir>("attributes",
> >>> >                    new
PropertyModel<Attribute>(MyRecordPanel.this,
> >>> >                            "selectedRecord.attribute"),
> >>> >                    RateCentrePanel.this.getAttributes(),
> >>> >                    new AttributeRenderer()));
> >>> >
> >>> >            ....
> >>> >
> >>> >            editForm.add(new Button("cancel")
> >>> >            {
> >>> >                private static final long serialVersionUID = 1L;
> >>> >
> >>> >                public void onSubmit()
> >>> >                {
> >>> >                    MyRecordPanel.this.selectedRecord = null;
> >>> >                    editGroup.setVisible(false);
> >>> >                    selectGroup.setVisible(true);
> >>> >                }
> >>> >            }.setDefaultFormProcessing(false));
> >>> >
> >>> >            add(editForm);
> >>> >
> >>> > Other than setting the selectedRecord to null, what should I be
> >> doing
> >>> > differently?
> >>> >
> >>> > Thanks in advance!
> >>> >
> >>> > Shelli
> >>> >
> >>> >
> >>
---------------------------------------------------------------------
> >>> > To unsubscribe, e-mail: [hidden
> >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=4>
> >>> > For additional commands, e-mail: [hidden
> >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=5>
> >>> >
> >>> >
> >>> >
> >>
---------------------------------------------------------------------
> >>> > To unsubscribe, e-mail: [hidden
> >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=6>
> >>> > For additional commands, e-mail: [hidden
> >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=7>
> >>> >
> >>> >
> >>>
---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: [hidden
> >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=8>
> >>> For additional commands, e-mail: [hidden
> >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=9>
> >>>
> >>>
> >>>
> >>>
> >>>
---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: [hidden
> >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=10>
> >>> For additional commands, e-mail: [hidden
> >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=11>
> >>>
> >>> ------------------------------
> >>>  View message @
> >>>
> >>
>
http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
> >> n-tp2955144p2968688.html
> >>> To start a new topic under Apache Wicket, email
> >>>
> >>
ml-node+1842946-398011874-65838@n4.nabble.com<ml-node%2B1842946-39801187
4-65838@n4.nabble.com>
> <ml-node%2B1842946-39801187
> >> 4-65838@n4.nabble.com>
> >>> To unsubscribe from Apache Wicket, click
> >>
here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp
> ?
> >>
tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
> >> QyOTQ2fDEyNTYxMzc3ODY=>.
> >>>
> >>>
> >>>
> >>
> >>
> >> --
> >> Sincerely,
> >> JC (http://www.linkedin.com/in/jcgarciam)
> >> Work smarter, not harder!.
> >>
> >> --
> >> View this message in context:
> >>
>
http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
> >> n-tp2955144p2968936.html
> >> Sent from the Users forum mailing list archive at Nabble.com.
> >>
> >>
---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >>
> >>
> >>
---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: PropertyModel Not Refreshing

Posted by nino martinez wael <ni...@gmail.com>.
No dont think so.. Please provide a quickstart.. I have had property models
working in 1.2, 1.3, 1.4 and 1.5 so must be error 42:)

2010/10/12 Shelli Orton <Sh...@sjrb.ca>

> Hi,
>
> Thanks for file.  Your first email was missing these changes:
>
>    IModel<RecordA> selectedRecordAModel;  (I had set mine to
> PropertyModel<RecordA> selectedRecordAModel;)
>    recordAs.setModel(selectedRecordAModel)
>
> However, even with those changes applied, I still get the same issue of the
> selected record not updating in the edit group.
>
> I am deploying in Glassfish v3.  Could that have anything to do with my
> problems?
>
> Shelli
>
> -----Original Message-----
> From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
> Sent: Tuesday, October 12, 2010 11:35 AM
> To: users@wicket.apache.org
> Subject: Re: PropertyModel Not Refreshing
>
> On Tue, Oct 12, 2010 at 10:30 AM, Shelli Orton <Sh...@sjrb.ca>
> wrote:
> > Thanks for the help.  Your changes got rid of the errors and I can delete
> records now (and the list is updated).
> >
> > However, once a record has been selected for edit and either saved or
> cancelled, that same record is always displayed in the edit group when I
> choose another record to edit or even when I try to create a new one.  I can
> even delete the chosen record and it still displays in the edit group.
>
> works fine here, meaning you did not completely/propery apply my
> changes. below is the complete file.
>
> -igor
>
> public class RecordAPanel extends Panel
> {
>    private static final long serialVersionUID = 1L;
>
>    RecordAService recordAService;
>    RecordBService recordBService;
>
>    RecordA selectedRecordA = new RecordA();
>    IModel<RecordA> selectedRecordAModel;
>    String unmodifiedRecordA;
>
>    boolean isNew = false;
>
>    WebMarkupContainer selectGroup;
>    WebMarkupContainer editGroup;
>
>    Form selectForm;
>    Form editForm;
>
>    DropDownChoice<RecordA> recordAs;
>    DropDownChoice<RecordB> recordBs;
>
>    Button add;
>    Button edit;
>    Button save;
>    Button delete;
>    Button cancel;
>
>    Label editLegendLabel;
>    String editLegend;
>    Label recordALabel;
>    Label recordBLabel;
>
>    RequiredTextField recordAText;
>
>    @SuppressWarnings({ "rawtypes", "unchecked" })
>    public RecordAPanel(String id)
>    {
>        super(id);
>
>        recordAService = ((Application)
> RequestCycle.get().getApplication()).getRecordAService();
>        recordBService = ((Application)
> RequestCycle.get().getApplication()).getRecordBService();
>
>        selectedRecordAModel = new PropertyModel<RecordA>(this,
> "selectedRecordA");
>        this.setDefaultModel(selectedRecordAModel);
>
>        // ************* Select  Group *************
>
>        selectGroup = new WebMarkupContainer("selectGroup");
>        selectForm = new Form("selectForm");
>
>        recordAs = new DropDownChoice<RecordA>("recordAs");
>        recordAs.setModel(selectedRecordAModel);
>        recordAs.setChoices(recordAsModel);
>        recordAs.setChoiceRenderer(new RecordARenderer());
>
>        //            recordAs = (DropDownChoice<RecordA>) new
> DropDownChoice<RecordA>("recordAs",
>        //                    new PropertyModel<RecordA>(this,
> "selectedRecordA"),
>        //                    recordAsModel,
>        //                    new RecordARenderer());
>
>        recordAs.setNullValid(false);
>
>        selectForm.add(recordAs);
>
>        add = new Button("add")
>        {
>            private static final long serialVersionUID = 1L;
>
>            public void onSubmit()
>            {
>                setSelectedRecordA(new RecordA());
>                isNew = true;
>                editLegend = "New";
>                editGroup.setVisible(true);
>                selectGroup.setVisible(false);
>            }
>        };
>
>        selectForm.add(add);
>
>        edit = new Button("edit")
>        {
>            private static final long serialVersionUID = 1L;
>
>            public void onSubmit()
>            {
>                if (selectedRecordA == null)
>                {
>                    info("You must select a record to edit.");
>                }
>                else
>                {
>                    unmodifiedRecordA = selectedRecordA.getName();
>                    isNew = false;
>                    editLegend = "Edit";
>                    editGroup.setVisible(true);
>                    selectGroup.setVisible(false);
>                }
>            }
>        };
>
>        selectForm.add(edit);
>
>        delete = new Button("delete")
>        {
>            private static final long serialVersionUID = 1L;
>
>            public void onSubmit()
>            {
>                if (selectedRecordA == null)
>                {
>                    info("You must select a record to delete.");
>                }
>                else
>                {
>                    // Delete the selected record
>                    unmodifiedRecordA = selectedRecordA.getName();
>                    recordAService.delete(selectedRecordA.getName());
>                    selectedRecordA = null;
>                    info("Deleted '" + unmodifiedRecordA + "'");
>
>                    // Force refresh of records list
>                    RecordAPanel.this.recordAsModel.detach();
>                }
>            }
>        };
>
>        // Add confirmation dialog box
>        delete.add(new SimpleAttributeModifier("onclick",
>                "if (!confirm('Please confirm you want to delete this
> record') ){ return false; }"));
>
>        selectForm.add(delete);
>        selectGroup.add(selectForm);
>
>        this.add(selectGroup);
>
>        // ************* Edit Group *************
>
>        editGroup = new WebMarkupContainer("editGroup");
>
>        editLegendLabel = new Label("editLegend", new PropertyModel(this,
>                "editLegend"));
>
>        editGroup.add(editLegendLabel);
>
>        editForm = new Form("editForm");
>
>        recordALabel = new Label("recordALabel", "Record A");
>        editForm.add(recordALabel);
>
>        recordBLabel = new Label("recordBLabel", "Record B");
>        editForm.add(recordBLabel);
>
>        recordAText = new RequiredTextField("recordAText",
>                new PropertyModel(selectedRecordAModel, "name"));
>
>        editForm.add(recordAText);
>
>        recordBs = new DropDownChoice<RecordB>("recordBs");
>        recordBs.setModel(new PropertyModel(selectedRecordAModel,
> "recordB"));
>        recordBs.setChoices(RecordAPanel.this.getRecordBs());
>        recordBs.setChoiceRenderer(new RecordBRenderer());
>
>        editForm.add(recordBs);
>
>        save = new Button("save")
>        {
>            private static final long serialVersionUID = 1L;
>
>            @Override
>            public void onSubmit()
>            {
>                if (isNew)
>                {
>
> recordAService.create(RecordAPanel.this.selectedRecordA);
>                        info("Created '"
>                                +
> RecordAPanel.this.selectedRecordA.getName()
>                                + "'");
>                }
>                else
>                {
>                        recordAService.update(unmodifiedRecordA,
>                                RecordAPanel.this.selectedRecordA);
>                        info("Updated '"
>                                +
> RecordAPanel.this.selectedRecordA.getName()
>                                + "'");
>                }
>
>                // TODO Update the dropdown list?
>
>                editGroup.setVisible(false);
>                selectGroup.setVisible(true);
>            }
>        };
>
>        editForm.add(save);
>
>        cancel = new Button("cancel")
>        {
>            private static final long serialVersionUID = 1L;
>
>            public void onSubmit()
>            {
>                RecordAPanel.this.selectedRecordA = null;
>                editGroup.setVisible(false);
>                selectGroup.setVisible(true);
>            }
>        };
>
>        cancel.setDefaultFormProcessing(false);
>        editForm.add(cancel);
>
>        editGroup.add(editForm);
>
>        editGroup.setVisible(false);
>        this.add(editGroup);
>    }
>
>    public RecordA getSelectedRecordA()
>    {
>        return selectedRecordA;
>    }
>
>    public void setSelectedRecordA(RecordA selectedRecordA)
>    {
>        this.selectedRecordA = selectedRecordA;
>    }
>
>    public LoadableDetachableModel<List<RecordA>> recordAsModel = new
> LoadableDetachableModel<List<RecordA>>()
>    {
>        private static final long serialVersionUID = 1L;
>
>        @Override
>        protected List<RecordA> load()
>        {
>            return recordAService.getList();
>        }
>
>        public void detach()
>        {
>            super.detach();
>        }
>    };
>
>    // TODO change this to LDM?
>    List<RecordB> getRecordBs()
>    {
>        return recordBService.getList();
>    }
>
>    class RecordARenderer implements IChoiceRenderer<RecordA>
>    {
>        private static final long serialVersionUID = 1L;
>
>        public Object getDisplayValue(RecordA recordA)
>        {
>            return recordA.getName();
>        }
>
>        public String getIdValue(RecordA recordA, int index)
>        {
>            return recordA.getName();
>        }
>    }
>
>    class RecordBRenderer implements IChoiceRenderer<RecordB>
>    {
>        private static final long serialVersionUID = 1L;
>
>        public Object getDisplayValue(RecordB recordB)
>        {
>            return recordB.getName();
>        }
>
>        public String getIdValue(RecordB recordB, int index)
>        {
>            return recordB.getName();
>        }
>    }
> }
>
> >
> > Shelli
> >
> > -----Original Message-----
> > From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
> > Sent: Tuesday, October 12, 2010 10:38 AM
> > To: users@wicket.apache.org
> > Subject: Re: PropertyModel Not Refreshing
> >
> > here are the tweaks you need to make this work:
> >
> > selectedRecordAModel = new PropertyModel<RecordA>(this,
> "selectedRecordA");
> >
> > recordAText = new RequiredTextField("recordAText",
> >                new PropertyModel(selectedRecordAModel, "name"));
> >
> >  recordBs.setModel(new PropertyModel(selectedRecordAModel, "recordB"));
> >
> > have fun
> >
> > -igor
> >
> > On Tue, Oct 12, 2010 at 9:03 AM, Shelli Orton <Sh...@sjrb.ca>
> wrote:
> >> I've been able to create a sample application that exhibits the
> >> same/similar problems to mine.  The sample makes use of an in-memory
> >> list for the data versus accessing a database and so there's some
> >> differences.  However, I believe the problems that this sample exhibits
> >> have the same root cause as my project (which I believe have something
> >> to do with how my models are set up...).
> >>
> >> Issues this sample exhibits:
> >>
> >> 1. Choose to edit an existing record, then cancel the edit.  Choose
> >> another/the same record to edit and the selected record is null (error
> >> message "You must select a record to edit" is displayed).  Must
> >> close/open session to reset.
> >>
> >> 2. Choose to edit an existing record and save the edit.  Choose
> >> another/the same record to edit and you get a NPE:
> >>
> >>    WicketMessage: Method onFormSubmitted of interface
> >> org.apache.wicket.markup.html.form.IFormSubmitListener targeted at
> >> component [MarkupContainer [Component id = selectForm]] threw an
> >> exception
> >>
> >>    Root cause:
> >>
> >>    java.lang.NullPointerException
> >>    at
> >> org.apache.wicket.markup.html.form.AbstractSingleSelectChoice.convertCho
> >> iceIdToChoice(AbstractSingleSelectChoice.java:247)
> >>
> >> 3. Create a new record and try to save it and get
> >> WicketRuntimeException:
> >>
> >>    WicketMessage: Attempted to set property value on a null object.
> >> Property expression: name Value: New One
> >>
> >>    Root cause:
> >>
> >>    org.apache.wicket.WicketRuntimeException: Attempted to set property
> >> value on a null object. Property expression: name Value: New One
> >>    at
> >> org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.j
> >> ava:125)
> >>
> >> 4. Create a new record and then cancel the add, Choose an existing
> >> record to edit and the selected record is null (error message "You must
> >> select a record to edit" is displayed).  Must close/open session to
> >> reset.
> >>
> >> As always, all help is greatly appreciated as I am stumped.
> >>
> >> Thanks,
> >> Shelli
> >>
> >> -----Original Message-----
> >> From: jcgarciam [mailto:jcgarciam@gmail.com]
> >> Sent: Friday, October 08, 2010 1:41 PM
> >> To: users@wicket.apache.org
> >> Subject: Re: PropertyModel Not Refreshing
> >>
> >>
> >> The attachment didn't make it,
> >>
> >> Can you try to extract out the relevant part and creates a quickstart
> >> project that actually reproduces your issue?
> >>
> >>
> >> On Fri, Oct 8, 2010 at 1:41 PM, Shelli Orton [via Apache Wicket] <
> >> ml-node+2968688-305091622-65838@n4.nabble.com<ml...@n4.nabble.com>
> <ml-node%2B2968688-30509162
> >> 2-65838@n4.nabble.com>
> >>> wrote:
> >>
> >>> Hi,
> >>>
> >>> I have been trying different things to see if I could get my code to
> >> work
> >>> (and understand Wicket models better), but am still stuck.  I have a
> >>> attached the (latest) panel class code which I hope is sufficient to
> >> help.
> >>>
> >>> I was reading about different models (both online and the Wicket in
> >> Action
> >>> book) and thought that perhaps using a CompoundPropertyModel was more
> >>> appropriate and may help with my issues.  Originally, I only declared
> >>> selectedRecordA (line 40) but didn't instantiate it.  The select group
> >>> displayed properly but when I chose a record from the list and tried
> >> to edit
> >>> it, this exception was thrown:
> >>>
> >>>     WicketMessage: Attempted to set property value on a null object.
> >>> Property expression: recordA Value: Name=A-One
> >>>     Root cause:
> >>>
> >>>     org.apache.wicket.WicketRuntimeException: Attempted to set
> >> property
> >>> value on a null object. Property expression: recordA Value: Name=A-One
> >>>         at
> >>>
> >> org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.j
> >> ava:125)
> >>>
> >>>         at
> >>>
> >> org.apache.wicket.model.AbstractPropertyModel.setObject(AbstractProperty
> >> Model.java:169)
> >>>
> >>>         at
> >>> org.apache.wicket.Component.setDefaultModelObject(Component.java:3125)
> >>>         ....
> >>>
> >>> I set breakpoints on the getSelectedRecordA and setSelectedRecordA
> >> methods,
> >>> but these aren't called when during the request cycle when the edit
> >> button
> >>> is clicked.
> >>>
> >>> I then changed the class so that selectedRecordA is initialized to an
> >> empty
> >>> instance of RecordA. This got rid of the above error.  However, I
> >> cannot
> >>> save the edit changes because the selectedRecordA is still the empty
> >>> instance that was created in the initialization and the persistence
> >> layer
> >>> throws an exception.  This same problem exists if I try to add a new
> >> RecordA
> >>> or try to delete an existing one.
> >>>
> >>> If I choose to cancel the edit and then select another record to edit,
> >> I
> >>> get the message "You must select a record to edit" (line 131).  This
> >> is
> >>> because the cancel onSubmit sets selectedRecordA to null and choosing
> >> the
> >>> record from the DDC is not setting it to the chosen record.
> >>>
> >>> Clearly I am not setting up this CompoundPropertyModel properly so
> >> that the
> >>> selectedARecord is set by the model.  Can someone tell me what I'm
> >> doing
> >>> wrong?
> >>>
> >>> All help is greatly appreciated,
> >>>
> >>> Shelli
> >>>
> >>>
> >>> -----Original Message-----
> >>> From: Igor Vaynberg [mailto:[hidden
> >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=0>]
> >>>
> >>> Sent: Thursday, October 07, 2010 11:27 AM
> >>> To: [hidden email]
> >> <http://user/SendEmail.jtp?type=node&node=2968688&i=1>
> >>> Subject: Re: PropertyModel Not Refreshing
> >>>
> >>> you have posted an incomplete piece of code and somehow from that we
> >>> are supposed to guess what is not working? create a quickstart and
> >>> provide that.
> >>>
> >>> -igor
> >>>
> >>> On Thu, Oct 7, 2010 at 10:15 AM, Shelli Orton <[hidden
> >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=2>>
> >>> wrote:
> >>>
> >>> > Does nobody have any suggestions?  If I can't get this fixed, I'm
> >> going
> >>> > to have to write the app in another framework (possibly GWT) and I'd
> >>> > really rather not have to do that.
> >>> >
> >>> > Shelli
> >>> >
> >>> > -----Original Message-----
> >>> > From: Shelli Orton
> >>> > Sent: Wednesday, October 06, 2010 3:52 PM
> >>> > To: [hidden
> >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=3>
> >>> > Subject: PropertyModel Not Refreshing
> >>> >
> >>> > Hi,
> >>> >
> >>> > First, thanks to all who have been helping me as I am new to Wicket.
> >> I
> >>> > am splitting out two issues I am dealing with to try to keep things
> >>> > clear.
> >>> >
> >>> > I am trying to write a simple app that does CRUD operations on
> >> database
> >>> > records.  The goal is for the app to make use of a tab panel where
> >> each
> >>> > tab encapsulates one table from the database.  Each tab panel has
> >> two
> >>> > groups (WebMarkupContainer).  The first, selectGroup, displays a
> >> list
> >>> > (DDC) of the current items, and three buttons, add, edit and delete.
> >>> > The second, editGroup, is displayed when either the add or edit
> >> button
> >>> > was clicked on the select group, displays the record attributes and
> >> save
> >>> > and cancel buttons.  The tab panel has a "selectedRecord" which is
> >> used
> >>> > by both groups' components via PropertyModels. Very basic stuff.
> >>> >
> >>> > When I choose a record and click the edit button, the record is
> >>> > displayed in the edit group properly.  If I then choose cancel, the
> >> edit
> >>> > group is no longer displayed and the select group DDC selection is
> >> null
> >>> > as expected. I then choose another record from the list and click
> >> the
> >>> > edit button and the previous record information is displayed in the
> >> edit
> >>> > group even though the select group DDC shows the correct/selected
> >>> > record.
> >>> >
> >>> > This problem also occurs if I first choose to add a new record and
> >> then
> >>> > cancel the add and then choose to edit a different record.  The DDC
> >>> > shows the correct/selected record, but all the attributes in the
> >> edit
> >>> > group are null/defaults for a new record.
> >>> >
> >>> > If I remove the call to setDefaultFormProcessing(false) on the
> >> cancel
> >>> > button, selecting other records for edit works correctly, but I
> >> can't
> >>> > cancel a creating a new record if I use a RequiredTextField because
> >> the
> >>> > form validation fails.
> >>> >
> >>> > If I select a record for editing or save the newly created record, I
> >> can
> >>> > select a different record for edit or create another one correctly.
> >> So
> >>> > I must be doing something wrong in the cancel logic. My editForm
> >>> > (created in the EditGroup constructor) looks like this:
> >>> >
> >>> >            Form editForm = new Form("editForm");
> >>> >
> >>> >            editForm.add(new Label("nameLabel", "Name"));
> >>> >
> >>> >            editForm.add(new Label("attributeLabel", "Attribute"));
> >>> >
> >>> >            editForm.add(new
> >> RequiredTextField<String>("recordNameText",
> >>> >                    new PropertyModel<String>(MyRecordPanel.this,
> >>> >                            "selectedRecord.name")));
> >>> >
> >>> >            editForm.add(new DropDownChoice<Lir>("attributes",
> >>> >                    new PropertyModel<Attribute>(MyRecordPanel.this,
> >>> >                            "selectedRecord.attribute"),
> >>> >                    RateCentrePanel.this.getAttributes(),
> >>> >                    new AttributeRenderer()));
> >>> >
> >>> >            ....
> >>> >
> >>> >            editForm.add(new Button("cancel")
> >>> >            {
> >>> >                private static final long serialVersionUID = 1L;
> >>> >
> >>> >                public void onSubmit()
> >>> >                {
> >>> >                    MyRecordPanel.this.selectedRecord = null;
> >>> >                    editGroup.setVisible(false);
> >>> >                    selectGroup.setVisible(true);
> >>> >                }
> >>> >            }.setDefaultFormProcessing(false));
> >>> >
> >>> >            add(editForm);
> >>> >
> >>> > Other than setting the selectedRecord to null, what should I be
> >> doing
> >>> > differently?
> >>> >
> >>> > Thanks in advance!
> >>> >
> >>> > Shelli
> >>> >
> >>> >
> >> ---------------------------------------------------------------------
> >>> > To unsubscribe, e-mail: [hidden
> >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=4>
> >>> > For additional commands, e-mail: [hidden
> >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=5>
> >>> >
> >>> >
> >>> >
> >> ---------------------------------------------------------------------
> >>> > To unsubscribe, e-mail: [hidden
> >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=6>
> >>> > For additional commands, e-mail: [hidden
> >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=7>
> >>> >
> >>> >
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: [hidden
> >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=8>
> >>> For additional commands, e-mail: [hidden
> >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=9>
> >>>
> >>>
> >>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: [hidden
> >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=10>
> >>> For additional commands, e-mail: [hidden
> >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=11>
> >>>
> >>> ------------------------------
> >>>  View message @
> >>>
> >>
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
> >> n-tp2955144p2968688.html
> >>> To start a new topic under Apache Wicket, email
> >>>
> >> ml-node+1842946-398011874-65838@n4.nabble.com<ml...@n4.nabble.com>
> <ml-node%2B1842946-39801187
> >> 4-65838@n4.nabble.com>
> >>> To unsubscribe from Apache Wicket, click
> >> here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp
> ?
> >> tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
> >> QyOTQ2fDEyNTYxMzc3ODY=>.
> >>>
> >>>
> >>>
> >>
> >>
> >> --
> >> Sincerely,
> >> JC (http://www.linkedin.com/in/jcgarciam)
> >> Work smarter, not harder!.
> >>
> >> --
> >> View this message in context:
> >>
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
> >> n-tp2955144p2968936.html
> >> Sent from the Users forum mailing list archive at Nabble.com.
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

RE: PropertyModel Not Refreshing

Posted by Shelli Orton <Sh...@sjrb.ca>.
Hi,

Thanks for file.  Your first email was missing these changes: 

    IModel<RecordA> selectedRecordAModel;  (I had set mine to PropertyModel<RecordA> selectedRecordAModel;)
    recordAs.setModel(selectedRecordAModel)

However, even with those changes applied, I still get the same issue of the selected record not updating in the edit group.  

I am deploying in Glassfish v3.  Could that have anything to do with my problems?

Shelli

-----Original Message-----
From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com] 
Sent: Tuesday, October 12, 2010 11:35 AM
To: users@wicket.apache.org
Subject: Re: PropertyModel Not Refreshing

On Tue, Oct 12, 2010 at 10:30 AM, Shelli Orton <Sh...@sjrb.ca> wrote:
> Thanks for the help.  Your changes got rid of the errors and I can delete records now (and the list is updated).
>
> However, once a record has been selected for edit and either saved or cancelled, that same record is always displayed in the edit group when I choose another record to edit or even when I try to create a new one.  I can even delete the chosen record and it still displays in the edit group.

works fine here, meaning you did not completely/propery apply my
changes. below is the complete file.

-igor

public class RecordAPanel extends Panel
{
    private static final long serialVersionUID = 1L;

    RecordAService recordAService;
    RecordBService recordBService;

    RecordA selectedRecordA = new RecordA();
    IModel<RecordA> selectedRecordAModel;
    String unmodifiedRecordA;

    boolean isNew = false;

    WebMarkupContainer selectGroup;
    WebMarkupContainer editGroup;

    Form selectForm;
    Form editForm;

    DropDownChoice<RecordA> recordAs;
    DropDownChoice<RecordB> recordBs;

    Button add;
    Button edit;
    Button save;
    Button delete;
    Button cancel;

    Label editLegendLabel;
    String editLegend;
    Label recordALabel;
    Label recordBLabel;

    RequiredTextField recordAText;

    @SuppressWarnings({ "rawtypes", "unchecked" })
    public RecordAPanel(String id)
    {
        super(id);

        recordAService = ((Application)
RequestCycle.get().getApplication()).getRecordAService();
        recordBService = ((Application)
RequestCycle.get().getApplication()).getRecordBService();

        selectedRecordAModel = new PropertyModel<RecordA>(this,
"selectedRecordA");
        this.setDefaultModel(selectedRecordAModel);

        // ************* Select  Group *************

        selectGroup = new WebMarkupContainer("selectGroup");
        selectForm = new Form("selectForm");

        recordAs = new DropDownChoice<RecordA>("recordAs");
        recordAs.setModel(selectedRecordAModel);
        recordAs.setChoices(recordAsModel);
        recordAs.setChoiceRenderer(new RecordARenderer());

        //            recordAs = (DropDownChoice<RecordA>) new
DropDownChoice<RecordA>("recordAs",
        //                    new PropertyModel<RecordA>(this,
"selectedRecordA"),
        //                    recordAsModel,
        //                    new RecordARenderer());

        recordAs.setNullValid(false);

        selectForm.add(recordAs);

        add = new Button("add")
        {
            private static final long serialVersionUID = 1L;

            public void onSubmit()
            {
                setSelectedRecordA(new RecordA());
                isNew = true;
                editLegend = "New";
                editGroup.setVisible(true);
                selectGroup.setVisible(false);
            }
        };

        selectForm.add(add);

        edit = new Button("edit")
        {
            private static final long serialVersionUID = 1L;

            public void onSubmit()
            {
                if (selectedRecordA == null)
                {
                    info("You must select a record to edit.");
                }
                else
                {
                    unmodifiedRecordA = selectedRecordA.getName();
                    isNew = false;
                    editLegend = "Edit";
                    editGroup.setVisible(true);
                    selectGroup.setVisible(false);
                }
            }
        };

        selectForm.add(edit);

        delete = new Button("delete")
        {
            private static final long serialVersionUID = 1L;

            public void onSubmit()
            {
                if (selectedRecordA == null)
                {
                    info("You must select a record to delete.");
                }
                else
                {
                    // Delete the selected record
                    unmodifiedRecordA = selectedRecordA.getName();
                    recordAService.delete(selectedRecordA.getName());
                    selectedRecordA = null;
                    info("Deleted '" + unmodifiedRecordA + "'");

                    // Force refresh of records list
                    RecordAPanel.this.recordAsModel.detach();
                }
            }
        };

        // Add confirmation dialog box
        delete.add(new SimpleAttributeModifier("onclick",
                "if (!confirm('Please confirm you want to delete this
record') ){ return false; }"));

        selectForm.add(delete);
        selectGroup.add(selectForm);

        this.add(selectGroup);

        // ************* Edit Group *************

        editGroup = new WebMarkupContainer("editGroup");

        editLegendLabel = new Label("editLegend", new PropertyModel(this,
                "editLegend"));

        editGroup.add(editLegendLabel);

        editForm = new Form("editForm");

        recordALabel = new Label("recordALabel", "Record A");
        editForm.add(recordALabel);

        recordBLabel = new Label("recordBLabel", "Record B");
        editForm.add(recordBLabel);

        recordAText = new RequiredTextField("recordAText",
                new PropertyModel(selectedRecordAModel, "name"));

        editForm.add(recordAText);

        recordBs = new DropDownChoice<RecordB>("recordBs");
        recordBs.setModel(new PropertyModel(selectedRecordAModel, "recordB"));
        recordBs.setChoices(RecordAPanel.this.getRecordBs());
        recordBs.setChoiceRenderer(new RecordBRenderer());

        editForm.add(recordBs);

        save = new Button("save")
        {
            private static final long serialVersionUID = 1L;

            @Override
            public void onSubmit()
            {
                if (isNew)
                {

recordAService.create(RecordAPanel.this.selectedRecordA);
                        info("Created '"
                                + RecordAPanel.this.selectedRecordA.getName()
                                + "'");
                }
                else
                {
                        recordAService.update(unmodifiedRecordA,
                                RecordAPanel.this.selectedRecordA);
                        info("Updated '"
                                + RecordAPanel.this.selectedRecordA.getName()
                                + "'");
                }

                // TODO Update the dropdown list?

                editGroup.setVisible(false);
                selectGroup.setVisible(true);
            }
        };

        editForm.add(save);

        cancel = new Button("cancel")
        {
            private static final long serialVersionUID = 1L;

            public void onSubmit()
            {
                RecordAPanel.this.selectedRecordA = null;
                editGroup.setVisible(false);
                selectGroup.setVisible(true);
            }
        };

        cancel.setDefaultFormProcessing(false);
        editForm.add(cancel);

        editGroup.add(editForm);

        editGroup.setVisible(false);
        this.add(editGroup);
    }

    public RecordA getSelectedRecordA()
    {
        return selectedRecordA;
    }

    public void setSelectedRecordA(RecordA selectedRecordA)
    {
        this.selectedRecordA = selectedRecordA;
    }

    public LoadableDetachableModel<List<RecordA>> recordAsModel = new
LoadableDetachableModel<List<RecordA>>()
    {
        private static final long serialVersionUID = 1L;

        @Override
        protected List<RecordA> load()
        {
            return recordAService.getList();
        }

        public void detach()
        {
            super.detach();
        }
    };

    // TODO change this to LDM?
    List<RecordB> getRecordBs()
    {
        return recordBService.getList();
    }

    class RecordARenderer implements IChoiceRenderer<RecordA>
    {
        private static final long serialVersionUID = 1L;

        public Object getDisplayValue(RecordA recordA)
        {
            return recordA.getName();
        }

        public String getIdValue(RecordA recordA, int index)
        {
            return recordA.getName();
        }
    }

    class RecordBRenderer implements IChoiceRenderer<RecordB>
    {
        private static final long serialVersionUID = 1L;

        public Object getDisplayValue(RecordB recordB)
        {
            return recordB.getName();
        }

        public String getIdValue(RecordB recordB, int index)
        {
            return recordB.getName();
        }
    }
}

>
> Shelli
>
> -----Original Message-----
> From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
> Sent: Tuesday, October 12, 2010 10:38 AM
> To: users@wicket.apache.org
> Subject: Re: PropertyModel Not Refreshing
>
> here are the tweaks you need to make this work:
>
> selectedRecordAModel = new PropertyModel<RecordA>(this, "selectedRecordA");
>
> recordAText = new RequiredTextField("recordAText",
>                new PropertyModel(selectedRecordAModel, "name"));
>
>  recordBs.setModel(new PropertyModel(selectedRecordAModel, "recordB"));
>
> have fun
>
> -igor
>
> On Tue, Oct 12, 2010 at 9:03 AM, Shelli Orton <Sh...@sjrb.ca> wrote:
>> I've been able to create a sample application that exhibits the
>> same/similar problems to mine.  The sample makes use of an in-memory
>> list for the data versus accessing a database and so there's some
>> differences.  However, I believe the problems that this sample exhibits
>> have the same root cause as my project (which I believe have something
>> to do with how my models are set up...).
>>
>> Issues this sample exhibits:
>>
>> 1. Choose to edit an existing record, then cancel the edit.  Choose
>> another/the same record to edit and the selected record is null (error
>> message "You must select a record to edit" is displayed).  Must
>> close/open session to reset.
>>
>> 2. Choose to edit an existing record and save the edit.  Choose
>> another/the same record to edit and you get a NPE:
>>
>>    WicketMessage: Method onFormSubmitted of interface
>> org.apache.wicket.markup.html.form.IFormSubmitListener targeted at
>> component [MarkupContainer [Component id = selectForm]] threw an
>> exception
>>
>>    Root cause:
>>
>>    java.lang.NullPointerException
>>    at
>> org.apache.wicket.markup.html.form.AbstractSingleSelectChoice.convertCho
>> iceIdToChoice(AbstractSingleSelectChoice.java:247)
>>
>> 3. Create a new record and try to save it and get
>> WicketRuntimeException:
>>
>>    WicketMessage: Attempted to set property value on a null object.
>> Property expression: name Value: New One
>>
>>    Root cause:
>>
>>    org.apache.wicket.WicketRuntimeException: Attempted to set property
>> value on a null object. Property expression: name Value: New One
>>    at
>> org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.j
>> ava:125)
>>
>> 4. Create a new record and then cancel the add, Choose an existing
>> record to edit and the selected record is null (error message "You must
>> select a record to edit" is displayed).  Must close/open session to
>> reset.
>>
>> As always, all help is greatly appreciated as I am stumped.
>>
>> Thanks,
>> Shelli
>>
>> -----Original Message-----
>> From: jcgarciam [mailto:jcgarciam@gmail.com]
>> Sent: Friday, October 08, 2010 1:41 PM
>> To: users@wicket.apache.org
>> Subject: Re: PropertyModel Not Refreshing
>>
>>
>> The attachment didn't make it,
>>
>> Can you try to extract out the relevant part and creates a quickstart
>> project that actually reproduces your issue?
>>
>>
>> On Fri, Oct 8, 2010 at 1:41 PM, Shelli Orton [via Apache Wicket] <
>> ml-node+2968688-305091622-65838@n4.nabble.com<ml-node%2B2968688-30509162
>> 2-65838@n4.nabble.com>
>>> wrote:
>>
>>> Hi,
>>>
>>> I have been trying different things to see if I could get my code to
>> work
>>> (and understand Wicket models better), but am still stuck.  I have a
>>> attached the (latest) panel class code which I hope is sufficient to
>> help.
>>>
>>> I was reading about different models (both online and the Wicket in
>> Action
>>> book) and thought that perhaps using a CompoundPropertyModel was more
>>> appropriate and may help with my issues.  Originally, I only declared
>>> selectedRecordA (line 40) but didn't instantiate it.  The select group
>>> displayed properly but when I chose a record from the list and tried
>> to edit
>>> it, this exception was thrown:
>>>
>>>     WicketMessage: Attempted to set property value on a null object.
>>> Property expression: recordA Value: Name=A-One
>>>     Root cause:
>>>
>>>     org.apache.wicket.WicketRuntimeException: Attempted to set
>> property
>>> value on a null object. Property expression: recordA Value: Name=A-One
>>>         at
>>>
>> org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.j
>> ava:125)
>>>
>>>         at
>>>
>> org.apache.wicket.model.AbstractPropertyModel.setObject(AbstractProperty
>> Model.java:169)
>>>
>>>         at
>>> org.apache.wicket.Component.setDefaultModelObject(Component.java:3125)
>>>         ....
>>>
>>> I set breakpoints on the getSelectedRecordA and setSelectedRecordA
>> methods,
>>> but these aren't called when during the request cycle when the edit
>> button
>>> is clicked.
>>>
>>> I then changed the class so that selectedRecordA is initialized to an
>> empty
>>> instance of RecordA. This got rid of the above error.  However, I
>> cannot
>>> save the edit changes because the selectedRecordA is still the empty
>>> instance that was created in the initialization and the persistence
>> layer
>>> throws an exception.  This same problem exists if I try to add a new
>> RecordA
>>> or try to delete an existing one.
>>>
>>> If I choose to cancel the edit and then select another record to edit,
>> I
>>> get the message "You must select a record to edit" (line 131).  This
>> is
>>> because the cancel onSubmit sets selectedRecordA to null and choosing
>> the
>>> record from the DDC is not setting it to the chosen record.
>>>
>>> Clearly I am not setting up this CompoundPropertyModel properly so
>> that the
>>> selectedARecord is set by the model.  Can someone tell me what I'm
>> doing
>>> wrong?
>>>
>>> All help is greatly appreciated,
>>>
>>> Shelli
>>>
>>>
>>> -----Original Message-----
>>> From: Igor Vaynberg [mailto:[hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=0>]
>>>
>>> Sent: Thursday, October 07, 2010 11:27 AM
>>> To: [hidden email]
>> <http://user/SendEmail.jtp?type=node&node=2968688&i=1>
>>> Subject: Re: PropertyModel Not Refreshing
>>>
>>> you have posted an incomplete piece of code and somehow from that we
>>> are supposed to guess what is not working? create a quickstart and
>>> provide that.
>>>
>>> -igor
>>>
>>> On Thu, Oct 7, 2010 at 10:15 AM, Shelli Orton <[hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=2>>
>>> wrote:
>>>
>>> > Does nobody have any suggestions?  If I can't get this fixed, I'm
>> going
>>> > to have to write the app in another framework (possibly GWT) and I'd
>>> > really rather not have to do that.
>>> >
>>> > Shelli
>>> >
>>> > -----Original Message-----
>>> > From: Shelli Orton
>>> > Sent: Wednesday, October 06, 2010 3:52 PM
>>> > To: [hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=3>
>>> > Subject: PropertyModel Not Refreshing
>>> >
>>> > Hi,
>>> >
>>> > First, thanks to all who have been helping me as I am new to Wicket.
>> I
>>> > am splitting out two issues I am dealing with to try to keep things
>>> > clear.
>>> >
>>> > I am trying to write a simple app that does CRUD operations on
>> database
>>> > records.  The goal is for the app to make use of a tab panel where
>> each
>>> > tab encapsulates one table from the database.  Each tab panel has
>> two
>>> > groups (WebMarkupContainer).  The first, selectGroup, displays a
>> list
>>> > (DDC) of the current items, and three buttons, add, edit and delete.
>>> > The second, editGroup, is displayed when either the add or edit
>> button
>>> > was clicked on the select group, displays the record attributes and
>> save
>>> > and cancel buttons.  The tab panel has a "selectedRecord" which is
>> used
>>> > by both groups' components via PropertyModels. Very basic stuff.
>>> >
>>> > When I choose a record and click the edit button, the record is
>>> > displayed in the edit group properly.  If I then choose cancel, the
>> edit
>>> > group is no longer displayed and the select group DDC selection is
>> null
>>> > as expected. I then choose another record from the list and click
>> the
>>> > edit button and the previous record information is displayed in the
>> edit
>>> > group even though the select group DDC shows the correct/selected
>>> > record.
>>> >
>>> > This problem also occurs if I first choose to add a new record and
>> then
>>> > cancel the add and then choose to edit a different record.  The DDC
>>> > shows the correct/selected record, but all the attributes in the
>> edit
>>> > group are null/defaults for a new record.
>>> >
>>> > If I remove the call to setDefaultFormProcessing(false) on the
>> cancel
>>> > button, selecting other records for edit works correctly, but I
>> can't
>>> > cancel a creating a new record if I use a RequiredTextField because
>> the
>>> > form validation fails.
>>> >
>>> > If I select a record for editing or save the newly created record, I
>> can
>>> > select a different record for edit or create another one correctly.
>> So
>>> > I must be doing something wrong in the cancel logic. My editForm
>>> > (created in the EditGroup constructor) looks like this:
>>> >
>>> >            Form editForm = new Form("editForm");
>>> >
>>> >            editForm.add(new Label("nameLabel", "Name"));
>>> >
>>> >            editForm.add(new Label("attributeLabel", "Attribute"));
>>> >
>>> >            editForm.add(new
>> RequiredTextField<String>("recordNameText",
>>> >                    new PropertyModel<String>(MyRecordPanel.this,
>>> >                            "selectedRecord.name")));
>>> >
>>> >            editForm.add(new DropDownChoice<Lir>("attributes",
>>> >                    new PropertyModel<Attribute>(MyRecordPanel.this,
>>> >                            "selectedRecord.attribute"),
>>> >                    RateCentrePanel.this.getAttributes(),
>>> >                    new AttributeRenderer()));
>>> >
>>> >            ....
>>> >
>>> >            editForm.add(new Button("cancel")
>>> >            {
>>> >                private static final long serialVersionUID = 1L;
>>> >
>>> >                public void onSubmit()
>>> >                {
>>> >                    MyRecordPanel.this.selectedRecord = null;
>>> >                    editGroup.setVisible(false);
>>> >                    selectGroup.setVisible(true);
>>> >                }
>>> >            }.setDefaultFormProcessing(false));
>>> >
>>> >            add(editForm);
>>> >
>>> > Other than setting the selectedRecord to null, what should I be
>> doing
>>> > differently?
>>> >
>>> > Thanks in advance!
>>> >
>>> > Shelli
>>> >
>>> >
>> ---------------------------------------------------------------------
>>> > To unsubscribe, e-mail: [hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=4>
>>> > For additional commands, e-mail: [hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=5>
>>> >
>>> >
>>> >
>> ---------------------------------------------------------------------
>>> > To unsubscribe, e-mail: [hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=6>
>>> > For additional commands, e-mail: [hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=7>
>>> >
>>> >
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=8>
>>> For additional commands, e-mail: [hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=9>
>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=10>
>>> For additional commands, e-mail: [hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=11>
>>>
>>> ------------------------------
>>>  View message @
>>>
>> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
>> n-tp2955144p2968688.html
>>> To start a new topic under Apache Wicket, email
>>>
>> ml-node+1842946-398011874-65838@n4.nabble.com<ml-node%2B1842946-39801187
>> 4-65838@n4.nabble.com>
>>> To unsubscribe from Apache Wicket, click
>> here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?
>> tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
>> QyOTQ2fDEyNTYxMzc3ODY=>.
>>>
>>>
>>>
>>
>>
>> --
>> Sincerely,
>> JC (http://www.linkedin.com/in/jcgarciam)
>> Work smarter, not harder!.
>>
>> --
>> View this message in context:
>> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
>> n-tp2955144p2968936.html
>> Sent from the Users forum mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


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


Re: PropertyModel Not Refreshing

Posted by Igor Vaynberg <ig...@gmail.com>.
On Tue, Oct 12, 2010 at 10:30 AM, Shelli Orton <Sh...@sjrb.ca> wrote:
> Thanks for the help.  Your changes got rid of the errors and I can delete records now (and the list is updated).
>
> However, once a record has been selected for edit and either saved or cancelled, that same record is always displayed in the edit group when I choose another record to edit or even when I try to create a new one.  I can even delete the chosen record and it still displays in the edit group.

works fine here, meaning you did not completely/propery apply my
changes. below is the complete file.

-igor

public class RecordAPanel extends Panel
{
    private static final long serialVersionUID = 1L;

    RecordAService recordAService;
    RecordBService recordBService;

    RecordA selectedRecordA = new RecordA();
    IModel<RecordA> selectedRecordAModel;
    String unmodifiedRecordA;

    boolean isNew = false;

    WebMarkupContainer selectGroup;
    WebMarkupContainer editGroup;

    Form selectForm;
    Form editForm;

    DropDownChoice<RecordA> recordAs;
    DropDownChoice<RecordB> recordBs;

    Button add;
    Button edit;
    Button save;
    Button delete;
    Button cancel;

    Label editLegendLabel;
    String editLegend;
    Label recordALabel;
    Label recordBLabel;

    RequiredTextField recordAText;

    @SuppressWarnings({ "rawtypes", "unchecked" })
    public RecordAPanel(String id)
    {
        super(id);

        recordAService = ((Application)
RequestCycle.get().getApplication()).getRecordAService();
        recordBService = ((Application)
RequestCycle.get().getApplication()).getRecordBService();

        selectedRecordAModel = new PropertyModel<RecordA>(this,
"selectedRecordA");
        this.setDefaultModel(selectedRecordAModel);

        // ************* Select  Group *************

        selectGroup = new WebMarkupContainer("selectGroup");
        selectForm = new Form("selectForm");

        recordAs = new DropDownChoice<RecordA>("recordAs");
        recordAs.setModel(selectedRecordAModel);
        recordAs.setChoices(recordAsModel);
        recordAs.setChoiceRenderer(new RecordARenderer());

        //            recordAs = (DropDownChoice<RecordA>) new
DropDownChoice<RecordA>("recordAs",
        //                    new PropertyModel<RecordA>(this,
"selectedRecordA"),
        //                    recordAsModel,
        //                    new RecordARenderer());

        recordAs.setNullValid(false);

        selectForm.add(recordAs);

        add = new Button("add")
        {
            private static final long serialVersionUID = 1L;

            public void onSubmit()
            {
                setSelectedRecordA(new RecordA());
                isNew = true;
                editLegend = "New";
                editGroup.setVisible(true);
                selectGroup.setVisible(false);
            }
        };

        selectForm.add(add);

        edit = new Button("edit")
        {
            private static final long serialVersionUID = 1L;

            public void onSubmit()
            {
                if (selectedRecordA == null)
                {
                    info("You must select a record to edit.");
                }
                else
                {
                    unmodifiedRecordA = selectedRecordA.getName();
                    isNew = false;
                    editLegend = "Edit";
                    editGroup.setVisible(true);
                    selectGroup.setVisible(false);
                }
            }
        };

        selectForm.add(edit);

        delete = new Button("delete")
        {
            private static final long serialVersionUID = 1L;

            public void onSubmit()
            {
                if (selectedRecordA == null)
                {
                    info("You must select a record to delete.");
                }
                else
                {
                    // Delete the selected record
                    unmodifiedRecordA = selectedRecordA.getName();
                    recordAService.delete(selectedRecordA.getName());
                    selectedRecordA = null;
                    info("Deleted '" + unmodifiedRecordA + "'");

                    // Force refresh of records list
                    RecordAPanel.this.recordAsModel.detach();
                }
            }
        };

        // Add confirmation dialog box
        delete.add(new SimpleAttributeModifier("onclick",
                "if (!confirm('Please confirm you want to delete this
record') ){ return false; }"));

        selectForm.add(delete);
        selectGroup.add(selectForm);

        this.add(selectGroup);

        // ************* Edit Group *************

        editGroup = new WebMarkupContainer("editGroup");

        editLegendLabel = new Label("editLegend", new PropertyModel(this,
                "editLegend"));

        editGroup.add(editLegendLabel);

        editForm = new Form("editForm");

        recordALabel = new Label("recordALabel", "Record A");
        editForm.add(recordALabel);

        recordBLabel = new Label("recordBLabel", "Record B");
        editForm.add(recordBLabel);

        recordAText = new RequiredTextField("recordAText",
                new PropertyModel(selectedRecordAModel, "name"));

        editForm.add(recordAText);

        recordBs = new DropDownChoice<RecordB>("recordBs");
        recordBs.setModel(new PropertyModel(selectedRecordAModel, "recordB"));
        recordBs.setChoices(RecordAPanel.this.getRecordBs());
        recordBs.setChoiceRenderer(new RecordBRenderer());

        editForm.add(recordBs);

        save = new Button("save")
        {
            private static final long serialVersionUID = 1L;

            @Override
            public void onSubmit()
            {
                if (isNew)
                {

recordAService.create(RecordAPanel.this.selectedRecordA);
                        info("Created '"
                                + RecordAPanel.this.selectedRecordA.getName()
                                + "'");
                }
                else
                {
                        recordAService.update(unmodifiedRecordA,
                                RecordAPanel.this.selectedRecordA);
                        info("Updated '"
                                + RecordAPanel.this.selectedRecordA.getName()
                                + "'");
                }

                // TODO Update the dropdown list?

                editGroup.setVisible(false);
                selectGroup.setVisible(true);
            }
        };

        editForm.add(save);

        cancel = new Button("cancel")
        {
            private static final long serialVersionUID = 1L;

            public void onSubmit()
            {
                RecordAPanel.this.selectedRecordA = null;
                editGroup.setVisible(false);
                selectGroup.setVisible(true);
            }
        };

        cancel.setDefaultFormProcessing(false);
        editForm.add(cancel);

        editGroup.add(editForm);

        editGroup.setVisible(false);
        this.add(editGroup);
    }

    public RecordA getSelectedRecordA()
    {
        return selectedRecordA;
    }

    public void setSelectedRecordA(RecordA selectedRecordA)
    {
        this.selectedRecordA = selectedRecordA;
    }

    public LoadableDetachableModel<List<RecordA>> recordAsModel = new
LoadableDetachableModel<List<RecordA>>()
    {
        private static final long serialVersionUID = 1L;

        @Override
        protected List<RecordA> load()
        {
            return recordAService.getList();
        }

        public void detach()
        {
            super.detach();
        }
    };

    // TODO change this to LDM?
    List<RecordB> getRecordBs()
    {
        return recordBService.getList();
    }

    class RecordARenderer implements IChoiceRenderer<RecordA>
    {
        private static final long serialVersionUID = 1L;

        public Object getDisplayValue(RecordA recordA)
        {
            return recordA.getName();
        }

        public String getIdValue(RecordA recordA, int index)
        {
            return recordA.getName();
        }
    }

    class RecordBRenderer implements IChoiceRenderer<RecordB>
    {
        private static final long serialVersionUID = 1L;

        public Object getDisplayValue(RecordB recordB)
        {
            return recordB.getName();
        }

        public String getIdValue(RecordB recordB, int index)
        {
            return recordB.getName();
        }
    }
}

>
> Shelli
>
> -----Original Message-----
> From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
> Sent: Tuesday, October 12, 2010 10:38 AM
> To: users@wicket.apache.org
> Subject: Re: PropertyModel Not Refreshing
>
> here are the tweaks you need to make this work:
>
> selectedRecordAModel = new PropertyModel<RecordA>(this, "selectedRecordA");
>
> recordAText = new RequiredTextField("recordAText",
>                new PropertyModel(selectedRecordAModel, "name"));
>
>  recordBs.setModel(new PropertyModel(selectedRecordAModel, "recordB"));
>
> have fun
>
> -igor
>
> On Tue, Oct 12, 2010 at 9:03 AM, Shelli Orton <Sh...@sjrb.ca> wrote:
>> I've been able to create a sample application that exhibits the
>> same/similar problems to mine.  The sample makes use of an in-memory
>> list for the data versus accessing a database and so there's some
>> differences.  However, I believe the problems that this sample exhibits
>> have the same root cause as my project (which I believe have something
>> to do with how my models are set up...).
>>
>> Issues this sample exhibits:
>>
>> 1. Choose to edit an existing record, then cancel the edit.  Choose
>> another/the same record to edit and the selected record is null (error
>> message "You must select a record to edit" is displayed).  Must
>> close/open session to reset.
>>
>> 2. Choose to edit an existing record and save the edit.  Choose
>> another/the same record to edit and you get a NPE:
>>
>>    WicketMessage: Method onFormSubmitted of interface
>> org.apache.wicket.markup.html.form.IFormSubmitListener targeted at
>> component [MarkupContainer [Component id = selectForm]] threw an
>> exception
>>
>>    Root cause:
>>
>>    java.lang.NullPointerException
>>    at
>> org.apache.wicket.markup.html.form.AbstractSingleSelectChoice.convertCho
>> iceIdToChoice(AbstractSingleSelectChoice.java:247)
>>
>> 3. Create a new record and try to save it and get
>> WicketRuntimeException:
>>
>>    WicketMessage: Attempted to set property value on a null object.
>> Property expression: name Value: New One
>>
>>    Root cause:
>>
>>    org.apache.wicket.WicketRuntimeException: Attempted to set property
>> value on a null object. Property expression: name Value: New One
>>    at
>> org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.j
>> ava:125)
>>
>> 4. Create a new record and then cancel the add, Choose an existing
>> record to edit and the selected record is null (error message "You must
>> select a record to edit" is displayed).  Must close/open session to
>> reset.
>>
>> As always, all help is greatly appreciated as I am stumped.
>>
>> Thanks,
>> Shelli
>>
>> -----Original Message-----
>> From: jcgarciam [mailto:jcgarciam@gmail.com]
>> Sent: Friday, October 08, 2010 1:41 PM
>> To: users@wicket.apache.org
>> Subject: Re: PropertyModel Not Refreshing
>>
>>
>> The attachment didn't make it,
>>
>> Can you try to extract out the relevant part and creates a quickstart
>> project that actually reproduces your issue?
>>
>>
>> On Fri, Oct 8, 2010 at 1:41 PM, Shelli Orton [via Apache Wicket] <
>> ml-node+2968688-305091622-65838@n4.nabble.com<ml-node%2B2968688-30509162
>> 2-65838@n4.nabble.com>
>>> wrote:
>>
>>> Hi,
>>>
>>> I have been trying different things to see if I could get my code to
>> work
>>> (and understand Wicket models better), but am still stuck.  I have a
>>> attached the (latest) panel class code which I hope is sufficient to
>> help.
>>>
>>> I was reading about different models (both online and the Wicket in
>> Action
>>> book) and thought that perhaps using a CompoundPropertyModel was more
>>> appropriate and may help with my issues.  Originally, I only declared
>>> selectedRecordA (line 40) but didn't instantiate it.  The select group
>>> displayed properly but when I chose a record from the list and tried
>> to edit
>>> it, this exception was thrown:
>>>
>>>     WicketMessage: Attempted to set property value on a null object.
>>> Property expression: recordA Value: Name=A-One
>>>     Root cause:
>>>
>>>     org.apache.wicket.WicketRuntimeException: Attempted to set
>> property
>>> value on a null object. Property expression: recordA Value: Name=A-One
>>>         at
>>>
>> org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.j
>> ava:125)
>>>
>>>         at
>>>
>> org.apache.wicket.model.AbstractPropertyModel.setObject(AbstractProperty
>> Model.java:169)
>>>
>>>         at
>>> org.apache.wicket.Component.setDefaultModelObject(Component.java:3125)
>>>         ....
>>>
>>> I set breakpoints on the getSelectedRecordA and setSelectedRecordA
>> methods,
>>> but these aren't called when during the request cycle when the edit
>> button
>>> is clicked.
>>>
>>> I then changed the class so that selectedRecordA is initialized to an
>> empty
>>> instance of RecordA. This got rid of the above error.  However, I
>> cannot
>>> save the edit changes because the selectedRecordA is still the empty
>>> instance that was created in the initialization and the persistence
>> layer
>>> throws an exception.  This same problem exists if I try to add a new
>> RecordA
>>> or try to delete an existing one.
>>>
>>> If I choose to cancel the edit and then select another record to edit,
>> I
>>> get the message "You must select a record to edit" (line 131).  This
>> is
>>> because the cancel onSubmit sets selectedRecordA to null and choosing
>> the
>>> record from the DDC is not setting it to the chosen record.
>>>
>>> Clearly I am not setting up this CompoundPropertyModel properly so
>> that the
>>> selectedARecord is set by the model.  Can someone tell me what I'm
>> doing
>>> wrong?
>>>
>>> All help is greatly appreciated,
>>>
>>> Shelli
>>>
>>>
>>> -----Original Message-----
>>> From: Igor Vaynberg [mailto:[hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=0>]
>>>
>>> Sent: Thursday, October 07, 2010 11:27 AM
>>> To: [hidden email]
>> <http://user/SendEmail.jtp?type=node&node=2968688&i=1>
>>> Subject: Re: PropertyModel Not Refreshing
>>>
>>> you have posted an incomplete piece of code and somehow from that we
>>> are supposed to guess what is not working? create a quickstart and
>>> provide that.
>>>
>>> -igor
>>>
>>> On Thu, Oct 7, 2010 at 10:15 AM, Shelli Orton <[hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=2>>
>>> wrote:
>>>
>>> > Does nobody have any suggestions?  If I can't get this fixed, I'm
>> going
>>> > to have to write the app in another framework (possibly GWT) and I'd
>>> > really rather not have to do that.
>>> >
>>> > Shelli
>>> >
>>> > -----Original Message-----
>>> > From: Shelli Orton
>>> > Sent: Wednesday, October 06, 2010 3:52 PM
>>> > To: [hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=3>
>>> > Subject: PropertyModel Not Refreshing
>>> >
>>> > Hi,
>>> >
>>> > First, thanks to all who have been helping me as I am new to Wicket.
>> I
>>> > am splitting out two issues I am dealing with to try to keep things
>>> > clear.
>>> >
>>> > I am trying to write a simple app that does CRUD operations on
>> database
>>> > records.  The goal is for the app to make use of a tab panel where
>> each
>>> > tab encapsulates one table from the database.  Each tab panel has
>> two
>>> > groups (WebMarkupContainer).  The first, selectGroup, displays a
>> list
>>> > (DDC) of the current items, and three buttons, add, edit and delete.
>>> > The second, editGroup, is displayed when either the add or edit
>> button
>>> > was clicked on the select group, displays the record attributes and
>> save
>>> > and cancel buttons.  The tab panel has a "selectedRecord" which is
>> used
>>> > by both groups' components via PropertyModels. Very basic stuff.
>>> >
>>> > When I choose a record and click the edit button, the record is
>>> > displayed in the edit group properly.  If I then choose cancel, the
>> edit
>>> > group is no longer displayed and the select group DDC selection is
>> null
>>> > as expected. I then choose another record from the list and click
>> the
>>> > edit button and the previous record information is displayed in the
>> edit
>>> > group even though the select group DDC shows the correct/selected
>>> > record.
>>> >
>>> > This problem also occurs if I first choose to add a new record and
>> then
>>> > cancel the add and then choose to edit a different record.  The DDC
>>> > shows the correct/selected record, but all the attributes in the
>> edit
>>> > group are null/defaults for a new record.
>>> >
>>> > If I remove the call to setDefaultFormProcessing(false) on the
>> cancel
>>> > button, selecting other records for edit works correctly, but I
>> can't
>>> > cancel a creating a new record if I use a RequiredTextField because
>> the
>>> > form validation fails.
>>> >
>>> > If I select a record for editing or save the newly created record, I
>> can
>>> > select a different record for edit or create another one correctly.
>> So
>>> > I must be doing something wrong in the cancel logic. My editForm
>>> > (created in the EditGroup constructor) looks like this:
>>> >
>>> >            Form editForm = new Form("editForm");
>>> >
>>> >            editForm.add(new Label("nameLabel", "Name"));
>>> >
>>> >            editForm.add(new Label("attributeLabel", "Attribute"));
>>> >
>>> >            editForm.add(new
>> RequiredTextField<String>("recordNameText",
>>> >                    new PropertyModel<String>(MyRecordPanel.this,
>>> >                            "selectedRecord.name")));
>>> >
>>> >            editForm.add(new DropDownChoice<Lir>("attributes",
>>> >                    new PropertyModel<Attribute>(MyRecordPanel.this,
>>> >                            "selectedRecord.attribute"),
>>> >                    RateCentrePanel.this.getAttributes(),
>>> >                    new AttributeRenderer()));
>>> >
>>> >            ....
>>> >
>>> >            editForm.add(new Button("cancel")
>>> >            {
>>> >                private static final long serialVersionUID = 1L;
>>> >
>>> >                public void onSubmit()
>>> >                {
>>> >                    MyRecordPanel.this.selectedRecord = null;
>>> >                    editGroup.setVisible(false);
>>> >                    selectGroup.setVisible(true);
>>> >                }
>>> >            }.setDefaultFormProcessing(false));
>>> >
>>> >            add(editForm);
>>> >
>>> > Other than setting the selectedRecord to null, what should I be
>> doing
>>> > differently?
>>> >
>>> > Thanks in advance!
>>> >
>>> > Shelli
>>> >
>>> >
>> ---------------------------------------------------------------------
>>> > To unsubscribe, e-mail: [hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=4>
>>> > For additional commands, e-mail: [hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=5>
>>> >
>>> >
>>> >
>> ---------------------------------------------------------------------
>>> > To unsubscribe, e-mail: [hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=6>
>>> > For additional commands, e-mail: [hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=7>
>>> >
>>> >
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=8>
>>> For additional commands, e-mail: [hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=9>
>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=10>
>>> For additional commands, e-mail: [hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=11>
>>>
>>> ------------------------------
>>>  View message @
>>>
>> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
>> n-tp2955144p2968688.html
>>> To start a new topic under Apache Wicket, email
>>>
>> ml-node+1842946-398011874-65838@n4.nabble.com<ml-node%2B1842946-39801187
>> 4-65838@n4.nabble.com>
>>> To unsubscribe from Apache Wicket, click
>> here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?
>> tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
>> QyOTQ2fDEyNTYxMzc3ODY=>.
>>>
>>>
>>>
>>
>>
>> --
>> Sincerely,
>> JC (http://www.linkedin.com/in/jcgarciam)
>> Work smarter, not harder!.
>>
>> --
>> View this message in context:
>> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
>> n-tp2955144p2968936.html
>> Sent from the Users forum mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


RE: PropertyModel Not Refreshing

Posted by Shelli Orton <Sh...@sjrb.ca>.
Thanks for the help.  Your changes got rid of the errors and I can delete records now (and the list is updated).  

However, once a record has been selected for edit and either saved or cancelled, that same record is always displayed in the edit group when I choose another record to edit or even when I try to create a new one.  I can even delete the chosen record and it still displays in the edit group.

Shelli

-----Original Message-----
From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com] 
Sent: Tuesday, October 12, 2010 10:38 AM
To: users@wicket.apache.org
Subject: Re: PropertyModel Not Refreshing

here are the tweaks you need to make this work:

selectedRecordAModel = new PropertyModel<RecordA>(this, "selectedRecordA");

recordAText = new RequiredTextField("recordAText",
                new PropertyModel(selectedRecordAModel, "name"));

 recordBs.setModel(new PropertyModel(selectedRecordAModel, "recordB"));

have fun

-igor

On Tue, Oct 12, 2010 at 9:03 AM, Shelli Orton <Sh...@sjrb.ca> wrote:
> I've been able to create a sample application that exhibits the
> same/similar problems to mine.  The sample makes use of an in-memory
> list for the data versus accessing a database and so there's some
> differences.  However, I believe the problems that this sample exhibits
> have the same root cause as my project (which I believe have something
> to do with how my models are set up...).
>
> Issues this sample exhibits:
>
> 1. Choose to edit an existing record, then cancel the edit.  Choose
> another/the same record to edit and the selected record is null (error
> message "You must select a record to edit" is displayed).  Must
> close/open session to reset.
>
> 2. Choose to edit an existing record and save the edit.  Choose
> another/the same record to edit and you get a NPE:
>
>    WicketMessage: Method onFormSubmitted of interface
> org.apache.wicket.markup.html.form.IFormSubmitListener targeted at
> component [MarkupContainer [Component id = selectForm]] threw an
> exception
>
>    Root cause:
>
>    java.lang.NullPointerException
>    at
> org.apache.wicket.markup.html.form.AbstractSingleSelectChoice.convertCho
> iceIdToChoice(AbstractSingleSelectChoice.java:247)
>
> 3. Create a new record and try to save it and get
> WicketRuntimeException:
>
>    WicketMessage: Attempted to set property value on a null object.
> Property expression: name Value: New One
>
>    Root cause:
>
>    org.apache.wicket.WicketRuntimeException: Attempted to set property
> value on a null object. Property expression: name Value: New One
>    at
> org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.j
> ava:125)
>
> 4. Create a new record and then cancel the add, Choose an existing
> record to edit and the selected record is null (error message "You must
> select a record to edit" is displayed).  Must close/open session to
> reset.
>
> As always, all help is greatly appreciated as I am stumped.
>
> Thanks,
> Shelli
>
> -----Original Message-----
> From: jcgarciam [mailto:jcgarciam@gmail.com]
> Sent: Friday, October 08, 2010 1:41 PM
> To: users@wicket.apache.org
> Subject: Re: PropertyModel Not Refreshing
>
>
> The attachment didn't make it,
>
> Can you try to extract out the relevant part and creates a quickstart
> project that actually reproduces your issue?
>
>
> On Fri, Oct 8, 2010 at 1:41 PM, Shelli Orton [via Apache Wicket] <
> ml-node+2968688-305091622-65838@n4.nabble.com<ml-node%2B2968688-30509162
> 2-65838@n4.nabble.com>
>> wrote:
>
>> Hi,
>>
>> I have been trying different things to see if I could get my code to
> work
>> (and understand Wicket models better), but am still stuck.  I have a
>> attached the (latest) panel class code which I hope is sufficient to
> help.
>>
>> I was reading about different models (both online and the Wicket in
> Action
>> book) and thought that perhaps using a CompoundPropertyModel was more
>> appropriate and may help with my issues.  Originally, I only declared
>> selectedRecordA (line 40) but didn't instantiate it.  The select group
>> displayed properly but when I chose a record from the list and tried
> to edit
>> it, this exception was thrown:
>>
>>     WicketMessage: Attempted to set property value on a null object.
>> Property expression: recordA Value: Name=A-One
>>     Root cause:
>>
>>     org.apache.wicket.WicketRuntimeException: Attempted to set
> property
>> value on a null object. Property expression: recordA Value: Name=A-One
>>         at
>>
> org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.j
> ava:125)
>>
>>         at
>>
> org.apache.wicket.model.AbstractPropertyModel.setObject(AbstractProperty
> Model.java:169)
>>
>>         at
>> org.apache.wicket.Component.setDefaultModelObject(Component.java:3125)
>>         ....
>>
>> I set breakpoints on the getSelectedRecordA and setSelectedRecordA
> methods,
>> but these aren't called when during the request cycle when the edit
> button
>> is clicked.
>>
>> I then changed the class so that selectedRecordA is initialized to an
> empty
>> instance of RecordA. This got rid of the above error.  However, I
> cannot
>> save the edit changes because the selectedRecordA is still the empty
>> instance that was created in the initialization and the persistence
> layer
>> throws an exception.  This same problem exists if I try to add a new
> RecordA
>> or try to delete an existing one.
>>
>> If I choose to cancel the edit and then select another record to edit,
> I
>> get the message "You must select a record to edit" (line 131).  This
> is
>> because the cancel onSubmit sets selectedRecordA to null and choosing
> the
>> record from the DDC is not setting it to the chosen record.
>>
>> Clearly I am not setting up this CompoundPropertyModel properly so
> that the
>> selectedARecord is set by the model.  Can someone tell me what I'm
> doing
>> wrong?
>>
>> All help is greatly appreciated,
>>
>> Shelli
>>
>>
>> -----Original Message-----
>> From: Igor Vaynberg [mailto:[hidden
> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=0>]
>>
>> Sent: Thursday, October 07, 2010 11:27 AM
>> To: [hidden email]
> <http://user/SendEmail.jtp?type=node&node=2968688&i=1>
>> Subject: Re: PropertyModel Not Refreshing
>>
>> you have posted an incomplete piece of code and somehow from that we
>> are supposed to guess what is not working? create a quickstart and
>> provide that.
>>
>> -igor
>>
>> On Thu, Oct 7, 2010 at 10:15 AM, Shelli Orton <[hidden
> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=2>>
>> wrote:
>>
>> > Does nobody have any suggestions?  If I can't get this fixed, I'm
> going
>> > to have to write the app in another framework (possibly GWT) and I'd
>> > really rather not have to do that.
>> >
>> > Shelli
>> >
>> > -----Original Message-----
>> > From: Shelli Orton
>> > Sent: Wednesday, October 06, 2010 3:52 PM
>> > To: [hidden
> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=3>
>> > Subject: PropertyModel Not Refreshing
>> >
>> > Hi,
>> >
>> > First, thanks to all who have been helping me as I am new to Wicket.
> I
>> > am splitting out two issues I am dealing with to try to keep things
>> > clear.
>> >
>> > I am trying to write a simple app that does CRUD operations on
> database
>> > records.  The goal is for the app to make use of a tab panel where
> each
>> > tab encapsulates one table from the database.  Each tab panel has
> two
>> > groups (WebMarkupContainer).  The first, selectGroup, displays a
> list
>> > (DDC) of the current items, and three buttons, add, edit and delete.
>> > The second, editGroup, is displayed when either the add or edit
> button
>> > was clicked on the select group, displays the record attributes and
> save
>> > and cancel buttons.  The tab panel has a "selectedRecord" which is
> used
>> > by both groups' components via PropertyModels. Very basic stuff.
>> >
>> > When I choose a record and click the edit button, the record is
>> > displayed in the edit group properly.  If I then choose cancel, the
> edit
>> > group is no longer displayed and the select group DDC selection is
> null
>> > as expected. I then choose another record from the list and click
> the
>> > edit button and the previous record information is displayed in the
> edit
>> > group even though the select group DDC shows the correct/selected
>> > record.
>> >
>> > This problem also occurs if I first choose to add a new record and
> then
>> > cancel the add and then choose to edit a different record.  The DDC
>> > shows the correct/selected record, but all the attributes in the
> edit
>> > group are null/defaults for a new record.
>> >
>> > If I remove the call to setDefaultFormProcessing(false) on the
> cancel
>> > button, selecting other records for edit works correctly, but I
> can't
>> > cancel a creating a new record if I use a RequiredTextField because
> the
>> > form validation fails.
>> >
>> > If I select a record for editing or save the newly created record, I
> can
>> > select a different record for edit or create another one correctly.
> So
>> > I must be doing something wrong in the cancel logic. My editForm
>> > (created in the EditGroup constructor) looks like this:
>> >
>> >            Form editForm = new Form("editForm");
>> >
>> >            editForm.add(new Label("nameLabel", "Name"));
>> >
>> >            editForm.add(new Label("attributeLabel", "Attribute"));
>> >
>> >            editForm.add(new
> RequiredTextField<String>("recordNameText",
>> >                    new PropertyModel<String>(MyRecordPanel.this,
>> >                            "selectedRecord.name")));
>> >
>> >            editForm.add(new DropDownChoice<Lir>("attributes",
>> >                    new PropertyModel<Attribute>(MyRecordPanel.this,
>> >                            "selectedRecord.attribute"),
>> >                    RateCentrePanel.this.getAttributes(),
>> >                    new AttributeRenderer()));
>> >
>> >            ....
>> >
>> >            editForm.add(new Button("cancel")
>> >            {
>> >                private static final long serialVersionUID = 1L;
>> >
>> >                public void onSubmit()
>> >                {
>> >                    MyRecordPanel.this.selectedRecord = null;
>> >                    editGroup.setVisible(false);
>> >                    selectGroup.setVisible(true);
>> >                }
>> >            }.setDefaultFormProcessing(false));
>> >
>> >            add(editForm);
>> >
>> > Other than setting the selectedRecord to null, what should I be
> doing
>> > differently?
>> >
>> > Thanks in advance!
>> >
>> > Shelli
>> >
>> >
> ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: [hidden
> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=4>
>> > For additional commands, e-mail: [hidden
> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=5>
>> >
>> >
>> >
> ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: [hidden
> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=6>
>> > For additional commands, e-mail: [hidden
> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=7>
>> >
>> >
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden
> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=8>
>> For additional commands, e-mail: [hidden
> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=9>
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden
> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=10>
>> For additional commands, e-mail: [hidden
> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=11>
>>
>> ------------------------------
>>  View message @
>>
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
> n-tp2955144p2968688.html
>> To start a new topic under Apache Wicket, email
>>
> ml-node+1842946-398011874-65838@n4.nabble.com<ml-node%2B1842946-39801187
> 4-65838@n4.nabble.com>
>> To unsubscribe from Apache Wicket, click
> here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?
> tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
> QyOTQ2fDEyNTYxMzc3ODY=>.
>>
>>
>>
>
>
> --
> Sincerely,
> JC (http://www.linkedin.com/in/jcgarciam)
> Work smarter, not harder!.
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
> n-tp2955144p2968936.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>

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


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


Re: PropertyModel Not Refreshing

Posted by Igor Vaynberg <ig...@gmail.com>.
here are the tweaks you need to make this work:

selectedRecordAModel = new PropertyModel<RecordA>(this, "selectedRecordA");

recordAText = new RequiredTextField("recordAText",
                new PropertyModel(selectedRecordAModel, "name"));

 recordBs.setModel(new PropertyModel(selectedRecordAModel, "recordB"));

have fun

-igor

On Tue, Oct 12, 2010 at 9:03 AM, Shelli Orton <Sh...@sjrb.ca> wrote:
> I've been able to create a sample application that exhibits the
> same/similar problems to mine.  The sample makes use of an in-memory
> list for the data versus accessing a database and so there's some
> differences.  However, I believe the problems that this sample exhibits
> have the same root cause as my project (which I believe have something
> to do with how my models are set up...).
>
> Issues this sample exhibits:
>
> 1. Choose to edit an existing record, then cancel the edit.  Choose
> another/the same record to edit and the selected record is null (error
> message "You must select a record to edit" is displayed).  Must
> close/open session to reset.
>
> 2. Choose to edit an existing record and save the edit.  Choose
> another/the same record to edit and you get a NPE:
>
>    WicketMessage: Method onFormSubmitted of interface
> org.apache.wicket.markup.html.form.IFormSubmitListener targeted at
> component [MarkupContainer [Component id = selectForm]] threw an
> exception
>
>    Root cause:
>
>    java.lang.NullPointerException
>    at
> org.apache.wicket.markup.html.form.AbstractSingleSelectChoice.convertCho
> iceIdToChoice(AbstractSingleSelectChoice.java:247)
>
> 3. Create a new record and try to save it and get
> WicketRuntimeException:
>
>    WicketMessage: Attempted to set property value on a null object.
> Property expression: name Value: New One
>
>    Root cause:
>
>    org.apache.wicket.WicketRuntimeException: Attempted to set property
> value on a null object. Property expression: name Value: New One
>    at
> org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.j
> ava:125)
>
> 4. Create a new record and then cancel the add, Choose an existing
> record to edit and the selected record is null (error message "You must
> select a record to edit" is displayed).  Must close/open session to
> reset.
>
> As always, all help is greatly appreciated as I am stumped.
>
> Thanks,
> Shelli
>
> -----Original Message-----
> From: jcgarciam [mailto:jcgarciam@gmail.com]
> Sent: Friday, October 08, 2010 1:41 PM
> To: users@wicket.apache.org
> Subject: Re: PropertyModel Not Refreshing
>
>
> The attachment didn't make it,
>
> Can you try to extract out the relevant part and creates a quickstart
> project that actually reproduces your issue?
>
>
> On Fri, Oct 8, 2010 at 1:41 PM, Shelli Orton [via Apache Wicket] <
> ml-node+2968688-305091622-65838@n4.nabble.com<ml-node%2B2968688-30509162
> 2-65838@n4.nabble.com>
>> wrote:
>
>> Hi,
>>
>> I have been trying different things to see if I could get my code to
> work
>> (and understand Wicket models better), but am still stuck.  I have a
>> attached the (latest) panel class code which I hope is sufficient to
> help.
>>
>> I was reading about different models (both online and the Wicket in
> Action
>> book) and thought that perhaps using a CompoundPropertyModel was more
>> appropriate and may help with my issues.  Originally, I only declared
>> selectedRecordA (line 40) but didn't instantiate it.  The select group
>> displayed properly but when I chose a record from the list and tried
> to edit
>> it, this exception was thrown:
>>
>>     WicketMessage: Attempted to set property value on a null object.
>> Property expression: recordA Value: Name=A-One
>>     Root cause:
>>
>>     org.apache.wicket.WicketRuntimeException: Attempted to set
> property
>> value on a null object. Property expression: recordA Value: Name=A-One
>>         at
>>
> org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.j
> ava:125)
>>
>>         at
>>
> org.apache.wicket.model.AbstractPropertyModel.setObject(AbstractProperty
> Model.java:169)
>>
>>         at
>> org.apache.wicket.Component.setDefaultModelObject(Component.java:3125)
>>         ....
>>
>> I set breakpoints on the getSelectedRecordA and setSelectedRecordA
> methods,
>> but these aren't called when during the request cycle when the edit
> button
>> is clicked.
>>
>> I then changed the class so that selectedRecordA is initialized to an
> empty
>> instance of RecordA. This got rid of the above error.  However, I
> cannot
>> save the edit changes because the selectedRecordA is still the empty
>> instance that was created in the initialization and the persistence
> layer
>> throws an exception.  This same problem exists if I try to add a new
> RecordA
>> or try to delete an existing one.
>>
>> If I choose to cancel the edit and then select another record to edit,
> I
>> get the message "You must select a record to edit" (line 131).  This
> is
>> because the cancel onSubmit sets selectedRecordA to null and choosing
> the
>> record from the DDC is not setting it to the chosen record.
>>
>> Clearly I am not setting up this CompoundPropertyModel properly so
> that the
>> selectedARecord is set by the model.  Can someone tell me what I'm
> doing
>> wrong?
>>
>> All help is greatly appreciated,
>>
>> Shelli
>>
>>
>> -----Original Message-----
>> From: Igor Vaynberg [mailto:[hidden
> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=0>]
>>
>> Sent: Thursday, October 07, 2010 11:27 AM
>> To: [hidden email]
> <http://user/SendEmail.jtp?type=node&node=2968688&i=1>
>> Subject: Re: PropertyModel Not Refreshing
>>
>> you have posted an incomplete piece of code and somehow from that we
>> are supposed to guess what is not working? create a quickstart and
>> provide that.
>>
>> -igor
>>
>> On Thu, Oct 7, 2010 at 10:15 AM, Shelli Orton <[hidden
> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=2>>
>> wrote:
>>
>> > Does nobody have any suggestions?  If I can't get this fixed, I'm
> going
>> > to have to write the app in another framework (possibly GWT) and I'd
>> > really rather not have to do that.
>> >
>> > Shelli
>> >
>> > -----Original Message-----
>> > From: Shelli Orton
>> > Sent: Wednesday, October 06, 2010 3:52 PM
>> > To: [hidden
> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=3>
>> > Subject: PropertyModel Not Refreshing
>> >
>> > Hi,
>> >
>> > First, thanks to all who have been helping me as I am new to Wicket.
> I
>> > am splitting out two issues I am dealing with to try to keep things
>> > clear.
>> >
>> > I am trying to write a simple app that does CRUD operations on
> database
>> > records.  The goal is for the app to make use of a tab panel where
> each
>> > tab encapsulates one table from the database.  Each tab panel has
> two
>> > groups (WebMarkupContainer).  The first, selectGroup, displays a
> list
>> > (DDC) of the current items, and three buttons, add, edit and delete.
>> > The second, editGroup, is displayed when either the add or edit
> button
>> > was clicked on the select group, displays the record attributes and
> save
>> > and cancel buttons.  The tab panel has a "selectedRecord" which is
> used
>> > by both groups' components via PropertyModels. Very basic stuff.
>> >
>> > When I choose a record and click the edit button, the record is
>> > displayed in the edit group properly.  If I then choose cancel, the
> edit
>> > group is no longer displayed and the select group DDC selection is
> null
>> > as expected. I then choose another record from the list and click
> the
>> > edit button and the previous record information is displayed in the
> edit
>> > group even though the select group DDC shows the correct/selected
>> > record.
>> >
>> > This problem also occurs if I first choose to add a new record and
> then
>> > cancel the add and then choose to edit a different record.  The DDC
>> > shows the correct/selected record, but all the attributes in the
> edit
>> > group are null/defaults for a new record.
>> >
>> > If I remove the call to setDefaultFormProcessing(false) on the
> cancel
>> > button, selecting other records for edit works correctly, but I
> can't
>> > cancel a creating a new record if I use a RequiredTextField because
> the
>> > form validation fails.
>> >
>> > If I select a record for editing or save the newly created record, I
> can
>> > select a different record for edit or create another one correctly.
> So
>> > I must be doing something wrong in the cancel logic. My editForm
>> > (created in the EditGroup constructor) looks like this:
>> >
>> >            Form editForm = new Form("editForm");
>> >
>> >            editForm.add(new Label("nameLabel", "Name"));
>> >
>> >            editForm.add(new Label("attributeLabel", "Attribute"));
>> >
>> >            editForm.add(new
> RequiredTextField<String>("recordNameText",
>> >                    new PropertyModel<String>(MyRecordPanel.this,
>> >                            "selectedRecord.name")));
>> >
>> >            editForm.add(new DropDownChoice<Lir>("attributes",
>> >                    new PropertyModel<Attribute>(MyRecordPanel.this,
>> >                            "selectedRecord.attribute"),
>> >                    RateCentrePanel.this.getAttributes(),
>> >                    new AttributeRenderer()));
>> >
>> >            ....
>> >
>> >            editForm.add(new Button("cancel")
>> >            {
>> >                private static final long serialVersionUID = 1L;
>> >
>> >                public void onSubmit()
>> >                {
>> >                    MyRecordPanel.this.selectedRecord = null;
>> >                    editGroup.setVisible(false);
>> >                    selectGroup.setVisible(true);
>> >                }
>> >            }.setDefaultFormProcessing(false));
>> >
>> >            add(editForm);
>> >
>> > Other than setting the selectedRecord to null, what should I be
> doing
>> > differently?
>> >
>> > Thanks in advance!
>> >
>> > Shelli
>> >
>> >
> ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: [hidden
> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=4>
>> > For additional commands, e-mail: [hidden
> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=5>
>> >
>> >
>> >
> ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: [hidden
> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=6>
>> > For additional commands, e-mail: [hidden
> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=7>
>> >
>> >
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden
> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=8>
>> For additional commands, e-mail: [hidden
> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=9>
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden
> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=10>
>> For additional commands, e-mail: [hidden
> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=11>
>>
>> ------------------------------
>>  View message @
>>
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
> n-tp2955144p2968688.html
>> To start a new topic under Apache Wicket, email
>>
> ml-node+1842946-398011874-65838@n4.nabble.com<ml-node%2B1842946-39801187
> 4-65838@n4.nabble.com>
>> To unsubscribe from Apache Wicket, click
> here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?
> tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
> QyOTQ2fDEyNTYxMzc3ODY=>.
>>
>>
>>
>
>
> --
> Sincerely,
> JC (http://www.linkedin.com/in/jcgarciam)
> Work smarter, not harder!.
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
> n-tp2955144p2968936.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>

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


RE: PropertyModel Not Refreshing

Posted by Shelli Orton <Sh...@sjrb.ca>.
I've been able to create a sample application that exhibits the
same/similar problems to mine.  The sample makes use of an in-memory
list for the data versus accessing a database and so there's some
differences.  However, I believe the problems that this sample exhibits
have the same root cause as my project (which I believe have something
to do with how my models are set up...).

Issues this sample exhibits:

1. Choose to edit an existing record, then cancel the edit.  Choose
another/the same record to edit and the selected record is null (error
message "You must select a record to edit" is displayed).  Must
close/open session to reset.

2. Choose to edit an existing record and save the edit.  Choose
another/the same record to edit and you get a NPE:

    WicketMessage: Method onFormSubmitted of interface
org.apache.wicket.markup.html.form.IFormSubmitListener targeted at
component [MarkupContainer [Component id = selectForm]] threw an
exception

    Root cause:

    java.lang.NullPointerException
    at
org.apache.wicket.markup.html.form.AbstractSingleSelectChoice.convertCho
iceIdToChoice(AbstractSingleSelectChoice.java:247)

3. Create a new record and try to save it and get
WicketRuntimeException:

    WicketMessage: Attempted to set property value on a null object.
Property expression: name Value: New One

    Root cause:

    org.apache.wicket.WicketRuntimeException: Attempted to set property
value on a null object. Property expression: name Value: New One
    at
org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.j
ava:125)

4. Create a new record and then cancel the add, Choose an existing
record to edit and the selected record is null (error message "You must
select a record to edit" is displayed).  Must close/open session to
reset.

As always, all help is greatly appreciated as I am stumped.

Thanks,
Shelli

-----Original Message-----
From: jcgarciam [mailto:jcgarciam@gmail.com] 
Sent: Friday, October 08, 2010 1:41 PM
To: users@wicket.apache.org
Subject: Re: PropertyModel Not Refreshing


The attachment didn't make it,

Can you try to extract out the relevant part and creates a quickstart
project that actually reproduces your issue?


On Fri, Oct 8, 2010 at 1:41 PM, Shelli Orton [via Apache Wicket] <
ml-node+2968688-305091622-65838@n4.nabble.com<ml-node%2B2968688-30509162
2-65838@n4.nabble.com>
> wrote:

> Hi,
>
> I have been trying different things to see if I could get my code to
work
> (and understand Wicket models better), but am still stuck.  I have a
> attached the (latest) panel class code which I hope is sufficient to
help.
>
> I was reading about different models (both online and the Wicket in
Action
> book) and thought that perhaps using a CompoundPropertyModel was more
> appropriate and may help with my issues.  Originally, I only declared
> selectedRecordA (line 40) but didn't instantiate it.  The select group
> displayed properly but when I chose a record from the list and tried
to edit
> it, this exception was thrown:
>
>     WicketMessage: Attempted to set property value on a null object.
> Property expression: recordA Value: Name=A-One
>     Root cause:
>
>     org.apache.wicket.WicketRuntimeException: Attempted to set
property
> value on a null object. Property expression: recordA Value: Name=A-One
>         at
>
org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.j
ava:125)
>
>         at
>
org.apache.wicket.model.AbstractPropertyModel.setObject(AbstractProperty
Model.java:169)
>
>         at
> org.apache.wicket.Component.setDefaultModelObject(Component.java:3125)
>         ....
>
> I set breakpoints on the getSelectedRecordA and setSelectedRecordA
methods,
> but these aren't called when during the request cycle when the edit
button
> is clicked.
>
> I then changed the class so that selectedRecordA is initialized to an
empty
> instance of RecordA. This got rid of the above error.  However, I
cannot
> save the edit changes because the selectedRecordA is still the empty
> instance that was created in the initialization and the persistence
layer
> throws an exception.  This same problem exists if I try to add a new
RecordA
> or try to delete an existing one.
>
> If I choose to cancel the edit and then select another record to edit,
I
> get the message "You must select a record to edit" (line 131).  This
is
> because the cancel onSubmit sets selectedRecordA to null and choosing
the
> record from the DDC is not setting it to the chosen record.
>
> Clearly I am not setting up this CompoundPropertyModel properly so
that the
> selectedARecord is set by the model.  Can someone tell me what I'm
doing
> wrong?
>
> All help is greatly appreciated,
>
> Shelli
>
>
> -----Original Message-----
> From: Igor Vaynberg [mailto:[hidden
email]<http://user/SendEmail.jtp?type=node&node=2968688&i=0>]
>
> Sent: Thursday, October 07, 2010 11:27 AM
> To: [hidden email]
<http://user/SendEmail.jtp?type=node&node=2968688&i=1>
> Subject: Re: PropertyModel Not Refreshing
>
> you have posted an incomplete piece of code and somehow from that we
> are supposed to guess what is not working? create a quickstart and
> provide that.
>
> -igor
>
> On Thu, Oct 7, 2010 at 10:15 AM, Shelli Orton <[hidden
email]<http://user/SendEmail.jtp?type=node&node=2968688&i=2>>
> wrote:
>
> > Does nobody have any suggestions?  If I can't get this fixed, I'm
going
> > to have to write the app in another framework (possibly GWT) and I'd
> > really rather not have to do that.
> >
> > Shelli
> >
> > -----Original Message-----
> > From: Shelli Orton
> > Sent: Wednesday, October 06, 2010 3:52 PM
> > To: [hidden
email]<http://user/SendEmail.jtp?type=node&node=2968688&i=3>
> > Subject: PropertyModel Not Refreshing
> >
> > Hi,
> >
> > First, thanks to all who have been helping me as I am new to Wicket.
I
> > am splitting out two issues I am dealing with to try to keep things
> > clear.
> >
> > I am trying to write a simple app that does CRUD operations on
database
> > records.  The goal is for the app to make use of a tab panel where
each
> > tab encapsulates one table from the database.  Each tab panel has
two
> > groups (WebMarkupContainer).  The first, selectGroup, displays a
list
> > (DDC) of the current items, and three buttons, add, edit and delete.
> > The second, editGroup, is displayed when either the add or edit
button
> > was clicked on the select group, displays the record attributes and
save
> > and cancel buttons.  The tab panel has a "selectedRecord" which is
used
> > by both groups' components via PropertyModels. Very basic stuff.
> >
> > When I choose a record and click the edit button, the record is
> > displayed in the edit group properly.  If I then choose cancel, the
edit
> > group is no longer displayed and the select group DDC selection is
null
> > as expected. I then choose another record from the list and click
the
> > edit button and the previous record information is displayed in the
edit
> > group even though the select group DDC shows the correct/selected
> > record.
> >
> > This problem also occurs if I first choose to add a new record and
then
> > cancel the add and then choose to edit a different record.  The DDC
> > shows the correct/selected record, but all the attributes in the
edit
> > group are null/defaults for a new record.
> >
> > If I remove the call to setDefaultFormProcessing(false) on the
cancel
> > button, selecting other records for edit works correctly, but I
can't
> > cancel a creating a new record if I use a RequiredTextField because
the
> > form validation fails.
> >
> > If I select a record for editing or save the newly created record, I
can
> > select a different record for edit or create another one correctly.
So
> > I must be doing something wrong in the cancel logic. My editForm
> > (created in the EditGroup constructor) looks like this:
> >
> >            Form editForm = new Form("editForm");
> >
> >            editForm.add(new Label("nameLabel", "Name"));
> >
> >            editForm.add(new Label("attributeLabel", "Attribute"));
> >
> >            editForm.add(new
RequiredTextField<String>("recordNameText",
> >                    new PropertyModel<String>(MyRecordPanel.this,
> >                            "selectedRecord.name")));
> >
> >            editForm.add(new DropDownChoice<Lir>("attributes",
> >                    new PropertyModel<Attribute>(MyRecordPanel.this,
> >                            "selectedRecord.attribute"),
> >                    RateCentrePanel.this.getAttributes(),
> >                    new AttributeRenderer()));
> >
> >            ....
> >
> >            editForm.add(new Button("cancel")
> >            {
> >                private static final long serialVersionUID = 1L;
> >
> >                public void onSubmit()
> >                {
> >                    MyRecordPanel.this.selectedRecord = null;
> >                    editGroup.setVisible(false);
> >                    selectGroup.setVisible(true);
> >                }
> >            }.setDefaultFormProcessing(false));
> >
> >            add(editForm);
> >
> > Other than setting the selectedRecord to null, what should I be
doing
> > differently?
> >
> > Thanks in advance!
> >
> > Shelli
> >
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden
email]<http://user/SendEmail.jtp?type=node&node=2968688&i=4>
> > For additional commands, e-mail: [hidden
email]<http://user/SendEmail.jtp?type=node&node=2968688&i=5>
> >
> >
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden
email]<http://user/SendEmail.jtp?type=node&node=2968688&i=6>
> > For additional commands, e-mail: [hidden
email]<http://user/SendEmail.jtp?type=node&node=2968688&i=7>
> >
> >
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden
email]<http://user/SendEmail.jtp?type=node&node=2968688&i=8>
> For additional commands, e-mail: [hidden
email]<http://user/SendEmail.jtp?type=node&node=2968688&i=9>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden
email]<http://user/SendEmail.jtp?type=node&node=2968688&i=10>
> For additional commands, e-mail: [hidden
email]<http://user/SendEmail.jtp?type=node&node=2968688&i=11>
>
> ------------------------------
>  View message @
>
http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
n-tp2955144p2968688.html
> To start a new topic under Apache Wicket, email
>
ml-node+1842946-398011874-65838@n4.nabble.com<ml-node%2B1842946-39801187
4-65838@n4.nabble.com>
> To unsubscribe from Apache Wicket, click
here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?
tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
QyOTQ2fDEyNTYxMzc3ODY=>.
>
>
>


-- 
Sincerely,
JC (http://www.linkedin.com/in/jcgarciam)
Work smarter, not harder!.

-- 
View this message in context:
http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
n-tp2955144p2968936.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: PropertyModel Not Refreshing

Posted by jcgarciam <jc...@gmail.com>.
The attachment didn't make it,

Can you try to extract out the relevant part and creates a quickstart
project that actually reproduces your issue?


On Fri, Oct 8, 2010 at 1:41 PM, Shelli Orton [via Apache Wicket] <
ml-node+2968688-305091622-65838@n4.nabble.com<ml...@n4.nabble.com>
> wrote:

> Hi,
>
> I have been trying different things to see if I could get my code to work
> (and understand Wicket models better), but am still stuck.  I have a
> attached the (latest) panel class code which I hope is sufficient to help.
>
> I was reading about different models (both online and the Wicket in Action
> book) and thought that perhaps using a CompoundPropertyModel was more
> appropriate and may help with my issues.  Originally, I only declared
> selectedRecordA (line 40) but didn't instantiate it.  The select group
> displayed properly but when I chose a record from the list and tried to edit
> it, this exception was thrown:
>
>     WicketMessage: Attempted to set property value on a null object.
> Property expression: recordA Value: Name=A-One
>     Root cause:
>
>     org.apache.wicket.WicketRuntimeException: Attempted to set property
> value on a null object. Property expression: recordA Value: Name=A-One
>         at
> org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.java:125)
>
>         at
> org.apache.wicket.model.AbstractPropertyModel.setObject(AbstractPropertyModel.java:169)
>
>         at
> org.apache.wicket.Component.setDefaultModelObject(Component.java:3125)
>         ....
>
> I set breakpoints on the getSelectedRecordA and setSelectedRecordA methods,
> but these aren't called when during the request cycle when the edit button
> is clicked.
>
> I then changed the class so that selectedRecordA is initialized to an empty
> instance of RecordA. This got rid of the above error.  However, I cannot
> save the edit changes because the selectedRecordA is still the empty
> instance that was created in the initialization and the persistence layer
> throws an exception.  This same problem exists if I try to add a new RecordA
> or try to delete an existing one.
>
> If I choose to cancel the edit and then select another record to edit, I
> get the message "You must select a record to edit" (line 131).  This is
> because the cancel onSubmit sets selectedRecordA to null and choosing the
> record from the DDC is not setting it to the chosen record.
>
> Clearly I am not setting up this CompoundPropertyModel properly so that the
> selectedARecord is set by the model.  Can someone tell me what I'm doing
> wrong?
>
> All help is greatly appreciated,
>
> Shelli
>
>
> -----Original Message-----
> From: Igor Vaynberg [mailto:[hidden email]<http://user/SendEmail.jtp?type=node&node=2968688&i=0>]
>
> Sent: Thursday, October 07, 2010 11:27 AM
> To: [hidden email] <http://user/SendEmail.jtp?type=node&node=2968688&i=1>
> Subject: Re: PropertyModel Not Refreshing
>
> you have posted an incomplete piece of code and somehow from that we
> are supposed to guess what is not working? create a quickstart and
> provide that.
>
> -igor
>
> On Thu, Oct 7, 2010 at 10:15 AM, Shelli Orton <[hidden email]<http://user/SendEmail.jtp?type=node&node=2968688&i=2>>
> wrote:
>
> > Does nobody have any suggestions?  If I can't get this fixed, I'm going
> > to have to write the app in another framework (possibly GWT) and I'd
> > really rather not have to do that.
> >
> > Shelli
> >
> > -----Original Message-----
> > From: Shelli Orton
> > Sent: Wednesday, October 06, 2010 3:52 PM
> > To: [hidden email]<http://user/SendEmail.jtp?type=node&node=2968688&i=3>
> > Subject: PropertyModel Not Refreshing
> >
> > Hi,
> >
> > First, thanks to all who have been helping me as I am new to Wicket.  I
> > am splitting out two issues I am dealing with to try to keep things
> > clear.
> >
> > I am trying to write a simple app that does CRUD operations on database
> > records.  The goal is for the app to make use of a tab panel where each
> > tab encapsulates one table from the database.  Each tab panel has two
> > groups (WebMarkupContainer).  The first, selectGroup, displays a list
> > (DDC) of the current items, and three buttons, add, edit and delete.
> > The second, editGroup, is displayed when either the add or edit button
> > was clicked on the select group, displays the record attributes and save
> > and cancel buttons.  The tab panel has a "selectedRecord" which is used
> > by both groups' components via PropertyModels. Very basic stuff.
> >
> > When I choose a record and click the edit button, the record is
> > displayed in the edit group properly.  If I then choose cancel, the edit
> > group is no longer displayed and the select group DDC selection is null
> > as expected. I then choose another record from the list and click the
> > edit button and the previous record information is displayed in the edit
> > group even though the select group DDC shows the correct/selected
> > record.
> >
> > This problem also occurs if I first choose to add a new record and then
> > cancel the add and then choose to edit a different record.  The DDC
> > shows the correct/selected record, but all the attributes in the edit
> > group are null/defaults for a new record.
> >
> > If I remove the call to setDefaultFormProcessing(false) on the cancel
> > button, selecting other records for edit works correctly, but I can't
> > cancel a creating a new record if I use a RequiredTextField because the
> > form validation fails.
> >
> > If I select a record for editing or save the newly created record, I can
> > select a different record for edit or create another one correctly.  So
> > I must be doing something wrong in the cancel logic. My editForm
> > (created in the EditGroup constructor) looks like this:
> >
> >            Form editForm = new Form("editForm");
> >
> >            editForm.add(new Label("nameLabel", "Name"));
> >
> >            editForm.add(new Label("attributeLabel", "Attribute"));
> >
> >            editForm.add(new RequiredTextField<String>("recordNameText",
> >                    new PropertyModel<String>(MyRecordPanel.this,
> >                            "selectedRecord.name")));
> >
> >            editForm.add(new DropDownChoice<Lir>("attributes",
> >                    new PropertyModel<Attribute>(MyRecordPanel.this,
> >                            "selectedRecord.attribute"),
> >                    RateCentrePanel.this.getAttributes(),
> >                    new AttributeRenderer()));
> >
> >            ....
> >
> >            editForm.add(new Button("cancel")
> >            {
> >                private static final long serialVersionUID = 1L;
> >
> >                public void onSubmit()
> >                {
> >                    MyRecordPanel.this.selectedRecord = null;
> >                    editGroup.setVisible(false);
> >                    selectGroup.setVisible(true);
> >                }
> >            }.setDefaultFormProcessing(false));
> >
> >            add(editForm);
> >
> > Other than setting the selectedRecord to null, what should I be doing
> > differently?
> >
> > Thanks in advance!
> >
> > Shelli
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=2968688&i=4>
> > For additional commands, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=2968688&i=5>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=2968688&i=6>
> > For additional commands, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=2968688&i=7>
> >
> >
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=2968688&i=8>
> For additional commands, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=2968688&i=9>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=2968688&i=10>
> For additional commands, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=2968688&i=11>
>
> ------------------------------
>  View message @
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusion-tp2955144p2968688.html
> To start a new topic under Apache Wicket, email
> ml-node+1842946-398011874-65838@n4.nabble.com<ml...@n4.nabble.com>
> To unsubscribe from Apache Wicket, click here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxODQyOTQ2fDEyNTYxMzc3ODY=>.
>
>
>


-- 
Sincerely,
JC (http://www.linkedin.com/in/jcgarciam)
Work smarter, not harder!.

-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusion-tp2955144p2968936.html
Sent from the Users forum mailing list archive at Nabble.com.

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


RE: PropertyModel Not Refreshing

Posted by Shelli Orton <Sh...@sjrb.ca>.
Hi,

I have been trying different things to see if I could get my code to work (and understand Wicket models better), but am still stuck.  I have a attached the (latest) panel class code which I hope is sufficient to help.

I was reading about different models (both online and the Wicket in Action book) and thought that perhaps using a CompoundPropertyModel was more appropriate and may help with my issues.  Originally, I only declared selectedRecordA (line 40) but didn't instantiate it.  The select group displayed properly but when I chose a record from the list and tried to edit it, this exception was thrown:

    WicketMessage: Attempted to set property value on a null object. Property expression: recordA Value: Name=A-One
    Root cause:

    org.apache.wicket.WicketRuntimeException: Attempted to set property value on a null object. Property expression: recordA Value: Name=A-One
        at org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.java:125)
        at org.apache.wicket.model.AbstractPropertyModel.setObject(AbstractPropertyModel.java:169)
        at org.apache.wicket.Component.setDefaultModelObject(Component.java:3125)
        ....

I set breakpoints on the getSelectedRecordA and setSelectedRecordA methods, but these aren't called when during the request cycle when the edit button is clicked.

I then changed the class so that selectedRecordA is initialized to an empty instance of RecordA. This got rid of the above error.  However, I cannot save the edit changes because the selectedRecordA is still the empty instance that was created in the initialization and the persistence layer throws an exception.  This same problem exists if I try to add a new RecordA or try to delete an existing one.

If I choose to cancel the edit and then select another record to edit, I get the message "You must select a record to edit" (line 131).  This is because the cancel onSubmit sets selectedRecordA to null and choosing the record from the DDC is not setting it to the chosen record.

Clearly I am not setting up this CompoundPropertyModel properly so that the selectedARecord is set by the model.  Can someone tell me what I'm doing wrong?

All help is greatly appreciated,

Shelli


-----Original Message-----
From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com] 
Sent: Thursday, October 07, 2010 11:27 AM
To: users@wicket.apache.org
Subject: Re: PropertyModel Not Refreshing

you have posted an incomplete piece of code and somehow from that we
are supposed to guess what is not working? create a quickstart and
provide that.

-igor

On Thu, Oct 7, 2010 at 10:15 AM, Shelli Orton <Sh...@sjrb.ca> wrote:
> Does nobody have any suggestions? �If I can't get this fixed, I'm going
> to have to write the app in another framework (possibly GWT) and I'd
> really rather not have to do that.
>
> Shelli
>
> -----Original Message-----
> From: Shelli Orton
> Sent: Wednesday, October 06, 2010 3:52 PM
> To: users@wicket.apache.org
> Subject: PropertyModel Not Refreshing
>
> Hi,
>
> First, thanks to all who have been helping me as I am new to Wicket. �I
> am splitting out two issues I am dealing with to try to keep things
> clear.
>
> I am trying to write a simple app that does CRUD operations on database
> records. �The goal is for the app to make use of a tab panel where each
> tab encapsulates one table from the database. �Each tab panel has two
> groups (WebMarkupContainer). �The first, selectGroup, displays a list
> (DDC) of the current items, and three buttons, add, edit and delete.
> The second, editGroup, is displayed when either the add or edit button
> was clicked on the select group, displays the record attributes and save
> and cancel buttons. �The tab panel has a "selectedRecord" which is used
> by both groups' components via PropertyModels. Very basic stuff.
>
> When I choose a record and click the edit button, the record is
> displayed in the edit group properly. �If I then choose cancel, the edit
> group is no longer displayed and the select group DDC selection is null
> as expected. I then choose another record from the list and click the
> edit button and the previous record information is displayed in the edit
> group even though the select group DDC shows the correct/selected
> record.
>
> This problem also occurs if I first choose to add a new record and then
> cancel the add and then choose to edit a different record. �The DDC
> shows the correct/selected record, but all the attributes in the edit
> group are null/defaults for a new record.
>
> If I remove the call to setDefaultFormProcessing(false) on the cancel
> button, selecting other records for edit works correctly, but I can't
> cancel a creating a new record if I use a RequiredTextField because the
> form validation fails.
>
> If I select a record for editing or save the newly created record, I can
> select a different record for edit or create another one correctly. �So
> I must be doing something wrong in the cancel logic. My editForm
> (created in the EditGroup constructor) looks like this:
>
> � � � � � �Form editForm = new Form("editForm");
>
> � � � � � �editForm.add(new Label("nameLabel", "Name"));
>
> � � � � � �editForm.add(new Label("attributeLabel", "Attribute"));
>
> � � � � � �editForm.add(new RequiredTextField<String>("recordNameText",
> � � � � � � � � � �new PropertyModel<String>(MyRecordPanel.this,
> � � � � � � � � � � � � � �"selectedRecord.name")));
>
> � � � � � �editForm.add(new DropDownChoice<Lir>("attributes",
> � � � � � � � � � �new PropertyModel<Attribute>(MyRecordPanel.this,
> � � � � � � � � � � � � � �"selectedRecord.attribute"),
> � � � � � � � � � �RateCentrePanel.this.getAttributes(),
> � � � � � � � � � �new AttributeRenderer()));
>
> � � � � � �....
>
> � � � � � �editForm.add(new Button("cancel")
> � � � � � �{
> � � � � � � � �private static final long serialVersionUID = 1L;
>
> � � � � � � � �public void onSubmit()
> � � � � � � � �{
> � � � � � � � � � �MyRecordPanel.this.selectedRecord = null;
> � � � � � � � � � �editGroup.setVisible(false);
> � � � � � � � � � �selectGroup.setVisible(true);
> � � � � � � � �}
> � � � � � �}.setDefaultFormProcessing(false));
>
> � � � � � �add(editForm);
>
> Other than setting the selectedRecord to null, what should I be doing
> differently?
>
> Thanks in advance!
>
> Shelli
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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



Re: PropertyModel Not Refreshing

Posted by Igor Vaynberg <ig...@gmail.com>.
you have posted an incomplete piece of code and somehow from that we
are supposed to guess what is not working? create a quickstart and
provide that.

-igor

On Thu, Oct 7, 2010 at 10:15 AM, Shelli Orton <Sh...@sjrb.ca> wrote:
> Does nobody have any suggestions?  If I can't get this fixed, I'm going
> to have to write the app in another framework (possibly GWT) and I'd
> really rather not have to do that.
>
> Shelli
>
> -----Original Message-----
> From: Shelli Orton
> Sent: Wednesday, October 06, 2010 3:52 PM
> To: users@wicket.apache.org
> Subject: PropertyModel Not Refreshing
>
> Hi,
>
> First, thanks to all who have been helping me as I am new to Wicket.  I
> am splitting out two issues I am dealing with to try to keep things
> clear.
>
> I am trying to write a simple app that does CRUD operations on database
> records.  The goal is for the app to make use of a tab panel where each
> tab encapsulates one table from the database.  Each tab panel has two
> groups (WebMarkupContainer).  The first, selectGroup, displays a list
> (DDC) of the current items, and three buttons, add, edit and delete.
> The second, editGroup, is displayed when either the add or edit button
> was clicked on the select group, displays the record attributes and save
> and cancel buttons.  The tab panel has a "selectedRecord" which is used
> by both groups' components via PropertyModels. Very basic stuff.
>
> When I choose a record and click the edit button, the record is
> displayed in the edit group properly.  If I then choose cancel, the edit
> group is no longer displayed and the select group DDC selection is null
> as expected. I then choose another record from the list and click the
> edit button and the previous record information is displayed in the edit
> group even though the select group DDC shows the correct/selected
> record.
>
> This problem also occurs if I first choose to add a new record and then
> cancel the add and then choose to edit a different record.  The DDC
> shows the correct/selected record, but all the attributes in the edit
> group are null/defaults for a new record.
>
> If I remove the call to setDefaultFormProcessing(false) on the cancel
> button, selecting other records for edit works correctly, but I can't
> cancel a creating a new record if I use a RequiredTextField because the
> form validation fails.
>
> If I select a record for editing or save the newly created record, I can
> select a different record for edit or create another one correctly.  So
> I must be doing something wrong in the cancel logic. My editForm
> (created in the EditGroup constructor) looks like this:
>
>            Form editForm = new Form("editForm");
>
>            editForm.add(new Label("nameLabel", "Name"));
>
>            editForm.add(new Label("attributeLabel", "Attribute"));
>
>            editForm.add(new RequiredTextField<String>("recordNameText",
>                    new PropertyModel<String>(MyRecordPanel.this,
>                            "selectedRecord.name")));
>
>            editForm.add(new DropDownChoice<Lir>("attributes",
>                    new PropertyModel<Attribute>(MyRecordPanel.this,
>                            "selectedRecord.attribute"),
>                    RateCentrePanel.this.getAttributes(),
>                    new AttributeRenderer()));
>
>            ....
>
>            editForm.add(new Button("cancel")
>            {
>                private static final long serialVersionUID = 1L;
>
>                public void onSubmit()
>                {
>                    MyRecordPanel.this.selectedRecord = null;
>                    editGroup.setVisible(false);
>                    selectGroup.setVisible(true);
>                }
>            }.setDefaultFormProcessing(false));
>
>            add(editForm);
>
> Other than setting the selectedRecord to null, what should I be doing
> differently?
>
> Thanks in advance!
>
> Shelli
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


RE: PropertyModel Not Refreshing

Posted by Shelli Orton <Sh...@sjrb.ca>.
Does nobody have any suggestions?  If I can't get this fixed, I'm going
to have to write the app in another framework (possibly GWT) and I'd
really rather not have to do that.

Shelli

-----Original Message-----
From: Shelli Orton 
Sent: Wednesday, October 06, 2010 3:52 PM
To: users@wicket.apache.org
Subject: PropertyModel Not Refreshing

Hi,

First, thanks to all who have been helping me as I am new to Wicket.  I
am splitting out two issues I am dealing with to try to keep things
clear.

I am trying to write a simple app that does CRUD operations on database
records.  The goal is for the app to make use of a tab panel where each
tab encapsulates one table from the database.  Each tab panel has two
groups (WebMarkupContainer).  The first, selectGroup, displays a list
(DDC) of the current items, and three buttons, add, edit and delete.
The second, editGroup, is displayed when either the add or edit button
was clicked on the select group, displays the record attributes and save
and cancel buttons.  The tab panel has a "selectedRecord" which is used
by both groups' components via PropertyModels. Very basic stuff.

When I choose a record and click the edit button, the record is
displayed in the edit group properly.  If I then choose cancel, the edit
group is no longer displayed and the select group DDC selection is null
as expected. I then choose another record from the list and click the
edit button and the previous record information is displayed in the edit
group even though the select group DDC shows the correct/selected
record.

This problem also occurs if I first choose to add a new record and then
cancel the add and then choose to edit a different record.  The DDC
shows the correct/selected record, but all the attributes in the edit
group are null/defaults for a new record.

If I remove the call to setDefaultFormProcessing(false) on the cancel
button, selecting other records for edit works correctly, but I can't
cancel a creating a new record if I use a RequiredTextField because the
form validation fails.

If I select a record for editing or save the newly created record, I can
select a different record for edit or create another one correctly.  So
I must be doing something wrong in the cancel logic. My editForm
(created in the EditGroup constructor) looks like this:

            Form editForm = new Form("editForm");
            
            editForm.add(new Label("nameLabel", "Name"));
            
            editForm.add(new Label("attributeLabel", "Attribute"));

            editForm.add(new RequiredTextField<String>("recordNameText",
                    new PropertyModel<String>(MyRecordPanel.this,
                            "selectedRecord.name")));

            editForm.add(new DropDownChoice<Lir>("attributes",
                    new PropertyModel<Attribute>(MyRecordPanel.this,
                            "selectedRecord.attribute"),
                    RateCentrePanel.this.getAttributes(),
                    new AttributeRenderer()));

            ....

            editForm.add(new Button("cancel")
            {
                private static final long serialVersionUID = 1L;

                public void onSubmit()
                {
                    MyRecordPanel.this.selectedRecord = null;
                    editGroup.setVisible(false);
                    selectGroup.setVisible(true);
                }
            }.setDefaultFormProcessing(false));

            add(editForm);

Other than setting the selectedRecord to null, what should I be doing
differently?

Thanks in advance!

Shelli

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


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


Re: Processing Flow for Button onSubmit and LDM load

Posted by Igor Vaynberg <ig...@gmail.com>.
the ldm's load() is called whenever ldm's getobject() is called, which
is called whenever *your* code uses the model. you are free to call
detach() on the ldm yourself if you need it to reload the value at
some point.

-igor

On Wed, Oct 6, 2010 at 3:05 PM, Shelli Orton <Sh...@sjrb.ca> wrote:
> Hi,
>
> Again, thanks to all who have been helping me as I am new to Wicket.  I
> am splitting out two issues I am dealing with to try to keep things
> clear.
>
> I am trying to write a simple app that does CRUD operations on database
> records.  The goal is for the app to make use of a tab panel where each
> tab encapsulates one table from the database.  Each tab panel has two
> groups (WebMarkupContainer).  The first, selectGroup, displays a list
> (DDC) of the current items, and three buttons, add, edit and delete.
> The DDC uses a LDM to get the list of records so that changes to the
> records are reflected on each request.
>
> When the save button is clicked the onSubmit method is called, then the
> LDM load method and then the detach method (twice).  Therefore the
> changes are reflected in the list when the page refreshes.
>
> However, when the delete button is clicked, the LDM load and detach
> methods are called and then the button's onSubmit.  Therefore the
> changes are not reflected in the list.  This same flow is followed by
> the cancel and add buttons, but since there are no changes made, it
> doesn't make a practical difference in those cases.
>
> Is it weird that the onSubmit is called before the LDM load and detach
> methods for one button and after for another?  Which is the expected
> processing flow?  Is there any way to change it so that the delete
> process matches the save process?
>
> Thanks in advance!
>
> Shelli
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


RE: Processing Flow for Button onSubmit and LDM load

Posted by Shelli Orton <Sh...@sjrb.ca>.
Again, does nobody have any suggestions?  If I can't get this fixed, I'm
going to have to write the app in another framework (possibly GWT) and
I'd really rather not have to do that.

Shelli

-----Original Message-----
From: Shelli Orton 
Sent: Wednesday, October 06, 2010 4:05 PM
To: users@wicket.apache.org
Subject: Processing Flow for Button onSubmit and LDM load

Hi,

Again, thanks to all who have been helping me as I am new to Wicket.  I
am splitting out two issues I am dealing with to try to keep things
clear.

I am trying to write a simple app that does CRUD operations on database
records.  The goal is for the app to make use of a tab panel where each
tab encapsulates one table from the database.  Each tab panel has two
groups (WebMarkupContainer).  The first, selectGroup, displays a list
(DDC) of the current items, and three buttons, add, edit and delete.
The DDC uses a LDM to get the list of records so that changes to the
records are reflected on each request.  

When the save button is clicked the onSubmit method is called, then the
LDM load method and then the detach method (twice).  Therefore the
changes are reflected in the list when the page refreshes.

However, when the delete button is clicked, the LDM load and detach
methods are called and then the button's onSubmit.  Therefore the
changes are not reflected in the list.  This same flow is followed by
the cancel and add buttons, but since there are no changes made, it
doesn't make a practical difference in those cases.

Is it weird that the onSubmit is called before the LDM load and detach
methods for one button and after for another?  Which is the expected
processing flow?  Is there any way to change it so that the delete
process matches the save process?

Thanks in advance!

Shelli

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


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


Processing Flow for Button onSubmit and LDM load

Posted by Shelli Orton <Sh...@sjrb.ca>.
Hi,

Again, thanks to all who have been helping me as I am new to Wicket.  I
am splitting out two issues I am dealing with to try to keep things
clear.

I am trying to write a simple app that does CRUD operations on database
records.  The goal is for the app to make use of a tab panel where each
tab encapsulates one table from the database.  Each tab panel has two
groups (WebMarkupContainer).  The first, selectGroup, displays a list
(DDC) of the current items, and three buttons, add, edit and delete.
The DDC uses a LDM to get the list of records so that changes to the
records are reflected on each request.  

When the save button is clicked the onSubmit method is called, then the
LDM load method and then the detach method (twice).  Therefore the
changes are reflected in the list when the page refreshes.

However, when the delete button is clicked, the LDM load and detach
methods are called and then the button's onSubmit.  Therefore the
changes are not reflected in the list.  This same flow is followed by
the cancel and add buttons, but since there are no changes made, it
doesn't make a practical difference in those cases.

Is it weird that the onSubmit is called before the LDM load and detach
methods for one button and after for another?  Which is the expected
processing flow?  Is there any way to change it so that the delete
process matches the save process?

Thanks in advance!

Shelli

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


PropertyModel Not Refreshing

Posted by Shelli Orton <Sh...@sjrb.ca>.
Hi,

First, thanks to all who have been helping me as I am new to Wicket.  I
am splitting out two issues I am dealing with to try to keep things
clear.

I am trying to write a simple app that does CRUD operations on database
records.  The goal is for the app to make use of a tab panel where each
tab encapsulates one table from the database.  Each tab panel has two
groups (WebMarkupContainer).  The first, selectGroup, displays a list
(DDC) of the current items, and three buttons, add, edit and delete.
The second, editGroup, is displayed when either the add or edit button
was clicked on the select group, displays the record attributes and save
and cancel buttons.  The tab panel has a "selectedRecord" which is used
by both groups' components via PropertyModels. Very basic stuff.

When I choose a record and click the edit button, the record is
displayed in the edit group properly.  If I then choose cancel, the edit
group is no longer displayed and the select group DDC selection is null
as expected. I then choose another record from the list and click the
edit button and the previous record information is displayed in the edit
group even though the select group DDC shows the correct/selected
record.

This problem also occurs if I first choose to add a new record and then
cancel the add and then choose to edit a different record.  The DDC
shows the correct/selected record, but all the attributes in the edit
group are null/defaults for a new record.

If I remove the call to setDefaultFormProcessing(false) on the cancel
button, selecting other records for edit works correctly, but I can't
cancel a creating a new record if I use a RequiredTextField because the
form validation fails.

If I select a record for editing or save the newly created record, I can
select a different record for edit or create another one correctly.  So
I must be doing something wrong in the cancel logic. My editForm
(created in the EditGroup constructor) looks like this:

            Form editForm = new Form("editForm");
            
            editForm.add(new Label("nameLabel", "Name"));
            
            editForm.add(new Label("attributeLabel", "Attribute"));

            editForm.add(new RequiredTextField<String>("recordNameText",
                    new PropertyModel<String>(MyRecordPanel.this,
                            "selectedRecord.name")));

            editForm.add(new DropDownChoice<Lir>("attributes",
                    new PropertyModel<Attribute>(MyRecordPanel.this,
                            "selectedRecord.attribute"),
                    RateCentrePanel.this.getAttributes(),
                    new AttributeRenderer()));

            ....

            editForm.add(new Button("cancel")
            {
                private static final long serialVersionUID = 1L;

                public void onSubmit()
                {
                    MyRecordPanel.this.selectedRecord = null;
                    editGroup.setVisible(false);
                    selectGroup.setVisible(true);
                }
            }.setDefaultFormProcessing(false));

            add(editForm);

Other than setting the selectedRecord to null, what should I be doing
differently?

Thanks in advance!

Shelli

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


RE: DropDownChoice/Model Confusion

Posted by Shelli Orton <Sh...@sjrb.ca>.
By removing the call to setDefaultFormProcessing(false) on the cancel button, the edit group is now updated as per the selection from the ddc.

However, I'm still having the ldm loading issue.  Can anyone provide any insight into why when the save button is clicked that the onSubmit method is called before the ldm.load, but the onSubmit is called after the ldm.load for the delete button?

Thanks for all the help!

Shelli

-----Original Message-----
From: Shelli Orton 
Sent: Wednesday, October 06, 2010 9:41 AM
To: users@wicket.apache.org
Subject: RE: DropDownChoice/Model Confusion

No, the getList() (called in the LDM load()) is only called once.  For the buttons add, edit and delete, the processng is like this:

- ldm.load() (which calls getList())
- button.onSubmit()
- ldm.detach() (called two times)

For the save button, the processing is:

- button.onSubmit()
- ldm.load()
- ldm.detach() (called two times)

I've discovered another anomaly in my code.  When I choose a record and click the edit button, the record is displayed in the edit group.  If I then choose cancel, the edit group is no longer displayed and the ddc selection is null. I then choose another record from the list and edit and the previous record information is displayed in the edit group even though the ddc shows the newly selected record.

I added get/set for the selectedRecord and set breakpoints, but those methods are never called.  Since the edit group components use PropertyModels, shouldn't the get method be called each time the page is submitted?

Shelli


-----Original Message-----
From: jcarman@carmanconsulting.com [mailto:jcarman@carmanconsulting.com] On Behalf Of James Carman
Sent: Tuesday, October 05, 2010 4:50 PM
To: users@wicket.apache.org
Subject: Re: DropDownChoice/Model Confusion

Is your getList() being called multiple times?

On Tue, Oct 5, 2010 at 6:37 PM, Shelli Orton <Sh...@sjrb.ca> wrote:
> I overrode the detach method in my class (which simply calls super.detach()) so I could set a breakpoint and see if it gets called and it does.
>
> Shelli
>
> -----Original Message-----
> From: Shelli Orton
> Sent: Tuesday, October 05, 2010 2:24 PM
> To: users@wicket.apache.org
> Subject: RE: DropDownChoice/Model Confusion
>
> I don't know how to determine that.
>
> -----Original Message-----
> From: jcarman@carmanconsulting.com [mailto:jcarman@carmanconsulting.com] On Behalf Of James Carman
> Sent: Tuesday, October 05, 2010 1:44 PM
> To: users@wicket.apache.org
> Subject: Re: DropDownChoice/Model Confusion
>
> Is it being detached?
>
> On Tue, Oct 5, 2010 at 3:26 PM, Shelli Orton <Sh...@sjrb.ca> wrote:
>> No, I'm not using AJAX.  Is there a way to force the LDB to reload?
>>
>> Shelli
>>
>> -----Original Message-----
>> From: jcgarciam [mailto:jcgarciam@gmail.com]
>> Sent: Tuesday, October 05, 2010 12:52 PM
>> To: users@wicket.apache.org
>> Subject: Re: DropDownChoice/Model Confusion
>>
>>
>> I dont think it may be related to the hierarchy, are you using AJAX?
>>
>> On Tue, Oct 5, 2010 at 2:38 PM, Shelli Orton [via Apache Wicket] <
>> ml-node+2956527-385265518-65838@n4.nabble.com<ml-node%2B2956527-38526551
>> 8-65838@n4.nabble.com>
>>> wrote:
>>
>>> Hmm, that code sort of works.  When I create or edit a record, the
>> list
>>> is updated.  However, when I delete a record it is not.  My component
>>> hierarchy is set up like this (hope it makes sense):
>>>
>>> TabPanel
>>>   - SelectForEditForm
>>>     - MyRecords (DDC)
>>>     - Add (Button)
>>>     - Edit (Button)
>>>     - Delete (Button)
>>>   - EditGroup (WebMarkupContainer)
>>>     - EditForm
>>>       - MyRecord Name (TextField)
>>>       - MyRecord Attribute (DDC)
>>>       - Save (Button)
>>>       - Cancel (Button)
>>>
>>> I created the EditGroup so that I can hide/display the edit panel.
>>> Debugging the application shows that the save button onSubmit is
>> called
>>> before the update of the myRecordsModel LDM and this is why the list
>> is
>>> updated when I create/edit a record. The delete button onSubmit is
>>> called after the update of the myRecordsModel LDM and that is why a
>>> deleted record is still visible in the list.
>>>
>>> I think the issue has something to do with the buttons being in
>>> different places in the component hierarchy. Can you provide any
>>> guidance on if there's some way to have the LDM updated after the
>> delete
>>> onSubmit?
>>>
>>> Thanks again,
>>> Shelli
>>>
>>> -----Original Message-----
>>> From: jcgarciam [mailto:[hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2956527&i=0>]
>>>
>>> Sent: Tuesday, October 05, 2010 9:33 AM
>>> To: [hidden email]
>> <http://user/SendEmail.jtp?type=node&node=2956527&i=1>
>>> Subject: Re: DropDownChoice/Model Confusion
>>>
>>>
>>> Yes, that should make your DDC to query the list any time it needs to
>> re
>>> render.
>>>
>>> To your 2nd. question in order to set a default or selected value,
>> just
>>> set
>>> a "MyRecord" reference to your property, keep in mind that your
>>> "MyRecord"
>>> should implement and equals/hashcode correctly.
>>>
>>>
>>> On Tue, Oct 5, 2010 at 12:00 PM, Shelli Orton [via Apache Wicket] <
>>> [hidden email]
>> <http://user/SendEmail.jtp?type=node&node=2956527&i=2><ml-node%2B2956214
>> -1797994
>>>
>>> [hidden email] <http://user/SendEmail.jtp?type=node&node=2956527&i=3>>
>>> > wrote:
>>>
>>> > Hi,
>>> >
>>> > Thanks for replying.  Just to clarify, do you mean do something like
>>> > this:
>>> >
>>> >
>>> >     LoadableDetachableModel<List<MyRecord>> myRecordsModel = new
>>> > LoadableDetachableModel<List<MyRecord>>()
>>> >     {
>>> >         @Override
>>> >         protected List<MyRecord> load()
>>> >         {
>>> >             return myRecordService.getList();
>>> >         }
>>> >     };
>>> >
>>> >     MyRecord selectedRecord;
>>> >
>>> >     form.add(new DropDownChoice<MyRecord>("records",
>>> >         new PropertyModel<MyRecord>(this, "selectedRecord"),
>>> >         myRecordsModel,
>>> >         new MyRecordRenderer()).setNullValid(false));
>>> >
>>> > Shelli
>>> >
>>> > -----Original Message-----
>>> > From: jcgarciam [mailto:[hidden
>>> email]<http://user/SendEmail.jtp?type=node&node=2956214&i=0>]
>>> >
>>> > Sent: Monday, October 04, 2010 6:27 PM
>>> > To: [hidden email]
>>> <http://user/SendEmail.jtp?type=node&node=2956214&i=1>
>>> > Subject: Re: DropDownChoice/Model Confusion
>>> >
>>> >
>>> > Hi, instead of passing  "getMyRecords()" in the constructor wrap it
>>> > around
>>> > a LoadableDetachableModel and pass that model to the DDC. The
>>> difference
>>> > is
>>> > that your current list is fetch only once at construction of your
>>> pages
>>>
>>> > and
>>> > is considered static because its never get called again unless you
>>> > triggered
>>> > it by entering to a new page instance, while by using a LDM the
>>> > component
>>> > will ask for it every time it needs to re-render them.
>>> >
>>> >
>>> > On Mon, Oct 4, 2010 at 6:52 PM, Shelli Orton [via Apache Wicket] <
>>> > [hidden email]
>>>
>> <http://user/SendEmail.jtp?type=node&node=2956214&i=2><ml-node%2B2955144
>>> -66557051
>>>
>>> >
>>> > [hidden email]
>> <http://user/SendEmail.jtp?type=node&node=2956214&i=3>>
>>> > > wrote:
>>> >
>>> > > I am writing a (simple?) database CRUD app where I have multiple
>> tab
>>> > > panels that encapsulate the different tables in the database.  On
>> a
>>> > > panel there's a dropdownchoice which lists the existing records
>> for
>>> > that
>>> > > table.  There's also create, delete and edit buttons (and and edit
>>> > panel
>>> > > with save and cancel buttons).  When I create, edit or delete any
>> of
>>> > the
>>> > > records, the dropdownchoice list doesn't reflect the changes until
>> I
>>> > > open a new session.  So my question is how to reload the list
>> after
>>> > one
>>> > > of these actions is done?
>>> > >
>>> > > Currently my dropdownchoice model is set like this:
>>> > >
>>> > >     MyRecord selectedRecord;
>>> > >     ...
>>> > >     form.add(new DropDownChoice<MyRecord>("records",
>>> > >         new PropertyModel<MyRecord>(this, "selectedRecord"),
>>> > >         getMyRecords(), // method that retrieves from the database
>>> > (via
>>> > > JPA)
>>> > >         new MyRecordRenderer()).setNullValid(false)); // used to
>>> > return
>>> > > the display attribute of MyRecord
>>> > >
>>> > > I am trying to understand if using a LoadableDetachableModel will
>> do
>>> > the
>>> >
>>> > > reload that I want. Also, I don't know how to set the
>> selectedRecord
>>> > > using that type of model or if it's even possible.
>>> > >
>>> > > Any advice?
>>> > >
>>> > > Thanks!
>>> > >
>>> > > Shelli
>>> > >
>>> > >
>>> ---------------------------------------------------------------------
>>>
>>> > > To unsubscribe, e-mail: [hidden
>>> > email]<http://user/SendEmail.jtp?type=node&node=2955144&i=0>
>>> > > For additional commands, e-mail: [hidden
>>> > email]<http://user/SendEmail.jtp?type=node&node=2955144&i=1>
>>> > >
>>> > >
>>> > >
>>> > > ------------------------------
>>> > >  View message @
>>> > >
>>> >
>>>
>> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
>> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
>> o?by-user=t>
>>>
>> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
>> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
>> ?by-user=t>
>>> o?by-user=t>
>>> > n-tp2955144p2955144.html
>>> > > To start a new topic under Apache Wicket, email
>>> > >
>>> > [hidden email]
>>>
>> <http://user/SendEmail.jtp?type=node&node=2956214&i=4><ml-node%2B1842946
>>> -39801187
>>> >
>>> > [hidden email]
>> <http://user/SendEmail.jtp?type=node&node=2956214&i=5>>
>>> > > To unsubscribe from Apache Wicket, click
>>> >
>>>
>> here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp<
>> http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-us
>> er=t><
>>>
>>>
>> http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-us
>> <http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-u
>> s&by-user=t>
>>> er=t>?
>>> >
>>> >
>>>
>> tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
>>>
>>> > QyOTQ2fDEyNTYxMzc3ODY=>.
>>> > >
>>> > >
>>> > >
>>> >
>>> >
>>> > --
>>> > Sincerely,
>>> > JC (http://www.linkedin.com/in/jcgarciam)
>>> > Work smarter, not harder!.
>>> >
>>> > --
>>> > View this message in context:
>>> >
>>>
>> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
>> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
>> o?by-user=t>
>>>
>> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
>> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
>> ?by-user=t>
>>> o?by-user=t>
>>> > n-tp2955144p2955255.html
>>> > Sent from the Users forum mailing list archive at Nabble.com.
>>> >
>>> >
>> ---------------------------------------------------------------------
>>> > To unsubscribe, e-mail: [hidden
>>> email]<http://user/SendEmail.jtp?type=node&node=2956214&i=6>
>>> > For additional commands, e-mail: [hidden
>>> email]<http://user/SendEmail.jtp?type=node&node=2956214&i=7>
>>> >
>>> >
>>> >
>> ---------------------------------------------------------------------
>>> > To unsubscribe, e-mail: [hidden
>>> email]<http://user/SendEmail.jtp?type=node&node=2956214&i=8>
>>> > For additional commands, e-mail: [hidden
>>> email]<http://user/SendEmail.jtp?type=node&node=2956214&i=9>
>>> >
>>> >
>>> >
>>> > ------------------------------
>>> >  View message @
>>> >
>>>
>> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
>> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
>> o?by-user=t>
>>> n-tp2955144p2956214.html
>>> > To start a new topic under Apache Wicket, email
>>> >
>>> [hidden email]
>> <http://user/SendEmail.jtp?type=node&node=2956527&i=4><ml-node%2B1842946
>> -39801187
>>>
>>> [hidden email] <http://user/SendEmail.jtp?type=node&node=2956527&i=5>>
>>> > To unsubscribe from Apache Wicket, click
>>>
>> here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp<
>> http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-us
>> er=t>?
>>>
>>>
>> tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
>>> QyOTQ2fDEyNTYxMzc3ODY=>.
>>> >
>>> >
>>> >
>>>
>>>
>>> --
>>> Sincerely,
>>> JC (http://www.linkedin.com/in/jcgarciam)
>>> Work smarter, not harder!.
>>>
>>> --
>>> View this message in context:
>>>
>> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
>> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
>> o?by-user=t>
>>> n-tp2955144p2956283.html
>>> Sent from the Users forum mailing list archive at Nabble.com.
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2956527&i=6>
>>> For additional commands, e-mail: [hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2956527&i=7>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2956527&i=8>
>>> For additional commands, e-mail: [hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2956527&i=9>
>>>
>>>
>>>
>>> ------------------------------
>>>  View message @
>>>
>> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
>> n-tp2955144p2956527.html
>>> To start a new topic under Apache Wicket, email
>>>
>> ml-node+1842946-398011874-65838@n4.nabble.com<ml-node%2B1842946-39801187
>> 4-65838@n4.nabble.com>
>>> To unsubscribe from Apache Wicket, click
>> here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?
>> tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
>> QyOTQ2fDEyNTYxMzc3ODY=>.
>>>
>>>
>>>
>>
>>
>> --
>> Sincerely,
>> JC (http://www.linkedin.com/in/jcgarciam)
>> Work smarter, not harder!.
>>
>> --
>> View this message in context:
>> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
>> n-tp2955144p2956669.html
>> Sent from the Users forum mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


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


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


RE: DropDownChoice/Model Confusion

Posted by Shelli Orton <Sh...@sjrb.ca>.
I don't understand what you mean by "between requests".

-----Original Message-----
From: jcarman@carmanconsulting.com [mailto:jcarman@carmanconsulting.com] On Behalf Of James Carman
Sent: Wednesday, October 06, 2010 9:43 AM
To: users@wicket.apache.org
Subject: Re: DropDownChoice/Model Confusion

I meant between requests

On Wed, Oct 6, 2010 at 11:41 AM, Shelli Orton <Sh...@sjrb.ca> wrote:
> No, the getList() (called in the LDM load()) is only called once.  For the buttons add, edit and delete, the processng is like this:
>
> - ldm.load() (which calls getList())
> - button.onSubmit()
> - ldm.detach() (called two times)
>
> For the save button, the processing is:
>
> - button.onSubmit()
> - ldm.load()
> - ldm.detach() (called two times)
>
> I've discovered another anomaly in my code.  When I choose a record and click the edit button, the record is displayed in the edit group.  If I then choose cancel, the edit group is no longer displayed and the ddc selection is null. I then choose another record from the list and edit and the previous record information is displayed in the edit group even though the ddc shows the newly selected record.
>
> I added get/set for the selectedRecord and set breakpoints, but those methods are never called.  Since the edit group components use PropertyModels, shouldn't the get method be called each time the page is submitted?
>
> Shelli
>
>
> -----Original Message-----
> From: jcarman@carmanconsulting.com [mailto:jcarman@carmanconsulting.com] On Behalf Of James Carman
> Sent: Tuesday, October 05, 2010 4:50 PM
> To: users@wicket.apache.org
> Subject: Re: DropDownChoice/Model Confusion
>
> Is your getList() being called multiple times?
>
> On Tue, Oct 5, 2010 at 6:37 PM, Shelli Orton <Sh...@sjrb.ca> wrote:
>> I overrode the detach method in my class (which simply calls super.detach()) so I could set a breakpoint and see if it gets called and it does.
>>
>> Shelli
>>
>> -----Original Message-----
>> From: Shelli Orton
>> Sent: Tuesday, October 05, 2010 2:24 PM
>> To: users@wicket.apache.org
>> Subject: RE: DropDownChoice/Model Confusion
>>
>> I don't know how to determine that.
>>
>> -----Original Message-----
>> From: jcarman@carmanconsulting.com [mailto:jcarman@carmanconsulting.com] On Behalf Of James Carman
>> Sent: Tuesday, October 05, 2010 1:44 PM
>> To: users@wicket.apache.org
>> Subject: Re: DropDownChoice/Model Confusion
>>
>> Is it being detached?
>>
>> On Tue, Oct 5, 2010 at 3:26 PM, Shelli Orton <Sh...@sjrb.ca> wrote:
>>> No, I'm not using AJAX.  Is there a way to force the LDB to reload?
>>>
>>> Shelli
>>>
>>> -----Original Message-----
>>> From: jcgarciam [mailto:jcgarciam@gmail.com]
>>> Sent: Tuesday, October 05, 2010 12:52 PM
>>> To: users@wicket.apache.org
>>> Subject: Re: DropDownChoice/Model Confusion
>>>
>>>
>>> I dont think it may be related to the hierarchy, are you using AJAX?
>>>
>>> On Tue, Oct 5, 2010 at 2:38 PM, Shelli Orton [via Apache Wicket] <
>>> ml-node+2956527-385265518-65838@n4.nabble.com<ml-node%2B2956527-38526551
>>> 8-65838@n4.nabble.com>
>>>> wrote:
>>>
>>>> Hmm, that code sort of works.  When I create or edit a record, the
>>> list
>>>> is updated.  However, when I delete a record it is not.  My component
>>>> hierarchy is set up like this (hope it makes sense):
>>>>
>>>> TabPanel
>>>>   - SelectForEditForm
>>>>     - MyRecords (DDC)
>>>>     - Add (Button)
>>>>     - Edit (Button)
>>>>     - Delete (Button)
>>>>   - EditGroup (WebMarkupContainer)
>>>>     - EditForm
>>>>       - MyRecord Name (TextField)
>>>>       - MyRecord Attribute (DDC)
>>>>       - Save (Button)
>>>>       - Cancel (Button)
>>>>
>>>> I created the EditGroup so that I can hide/display the edit panel.
>>>> Debugging the application shows that the save button onSubmit is
>>> called
>>>> before the update of the myRecordsModel LDM and this is why the list
>>> is
>>>> updated when I create/edit a record. The delete button onSubmit is
>>>> called after the update of the myRecordsModel LDM and that is why a
>>>> deleted record is still visible in the list.
>>>>
>>>> I think the issue has something to do with the buttons being in
>>>> different places in the component hierarchy. Can you provide any
>>>> guidance on if there's some way to have the LDM updated after the
>>> delete
>>>> onSubmit?
>>>>
>>>> Thanks again,
>>>> Shelli
>>>>
>>>> -----Original Message-----
>>>> From: jcgarciam [mailto:[hidden
>>> email]<http://user/SendEmail.jtp?type=node&node=2956527&i=0>]
>>>>
>>>> Sent: Tuesday, October 05, 2010 9:33 AM
>>>> To: [hidden email]
>>> <http://user/SendEmail.jtp?type=node&node=2956527&i=1>
>>>> Subject: Re: DropDownChoice/Model Confusion
>>>>
>>>>
>>>> Yes, that should make your DDC to query the list any time it needs to
>>> re
>>>> render.
>>>>
>>>> To your 2nd. question in order to set a default or selected value,
>>> just
>>>> set
>>>> a "MyRecord" reference to your property, keep in mind that your
>>>> "MyRecord"
>>>> should implement and equals/hashcode correctly.
>>>>
>>>>
>>>> On Tue, Oct 5, 2010 at 12:00 PM, Shelli Orton [via Apache Wicket] <
>>>> [hidden email]
>>> <http://user/SendEmail.jtp?type=node&node=2956527&i=2><ml-node%2B2956214
>>> -1797994
>>>>
>>>> [hidden email] <http://user/SendEmail.jtp?type=node&node=2956527&i=3>>
>>>> > wrote:
>>>>
>>>> > Hi,
>>>> >
>>>> > Thanks for replying.  Just to clarify, do you mean do something like
>>>> > this:
>>>> >
>>>> >
>>>> >     LoadableDetachableModel<List<MyRecord>> myRecordsModel = new
>>>> > LoadableDetachableModel<List<MyRecord>>()
>>>> >     {
>>>> >         @Override
>>>> >         protected List<MyRecord> load()
>>>> >         {
>>>> >             return myRecordService.getList();
>>>> >         }
>>>> >     };
>>>> >
>>>> >     MyRecord selectedRecord;
>>>> >
>>>> >     form.add(new DropDownChoice<MyRecord>("records",
>>>> >         new PropertyModel<MyRecord>(this, "selectedRecord"),
>>>> >         myRecordsModel,
>>>> >         new MyRecordRenderer()).setNullValid(false));
>>>> >
>>>> > Shelli
>>>> >
>>>> > -----Original Message-----
>>>> > From: jcgarciam [mailto:[hidden
>>>> email]<http://user/SendEmail.jtp?type=node&node=2956214&i=0>]
>>>> >
>>>> > Sent: Monday, October 04, 2010 6:27 PM
>>>> > To: [hidden email]
>>>> <http://user/SendEmail.jtp?type=node&node=2956214&i=1>
>>>> > Subject: Re: DropDownChoice/Model Confusion
>>>> >
>>>> >
>>>> > Hi, instead of passing  "getMyRecords()" in the constructor wrap it
>>>> > around
>>>> > a LoadableDetachableModel and pass that model to the DDC. The
>>>> difference
>>>> > is
>>>> > that your current list is fetch only once at construction of your
>>>> pages
>>>>
>>>> > and
>>>> > is considered static because its never get called again unless you
>>>> > triggered
>>>> > it by entering to a new page instance, while by using a LDM the
>>>> > component
>>>> > will ask for it every time it needs to re-render them.
>>>> >
>>>> >
>>>> > On Mon, Oct 4, 2010 at 6:52 PM, Shelli Orton [via Apache Wicket] <
>>>> > [hidden email]
>>>>
>>> <http://user/SendEmail.jtp?type=node&node=2956214&i=2><ml-node%2B2955144
>>>> -66557051
>>>>
>>>> >
>>>> > [hidden email]
>>> <http://user/SendEmail.jtp?type=node&node=2956214&i=3>>
>>>> > > wrote:
>>>> >
>>>> > > I am writing a (simple?) database CRUD app where I have multiple
>>> tab
>>>> > > panels that encapsulate the different tables in the database.  On
>>> a
>>>> > > panel there's a dropdownchoice which lists the existing records
>>> for
>>>> > that
>>>> > > table.  There's also create, delete and edit buttons (and and edit
>>>> > panel
>>>> > > with save and cancel buttons).  When I create, edit or delete any
>>> of
>>>> > the
>>>> > > records, the dropdownchoice list doesn't reflect the changes until
>>> I
>>>> > > open a new session.  So my question is how to reload the list
>>> after
>>>> > one
>>>> > > of these actions is done?
>>>> > >
>>>> > > Currently my dropdownchoice model is set like this:
>>>> > >
>>>> > >     MyRecord selectedRecord;
>>>> > >     ...
>>>> > >     form.add(new DropDownChoice<MyRecord>("records",
>>>> > >         new PropertyModel<MyRecord>(this, "selectedRecord"),
>>>> > >         getMyRecords(), // method that retrieves from the database
>>>> > (via
>>>> > > JPA)
>>>> > >         new MyRecordRenderer()).setNullValid(false)); // used to
>>>> > return
>>>> > > the display attribute of MyRecord
>>>> > >
>>>> > > I am trying to understand if using a LoadableDetachableModel will
>>> do
>>>> > the
>>>> >
>>>> > > reload that I want. Also, I don't know how to set the
>>> selectedRecord
>>>> > > using that type of model or if it's even possible.
>>>> > >
>>>> > > Any advice?
>>>> > >
>>>> > > Thanks!
>>>> > >
>>>> > > Shelli
>>>> > >
>>>> > >
>>>> ---------------------------------------------------------------------
>>>>
>>>> > > To unsubscribe, e-mail: [hidden
>>>> > email]<http://user/SendEmail.jtp?type=node&node=2955144&i=0>
>>>> > > For additional commands, e-mail: [hidden
>>>> > email]<http://user/SendEmail.jtp?type=node&node=2955144&i=1>
>>>> > >
>>>> > >
>>>> > >
>>>> > > ------------------------------
>>>> > >  View message @
>>>> > >
>>>> >
>>>>
>>> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
>>> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
>>> o?by-user=t>
>>>>
>>> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
>>> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
>>> ?by-user=t>
>>>> o?by-user=t>
>>>> > n-tp2955144p2955144.html
>>>> > > To start a new topic under Apache Wicket, email
>>>> > >
>>>> > [hidden email]
>>>>
>>> <http://user/SendEmail.jtp?type=node&node=2956214&i=4><ml-node%2B1842946
>>>> -39801187
>>>> >
>>>> > [hidden email]
>>> <http://user/SendEmail.jtp?type=node&node=2956214&i=5>>
>>>> > > To unsubscribe from Apache Wicket, click
>>>> >
>>>>
>>> here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp<
>>> http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-us
>>> er=t><
>>>>
>>>>
>>> http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-us
>>> <http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-u
>>> s&by-user=t>
>>>> er=t>?
>>>> >
>>>> >
>>>>
>>> tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
>>>>
>>>> > QyOTQ2fDEyNTYxMzc3ODY=>.
>>>> > >
>>>> > >
>>>> > >
>>>> >
>>>> >
>>>> > --
>>>> > Sincerely,
>>>> > JC (http://www.linkedin.com/in/jcgarciam)
>>>> > Work smarter, not harder!.
>>>> >
>>>> > --
>>>> > View this message in context:
>>>> >
>>>>
>>> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
>>> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
>>> o?by-user=t>
>>>>
>>> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
>>> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
>>> ?by-user=t>
>>>> o?by-user=t>
>>>> > n-tp2955144p2955255.html
>>>> > Sent from the Users forum mailing list archive at Nabble.com.
>>>> >
>>>> >
>>> ---------------------------------------------------------------------
>>>> > To unsubscribe, e-mail: [hidden
>>>> email]<http://user/SendEmail.jtp?type=node&node=2956214&i=6>
>>>> > For additional commands, e-mail: [hidden
>>>> email]<http://user/SendEmail.jtp?type=node&node=2956214&i=7>
>>>> >
>>>> >
>>>> >
>>> ---------------------------------------------------------------------
>>>> > To unsubscribe, e-mail: [hidden
>>>> email]<http://user/SendEmail.jtp?type=node&node=2956214&i=8>
>>>> > For additional commands, e-mail: [hidden
>>>> email]<http://user/SendEmail.jtp?type=node&node=2956214&i=9>
>>>> >
>>>> >
>>>> >
>>>> > ------------------------------
>>>> >  View message @
>>>> >
>>>>
>>> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
>>> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
>>> o?by-user=t>
>>>> n-tp2955144p2956214.html
>>>> > To start a new topic under Apache Wicket, email
>>>> >
>>>> [hidden email]
>>> <http://user/SendEmail.jtp?type=node&node=2956527&i=4><ml-node%2B1842946
>>> -39801187
>>>>
>>>> [hidden email] <http://user/SendEmail.jtp?type=node&node=2956527&i=5>>
>>>> > To unsubscribe from Apache Wicket, click
>>>>
>>> here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp<
>>> http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-us
>>> er=t>?
>>>>
>>>>
>>> tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
>>>> QyOTQ2fDEyNTYxMzc3ODY=>.
>>>> >
>>>> >
>>>> >
>>>>
>>>>
>>>> --
>>>> Sincerely,
>>>> JC (http://www.linkedin.com/in/jcgarciam)
>>>> Work smarter, not harder!.
>>>>
>>>> --
>>>> View this message in context:
>>>>
>>> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
>>> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
>>> o?by-user=t>
>>>> n-tp2955144p2956283.html
>>>> Sent from the Users forum mailing list archive at Nabble.com.
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: [hidden
>>> email]<http://user/SendEmail.jtp?type=node&node=2956527&i=6>
>>>> For additional commands, e-mail: [hidden
>>> email]<http://user/SendEmail.jtp?type=node&node=2956527&i=7>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: [hidden
>>> email]<http://user/SendEmail.jtp?type=node&node=2956527&i=8>
>>>> For additional commands, e-mail: [hidden
>>> email]<http://user/SendEmail.jtp?type=node&node=2956527&i=9>
>>>>
>>>>
>>>>
>>>> ------------------------------
>>>>  View message @
>>>>
>>> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
>>> n-tp2955144p2956527.html
>>>> To start a new topic under Apache Wicket, email
>>>>
>>> ml-node+1842946-398011874-65838@n4.nabble.com<ml-node%2B1842946-39801187
>>> 4-65838@n4.nabble.com>
>>>> To unsubscribe from Apache Wicket, click
>>> here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?
>>> tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
>>> QyOTQ2fDEyNTYxMzc3ODY=>.
>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> Sincerely,
>>> JC (http://www.linkedin.com/in/jcgarciam)
>>> Work smarter, not harder!.
>>>
>>> --
>>> View this message in context:
>>> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
>>> n-tp2955144p2956669.html
>>> Sent from the Users forum mailing list archive at Nabble.com.
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


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


Re: DropDownChoice/Model Confusion

Posted by James Carman <ja...@carmanconsulting.com>.
I meant between requests

On Wed, Oct 6, 2010 at 11:41 AM, Shelli Orton <Sh...@sjrb.ca> wrote:
> No, the getList() (called in the LDM load()) is only called once.  For the buttons add, edit and delete, the processng is like this:
>
> - ldm.load() (which calls getList())
> - button.onSubmit()
> - ldm.detach() (called two times)
>
> For the save button, the processing is:
>
> - button.onSubmit()
> - ldm.load()
> - ldm.detach() (called two times)
>
> I've discovered another anomaly in my code.  When I choose a record and click the edit button, the record is displayed in the edit group.  If I then choose cancel, the edit group is no longer displayed and the ddc selection is null. I then choose another record from the list and edit and the previous record information is displayed in the edit group even though the ddc shows the newly selected record.
>
> I added get/set for the selectedRecord and set breakpoints, but those methods are never called.  Since the edit group components use PropertyModels, shouldn't the get method be called each time the page is submitted?
>
> Shelli
>
>
> -----Original Message-----
> From: jcarman@carmanconsulting.com [mailto:jcarman@carmanconsulting.com] On Behalf Of James Carman
> Sent: Tuesday, October 05, 2010 4:50 PM
> To: users@wicket.apache.org
> Subject: Re: DropDownChoice/Model Confusion
>
> Is your getList() being called multiple times?
>
> On Tue, Oct 5, 2010 at 6:37 PM, Shelli Orton <Sh...@sjrb.ca> wrote:
>> I overrode the detach method in my class (which simply calls super.detach()) so I could set a breakpoint and see if it gets called and it does.
>>
>> Shelli
>>
>> -----Original Message-----
>> From: Shelli Orton
>> Sent: Tuesday, October 05, 2010 2:24 PM
>> To: users@wicket.apache.org
>> Subject: RE: DropDownChoice/Model Confusion
>>
>> I don't know how to determine that.
>>
>> -----Original Message-----
>> From: jcarman@carmanconsulting.com [mailto:jcarman@carmanconsulting.com] On Behalf Of James Carman
>> Sent: Tuesday, October 05, 2010 1:44 PM
>> To: users@wicket.apache.org
>> Subject: Re: DropDownChoice/Model Confusion
>>
>> Is it being detached?
>>
>> On Tue, Oct 5, 2010 at 3:26 PM, Shelli Orton <Sh...@sjrb.ca> wrote:
>>> No, I'm not using AJAX.  Is there a way to force the LDB to reload?
>>>
>>> Shelli
>>>
>>> -----Original Message-----
>>> From: jcgarciam [mailto:jcgarciam@gmail.com]
>>> Sent: Tuesday, October 05, 2010 12:52 PM
>>> To: users@wicket.apache.org
>>> Subject: Re: DropDownChoice/Model Confusion
>>>
>>>
>>> I dont think it may be related to the hierarchy, are you using AJAX?
>>>
>>> On Tue, Oct 5, 2010 at 2:38 PM, Shelli Orton [via Apache Wicket] <
>>> ml-node+2956527-385265518-65838@n4.nabble.com<ml-node%2B2956527-38526551
>>> 8-65838@n4.nabble.com>
>>>> wrote:
>>>
>>>> Hmm, that code sort of works.  When I create or edit a record, the
>>> list
>>>> is updated.  However, when I delete a record it is not.  My component
>>>> hierarchy is set up like this (hope it makes sense):
>>>>
>>>> TabPanel
>>>>   - SelectForEditForm
>>>>     - MyRecords (DDC)
>>>>     - Add (Button)
>>>>     - Edit (Button)
>>>>     - Delete (Button)
>>>>   - EditGroup (WebMarkupContainer)
>>>>     - EditForm
>>>>       - MyRecord Name (TextField)
>>>>       - MyRecord Attribute (DDC)
>>>>       - Save (Button)
>>>>       - Cancel (Button)
>>>>
>>>> I created the EditGroup so that I can hide/display the edit panel.
>>>> Debugging the application shows that the save button onSubmit is
>>> called
>>>> before the update of the myRecordsModel LDM and this is why the list
>>> is
>>>> updated when I create/edit a record. The delete button onSubmit is
>>>> called after the update of the myRecordsModel LDM and that is why a
>>>> deleted record is still visible in the list.
>>>>
>>>> I think the issue has something to do with the buttons being in
>>>> different places in the component hierarchy. Can you provide any
>>>> guidance on if there's some way to have the LDM updated after the
>>> delete
>>>> onSubmit?
>>>>
>>>> Thanks again,
>>>> Shelli
>>>>
>>>> -----Original Message-----
>>>> From: jcgarciam [mailto:[hidden
>>> email]<http://user/SendEmail.jtp?type=node&node=2956527&i=0>]
>>>>
>>>> Sent: Tuesday, October 05, 2010 9:33 AM
>>>> To: [hidden email]
>>> <http://user/SendEmail.jtp?type=node&node=2956527&i=1>
>>>> Subject: Re: DropDownChoice/Model Confusion
>>>>
>>>>
>>>> Yes, that should make your DDC to query the list any time it needs to
>>> re
>>>> render.
>>>>
>>>> To your 2nd. question in order to set a default or selected value,
>>> just
>>>> set
>>>> a "MyRecord" reference to your property, keep in mind that your
>>>> "MyRecord"
>>>> should implement and equals/hashcode correctly.
>>>>
>>>>
>>>> On Tue, Oct 5, 2010 at 12:00 PM, Shelli Orton [via Apache Wicket] <
>>>> [hidden email]
>>> <http://user/SendEmail.jtp?type=node&node=2956527&i=2><ml-node%2B2956214
>>> -1797994
>>>>
>>>> [hidden email] <http://user/SendEmail.jtp?type=node&node=2956527&i=3>>
>>>> > wrote:
>>>>
>>>> > Hi,
>>>> >
>>>> > Thanks for replying.  Just to clarify, do you mean do something like
>>>> > this:
>>>> >
>>>> >
>>>> >     LoadableDetachableModel<List<MyRecord>> myRecordsModel = new
>>>> > LoadableDetachableModel<List<MyRecord>>()
>>>> >     {
>>>> >         @Override
>>>> >         protected List<MyRecord> load()
>>>> >         {
>>>> >             return myRecordService.getList();
>>>> >         }
>>>> >     };
>>>> >
>>>> >     MyRecord selectedRecord;
>>>> >
>>>> >     form.add(new DropDownChoice<MyRecord>("records",
>>>> >         new PropertyModel<MyRecord>(this, "selectedRecord"),
>>>> >         myRecordsModel,
>>>> >         new MyRecordRenderer()).setNullValid(false));
>>>> >
>>>> > Shelli
>>>> >
>>>> > -----Original Message-----
>>>> > From: jcgarciam [mailto:[hidden
>>>> email]<http://user/SendEmail.jtp?type=node&node=2956214&i=0>]
>>>> >
>>>> > Sent: Monday, October 04, 2010 6:27 PM
>>>> > To: [hidden email]
>>>> <http://user/SendEmail.jtp?type=node&node=2956214&i=1>
>>>> > Subject: Re: DropDownChoice/Model Confusion
>>>> >
>>>> >
>>>> > Hi, instead of passing  "getMyRecords()" in the constructor wrap it
>>>> > around
>>>> > a LoadableDetachableModel and pass that model to the DDC. The
>>>> difference
>>>> > is
>>>> > that your current list is fetch only once at construction of your
>>>> pages
>>>>
>>>> > and
>>>> > is considered static because its never get called again unless you
>>>> > triggered
>>>> > it by entering to a new page instance, while by using a LDM the
>>>> > component
>>>> > will ask for it every time it needs to re-render them.
>>>> >
>>>> >
>>>> > On Mon, Oct 4, 2010 at 6:52 PM, Shelli Orton [via Apache Wicket] <
>>>> > [hidden email]
>>>>
>>> <http://user/SendEmail.jtp?type=node&node=2956214&i=2><ml-node%2B2955144
>>>> -66557051
>>>>
>>>> >
>>>> > [hidden email]
>>> <http://user/SendEmail.jtp?type=node&node=2956214&i=3>>
>>>> > > wrote:
>>>> >
>>>> > > I am writing a (simple?) database CRUD app where I have multiple
>>> tab
>>>> > > panels that encapsulate the different tables in the database.  On
>>> a
>>>> > > panel there's a dropdownchoice which lists the existing records
>>> for
>>>> > that
>>>> > > table.  There's also create, delete and edit buttons (and and edit
>>>> > panel
>>>> > > with save and cancel buttons).  When I create, edit or delete any
>>> of
>>>> > the
>>>> > > records, the dropdownchoice list doesn't reflect the changes until
>>> I
>>>> > > open a new session.  So my question is how to reload the list
>>> after
>>>> > one
>>>> > > of these actions is done?
>>>> > >
>>>> > > Currently my dropdownchoice model is set like this:
>>>> > >
>>>> > >     MyRecord selectedRecord;
>>>> > >     ...
>>>> > >     form.add(new DropDownChoice<MyRecord>("records",
>>>> > >         new PropertyModel<MyRecord>(this, "selectedRecord"),
>>>> > >         getMyRecords(), // method that retrieves from the database
>>>> > (via
>>>> > > JPA)
>>>> > >         new MyRecordRenderer()).setNullValid(false)); // used to
>>>> > return
>>>> > > the display attribute of MyRecord
>>>> > >
>>>> > > I am trying to understand if using a LoadableDetachableModel will
>>> do
>>>> > the
>>>> >
>>>> > > reload that I want. Also, I don't know how to set the
>>> selectedRecord
>>>> > > using that type of model or if it's even possible.
>>>> > >
>>>> > > Any advice?
>>>> > >
>>>> > > Thanks!
>>>> > >
>>>> > > Shelli
>>>> > >
>>>> > >
>>>> ---------------------------------------------------------------------
>>>>
>>>> > > To unsubscribe, e-mail: [hidden
>>>> > email]<http://user/SendEmail.jtp?type=node&node=2955144&i=0>
>>>> > > For additional commands, e-mail: [hidden
>>>> > email]<http://user/SendEmail.jtp?type=node&node=2955144&i=1>
>>>> > >
>>>> > >
>>>> > >
>>>> > > ------------------------------
>>>> > >  View message @
>>>> > >
>>>> >
>>>>
>>> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
>>> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
>>> o?by-user=t>
>>>>
>>> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
>>> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
>>> ?by-user=t>
>>>> o?by-user=t>
>>>> > n-tp2955144p2955144.html
>>>> > > To start a new topic under Apache Wicket, email
>>>> > >
>>>> > [hidden email]
>>>>
>>> <http://user/SendEmail.jtp?type=node&node=2956214&i=4><ml-node%2B1842946
>>>> -39801187
>>>> >
>>>> > [hidden email]
>>> <http://user/SendEmail.jtp?type=node&node=2956214&i=5>>
>>>> > > To unsubscribe from Apache Wicket, click
>>>> >
>>>>
>>> here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp<
>>> http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-us
>>> er=t><
>>>>
>>>>
>>> http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-us
>>> <http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-u
>>> s&by-user=t>
>>>> er=t>?
>>>> >
>>>> >
>>>>
>>> tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
>>>>
>>>> > QyOTQ2fDEyNTYxMzc3ODY=>.
>>>> > >
>>>> > >
>>>> > >
>>>> >
>>>> >
>>>> > --
>>>> > Sincerely,
>>>> > JC (http://www.linkedin.com/in/jcgarciam)
>>>> > Work smarter, not harder!.
>>>> >
>>>> > --
>>>> > View this message in context:
>>>> >
>>>>
>>> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
>>> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
>>> o?by-user=t>
>>>>
>>> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
>>> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
>>> ?by-user=t>
>>>> o?by-user=t>
>>>> > n-tp2955144p2955255.html
>>>> > Sent from the Users forum mailing list archive at Nabble.com.
>>>> >
>>>> >
>>> ---------------------------------------------------------------------
>>>> > To unsubscribe, e-mail: [hidden
>>>> email]<http://user/SendEmail.jtp?type=node&node=2956214&i=6>
>>>> > For additional commands, e-mail: [hidden
>>>> email]<http://user/SendEmail.jtp?type=node&node=2956214&i=7>
>>>> >
>>>> >
>>>> >
>>> ---------------------------------------------------------------------
>>>> > To unsubscribe, e-mail: [hidden
>>>> email]<http://user/SendEmail.jtp?type=node&node=2956214&i=8>
>>>> > For additional commands, e-mail: [hidden
>>>> email]<http://user/SendEmail.jtp?type=node&node=2956214&i=9>
>>>> >
>>>> >
>>>> >
>>>> > ------------------------------
>>>> >  View message @
>>>> >
>>>>
>>> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
>>> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
>>> o?by-user=t>
>>>> n-tp2955144p2956214.html
>>>> > To start a new topic under Apache Wicket, email
>>>> >
>>>> [hidden email]
>>> <http://user/SendEmail.jtp?type=node&node=2956527&i=4><ml-node%2B1842946
>>> -39801187
>>>>
>>>> [hidden email] <http://user/SendEmail.jtp?type=node&node=2956527&i=5>>
>>>> > To unsubscribe from Apache Wicket, click
>>>>
>>> here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp<
>>> http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-us
>>> er=t>?
>>>>
>>>>
>>> tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
>>>> QyOTQ2fDEyNTYxMzc3ODY=>.
>>>> >
>>>> >
>>>> >
>>>>
>>>>
>>>> --
>>>> Sincerely,
>>>> JC (http://www.linkedin.com/in/jcgarciam)
>>>> Work smarter, not harder!.
>>>>
>>>> --
>>>> View this message in context:
>>>>
>>> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
>>> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
>>> o?by-user=t>
>>>> n-tp2955144p2956283.html
>>>> Sent from the Users forum mailing list archive at Nabble.com.
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: [hidden
>>> email]<http://user/SendEmail.jtp?type=node&node=2956527&i=6>
>>>> For additional commands, e-mail: [hidden
>>> email]<http://user/SendEmail.jtp?type=node&node=2956527&i=7>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: [hidden
>>> email]<http://user/SendEmail.jtp?type=node&node=2956527&i=8>
>>>> For additional commands, e-mail: [hidden
>>> email]<http://user/SendEmail.jtp?type=node&node=2956527&i=9>
>>>>
>>>>
>>>>
>>>> ------------------------------
>>>>  View message @
>>>>
>>> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
>>> n-tp2955144p2956527.html
>>>> To start a new topic under Apache Wicket, email
>>>>
>>> ml-node+1842946-398011874-65838@n4.nabble.com<ml-node%2B1842946-39801187
>>> 4-65838@n4.nabble.com>
>>>> To unsubscribe from Apache Wicket, click
>>> here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?
>>> tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
>>> QyOTQ2fDEyNTYxMzc3ODY=>.
>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> Sincerely,
>>> JC (http://www.linkedin.com/in/jcgarciam)
>>> Work smarter, not harder!.
>>>
>>> --
>>> View this message in context:
>>> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
>>> n-tp2955144p2956669.html
>>> Sent from the Users forum mailing list archive at Nabble.com.
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


RE: DropDownChoice/Model Confusion

Posted by Shelli Orton <Sh...@sjrb.ca>.
No, the getList() (called in the LDM load()) is only called once.  For the buttons add, edit and delete, the processng is like this:

- ldm.load() (which calls getList())
- button.onSubmit()
- ldm.detach() (called two times)

For the save button, the processing is:

- button.onSubmit()
- ldm.load()
- ldm.detach() (called two times)

I've discovered another anomaly in my code.  When I choose a record and click the edit button, the record is displayed in the edit group.  If I then choose cancel, the edit group is no longer displayed and the ddc selection is null. I then choose another record from the list and edit and the previous record information is displayed in the edit group even though the ddc shows the newly selected record.

I added get/set for the selectedRecord and set breakpoints, but those methods are never called.  Since the edit group components use PropertyModels, shouldn't the get method be called each time the page is submitted?

Shelli


-----Original Message-----
From: jcarman@carmanconsulting.com [mailto:jcarman@carmanconsulting.com] On Behalf Of James Carman
Sent: Tuesday, October 05, 2010 4:50 PM
To: users@wicket.apache.org
Subject: Re: DropDownChoice/Model Confusion

Is your getList() being called multiple times?

On Tue, Oct 5, 2010 at 6:37 PM, Shelli Orton <Sh...@sjrb.ca> wrote:
> I overrode the detach method in my class (which simply calls super.detach()) so I could set a breakpoint and see if it gets called and it does.
>
> Shelli
>
> -----Original Message-----
> From: Shelli Orton
> Sent: Tuesday, October 05, 2010 2:24 PM
> To: users@wicket.apache.org
> Subject: RE: DropDownChoice/Model Confusion
>
> I don't know how to determine that.
>
> -----Original Message-----
> From: jcarman@carmanconsulting.com [mailto:jcarman@carmanconsulting.com] On Behalf Of James Carman
> Sent: Tuesday, October 05, 2010 1:44 PM
> To: users@wicket.apache.org
> Subject: Re: DropDownChoice/Model Confusion
>
> Is it being detached?
>
> On Tue, Oct 5, 2010 at 3:26 PM, Shelli Orton <Sh...@sjrb.ca> wrote:
>> No, I'm not using AJAX.  Is there a way to force the LDB to reload?
>>
>> Shelli
>>
>> -----Original Message-----
>> From: jcgarciam [mailto:jcgarciam@gmail.com]
>> Sent: Tuesday, October 05, 2010 12:52 PM
>> To: users@wicket.apache.org
>> Subject: Re: DropDownChoice/Model Confusion
>>
>>
>> I dont think it may be related to the hierarchy, are you using AJAX?
>>
>> On Tue, Oct 5, 2010 at 2:38 PM, Shelli Orton [via Apache Wicket] <
>> ml-node+2956527-385265518-65838@n4.nabble.com<ml-node%2B2956527-38526551
>> 8-65838@n4.nabble.com>
>>> wrote:
>>
>>> Hmm, that code sort of works.  When I create or edit a record, the
>> list
>>> is updated.  However, when I delete a record it is not.  My component
>>> hierarchy is set up like this (hope it makes sense):
>>>
>>> TabPanel
>>>   - SelectForEditForm
>>>     - MyRecords (DDC)
>>>     - Add (Button)
>>>     - Edit (Button)
>>>     - Delete (Button)
>>>   - EditGroup (WebMarkupContainer)
>>>     - EditForm
>>>       - MyRecord Name (TextField)
>>>       - MyRecord Attribute (DDC)
>>>       - Save (Button)
>>>       - Cancel (Button)
>>>
>>> I created the EditGroup so that I can hide/display the edit panel.
>>> Debugging the application shows that the save button onSubmit is
>> called
>>> before the update of the myRecordsModel LDM and this is why the list
>> is
>>> updated when I create/edit a record. The delete button onSubmit is
>>> called after the update of the myRecordsModel LDM and that is why a
>>> deleted record is still visible in the list.
>>>
>>> I think the issue has something to do with the buttons being in
>>> different places in the component hierarchy. Can you provide any
>>> guidance on if there's some way to have the LDM updated after the
>> delete
>>> onSubmit?
>>>
>>> Thanks again,
>>> Shelli
>>>
>>> -----Original Message-----
>>> From: jcgarciam [mailto:[hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2956527&i=0>]
>>>
>>> Sent: Tuesday, October 05, 2010 9:33 AM
>>> To: [hidden email]
>> <http://user/SendEmail.jtp?type=node&node=2956527&i=1>
>>> Subject: Re: DropDownChoice/Model Confusion
>>>
>>>
>>> Yes, that should make your DDC to query the list any time it needs to
>> re
>>> render.
>>>
>>> To your 2nd. question in order to set a default or selected value,
>> just
>>> set
>>> a "MyRecord" reference to your property, keep in mind that your
>>> "MyRecord"
>>> should implement and equals/hashcode correctly.
>>>
>>>
>>> On Tue, Oct 5, 2010 at 12:00 PM, Shelli Orton [via Apache Wicket] <
>>> [hidden email]
>> <http://user/SendEmail.jtp?type=node&node=2956527&i=2><ml-node%2B2956214
>> -1797994
>>>
>>> [hidden email] <http://user/SendEmail.jtp?type=node&node=2956527&i=3>>
>>> > wrote:
>>>
>>> > Hi,
>>> >
>>> > Thanks for replying.  Just to clarify, do you mean do something like
>>> > this:
>>> >
>>> >
>>> >     LoadableDetachableModel<List<MyRecord>> myRecordsModel = new
>>> > LoadableDetachableModel<List<MyRecord>>()
>>> >     {
>>> >         @Override
>>> >         protected List<MyRecord> load()
>>> >         {
>>> >             return myRecordService.getList();
>>> >         }
>>> >     };
>>> >
>>> >     MyRecord selectedRecord;
>>> >
>>> >     form.add(new DropDownChoice<MyRecord>("records",
>>> >         new PropertyModel<MyRecord>(this, "selectedRecord"),
>>> >         myRecordsModel,
>>> >         new MyRecordRenderer()).setNullValid(false));
>>> >
>>> > Shelli
>>> >
>>> > -----Original Message-----
>>> > From: jcgarciam [mailto:[hidden
>>> email]<http://user/SendEmail.jtp?type=node&node=2956214&i=0>]
>>> >
>>> > Sent: Monday, October 04, 2010 6:27 PM
>>> > To: [hidden email]
>>> <http://user/SendEmail.jtp?type=node&node=2956214&i=1>
>>> > Subject: Re: DropDownChoice/Model Confusion
>>> >
>>> >
>>> > Hi, instead of passing  "getMyRecords()" in the constructor wrap it
>>> > around
>>> > a LoadableDetachableModel and pass that model to the DDC. The
>>> difference
>>> > is
>>> > that your current list is fetch only once at construction of your
>>> pages
>>>
>>> > and
>>> > is considered static because its never get called again unless you
>>> > triggered
>>> > it by entering to a new page instance, while by using a LDM the
>>> > component
>>> > will ask for it every time it needs to re-render them.
>>> >
>>> >
>>> > On Mon, Oct 4, 2010 at 6:52 PM, Shelli Orton [via Apache Wicket] <
>>> > [hidden email]
>>>
>> <http://user/SendEmail.jtp?type=node&node=2956214&i=2><ml-node%2B2955144
>>> -66557051
>>>
>>> >
>>> > [hidden email]
>> <http://user/SendEmail.jtp?type=node&node=2956214&i=3>>
>>> > > wrote:
>>> >
>>> > > I am writing a (simple?) database CRUD app where I have multiple
>> tab
>>> > > panels that encapsulate the different tables in the database.  On
>> a
>>> > > panel there's a dropdownchoice which lists the existing records
>> for
>>> > that
>>> > > table.  There's also create, delete and edit buttons (and and edit
>>> > panel
>>> > > with save and cancel buttons).  When I create, edit or delete any
>> of
>>> > the
>>> > > records, the dropdownchoice list doesn't reflect the changes until
>> I
>>> > > open a new session.  So my question is how to reload the list
>> after
>>> > one
>>> > > of these actions is done?
>>> > >
>>> > > Currently my dropdownchoice model is set like this:
>>> > >
>>> > >     MyRecord selectedRecord;
>>> > >     ...
>>> > >     form.add(new DropDownChoice<MyRecord>("records",
>>> > >         new PropertyModel<MyRecord>(this, "selectedRecord"),
>>> > >         getMyRecords(), // method that retrieves from the database
>>> > (via
>>> > > JPA)
>>> > >         new MyRecordRenderer()).setNullValid(false)); // used to
>>> > return
>>> > > the display attribute of MyRecord
>>> > >
>>> > > I am trying to understand if using a LoadableDetachableModel will
>> do
>>> > the
>>> >
>>> > > reload that I want. Also, I don't know how to set the
>> selectedRecord
>>> > > using that type of model or if it's even possible.
>>> > >
>>> > > Any advice?
>>> > >
>>> > > Thanks!
>>> > >
>>> > > Shelli
>>> > >
>>> > >
>>> ---------------------------------------------------------------------
>>>
>>> > > To unsubscribe, e-mail: [hidden
>>> > email]<http://user/SendEmail.jtp?type=node&node=2955144&i=0>
>>> > > For additional commands, e-mail: [hidden
>>> > email]<http://user/SendEmail.jtp?type=node&node=2955144&i=1>
>>> > >
>>> > >
>>> > >
>>> > > ------------------------------
>>> > >  View message @
>>> > >
>>> >
>>>
>> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
>> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
>> o?by-user=t>
>>>
>> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
>> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
>> ?by-user=t>
>>> o?by-user=t>
>>> > n-tp2955144p2955144.html
>>> > > To start a new topic under Apache Wicket, email
>>> > >
>>> > [hidden email]
>>>
>> <http://user/SendEmail.jtp?type=node&node=2956214&i=4><ml-node%2B1842946
>>> -39801187
>>> >
>>> > [hidden email]
>> <http://user/SendEmail.jtp?type=node&node=2956214&i=5>>
>>> > > To unsubscribe from Apache Wicket, click
>>> >
>>>
>> here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp<
>> http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-us
>> er=t><
>>>
>>>
>> http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-us
>> <http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-u
>> s&by-user=t>
>>> er=t>?
>>> >
>>> >
>>>
>> tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
>>>
>>> > QyOTQ2fDEyNTYxMzc3ODY=>.
>>> > >
>>> > >
>>> > >
>>> >
>>> >
>>> > --
>>> > Sincerely,
>>> > JC (http://www.linkedin.com/in/jcgarciam)
>>> > Work smarter, not harder!.
>>> >
>>> > --
>>> > View this message in context:
>>> >
>>>
>> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
>> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
>> o?by-user=t>
>>>
>> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
>> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
>> ?by-user=t>
>>> o?by-user=t>
>>> > n-tp2955144p2955255.html
>>> > Sent from the Users forum mailing list archive at Nabble.com.
>>> >
>>> >
>> ---------------------------------------------------------------------
>>> > To unsubscribe, e-mail: [hidden
>>> email]<http://user/SendEmail.jtp?type=node&node=2956214&i=6>
>>> > For additional commands, e-mail: [hidden
>>> email]<http://user/SendEmail.jtp?type=node&node=2956214&i=7>
>>> >
>>> >
>>> >
>> ---------------------------------------------------------------------
>>> > To unsubscribe, e-mail: [hidden
>>> email]<http://user/SendEmail.jtp?type=node&node=2956214&i=8>
>>> > For additional commands, e-mail: [hidden
>>> email]<http://user/SendEmail.jtp?type=node&node=2956214&i=9>
>>> >
>>> >
>>> >
>>> > ------------------------------
>>> >  View message @
>>> >
>>>
>> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
>> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
>> o?by-user=t>
>>> n-tp2955144p2956214.html
>>> > To start a new topic under Apache Wicket, email
>>> >
>>> [hidden email]
>> <http://user/SendEmail.jtp?type=node&node=2956527&i=4><ml-node%2B1842946
>> -39801187
>>>
>>> [hidden email] <http://user/SendEmail.jtp?type=node&node=2956527&i=5>>
>>> > To unsubscribe from Apache Wicket, click
>>>
>> here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp<
>> http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-us
>> er=t>?
>>>
>>>
>> tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
>>> QyOTQ2fDEyNTYxMzc3ODY=>.
>>> >
>>> >
>>> >
>>>
>>>
>>> --
>>> Sincerely,
>>> JC (http://www.linkedin.com/in/jcgarciam)
>>> Work smarter, not harder!.
>>>
>>> --
>>> View this message in context:
>>>
>> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
>> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
>> o?by-user=t>
>>> n-tp2955144p2956283.html
>>> Sent from the Users forum mailing list archive at Nabble.com.
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2956527&i=6>
>>> For additional commands, e-mail: [hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2956527&i=7>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2956527&i=8>
>>> For additional commands, e-mail: [hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2956527&i=9>
>>>
>>>
>>>
>>> ------------------------------
>>>  View message @
>>>
>> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
>> n-tp2955144p2956527.html
>>> To start a new topic under Apache Wicket, email
>>>
>> ml-node+1842946-398011874-65838@n4.nabble.com<ml-node%2B1842946-39801187
>> 4-65838@n4.nabble.com>
>>> To unsubscribe from Apache Wicket, click
>> here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?
>> tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
>> QyOTQ2fDEyNTYxMzc3ODY=>.
>>>
>>>
>>>
>>
>>
>> --
>> Sincerely,
>> JC (http://www.linkedin.com/in/jcgarciam)
>> Work smarter, not harder!.
>>
>> --
>> View this message in context:
>> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
>> n-tp2955144p2956669.html
>> Sent from the Users forum mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


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


Re: DropDownChoice/Model Confusion

Posted by James Carman <ja...@carmanconsulting.com>.
Is your getList() being called multiple times?

On Tue, Oct 5, 2010 at 6:37 PM, Shelli Orton <Sh...@sjrb.ca> wrote:
> I overrode the detach method in my class (which simply calls super.detach()) so I could set a breakpoint and see if it gets called and it does.
>
> Shelli
>
> -----Original Message-----
> From: Shelli Orton
> Sent: Tuesday, October 05, 2010 2:24 PM
> To: users@wicket.apache.org
> Subject: RE: DropDownChoice/Model Confusion
>
> I don't know how to determine that.
>
> -----Original Message-----
> From: jcarman@carmanconsulting.com [mailto:jcarman@carmanconsulting.com] On Behalf Of James Carman
> Sent: Tuesday, October 05, 2010 1:44 PM
> To: users@wicket.apache.org
> Subject: Re: DropDownChoice/Model Confusion
>
> Is it being detached?
>
> On Tue, Oct 5, 2010 at 3:26 PM, Shelli Orton <Sh...@sjrb.ca> wrote:
>> No, I'm not using AJAX.  Is there a way to force the LDB to reload?
>>
>> Shelli
>>
>> -----Original Message-----
>> From: jcgarciam [mailto:jcgarciam@gmail.com]
>> Sent: Tuesday, October 05, 2010 12:52 PM
>> To: users@wicket.apache.org
>> Subject: Re: DropDownChoice/Model Confusion
>>
>>
>> I dont think it may be related to the hierarchy, are you using AJAX?
>>
>> On Tue, Oct 5, 2010 at 2:38 PM, Shelli Orton [via Apache Wicket] <
>> ml-node+2956527-385265518-65838@n4.nabble.com<ml-node%2B2956527-38526551
>> 8-65838@n4.nabble.com>
>>> wrote:
>>
>>> Hmm, that code sort of works.  When I create or edit a record, the
>> list
>>> is updated.  However, when I delete a record it is not.  My component
>>> hierarchy is set up like this (hope it makes sense):
>>>
>>> TabPanel
>>>   - SelectForEditForm
>>>     - MyRecords (DDC)
>>>     - Add (Button)
>>>     - Edit (Button)
>>>     - Delete (Button)
>>>   - EditGroup (WebMarkupContainer)
>>>     - EditForm
>>>       - MyRecord Name (TextField)
>>>       - MyRecord Attribute (DDC)
>>>       - Save (Button)
>>>       - Cancel (Button)
>>>
>>> I created the EditGroup so that I can hide/display the edit panel.
>>> Debugging the application shows that the save button onSubmit is
>> called
>>> before the update of the myRecordsModel LDM and this is why the list
>> is
>>> updated when I create/edit a record. The delete button onSubmit is
>>> called after the update of the myRecordsModel LDM and that is why a
>>> deleted record is still visible in the list.
>>>
>>> I think the issue has something to do with the buttons being in
>>> different places in the component hierarchy. Can you provide any
>>> guidance on if there's some way to have the LDM updated after the
>> delete
>>> onSubmit?
>>>
>>> Thanks again,
>>> Shelli
>>>
>>> -----Original Message-----
>>> From: jcgarciam [mailto:[hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2956527&i=0>]
>>>
>>> Sent: Tuesday, October 05, 2010 9:33 AM
>>> To: [hidden email]
>> <http://user/SendEmail.jtp?type=node&node=2956527&i=1>
>>> Subject: Re: DropDownChoice/Model Confusion
>>>
>>>
>>> Yes, that should make your DDC to query the list any time it needs to
>> re
>>> render.
>>>
>>> To your 2nd. question in order to set a default or selected value,
>> just
>>> set
>>> a "MyRecord" reference to your property, keep in mind that your
>>> "MyRecord"
>>> should implement and equals/hashcode correctly.
>>>
>>>
>>> On Tue, Oct 5, 2010 at 12:00 PM, Shelli Orton [via Apache Wicket] <
>>> [hidden email]
>> <http://user/SendEmail.jtp?type=node&node=2956527&i=2><ml-node%2B2956214
>> -1797994
>>>
>>> [hidden email] <http://user/SendEmail.jtp?type=node&node=2956527&i=3>>
>>> > wrote:
>>>
>>> > Hi,
>>> >
>>> > Thanks for replying.  Just to clarify, do you mean do something like
>>> > this:
>>> >
>>> >
>>> >     LoadableDetachableModel<List<MyRecord>> myRecordsModel = new
>>> > LoadableDetachableModel<List<MyRecord>>()
>>> >     {
>>> >         @Override
>>> >         protected List<MyRecord> load()
>>> >         {
>>> >             return myRecordService.getList();
>>> >         }
>>> >     };
>>> >
>>> >     MyRecord selectedRecord;
>>> >
>>> >     form.add(new DropDownChoice<MyRecord>("records",
>>> >         new PropertyModel<MyRecord>(this, "selectedRecord"),
>>> >         myRecordsModel,
>>> >         new MyRecordRenderer()).setNullValid(false));
>>> >
>>> > Shelli
>>> >
>>> > -----Original Message-----
>>> > From: jcgarciam [mailto:[hidden
>>> email]<http://user/SendEmail.jtp?type=node&node=2956214&i=0>]
>>> >
>>> > Sent: Monday, October 04, 2010 6:27 PM
>>> > To: [hidden email]
>>> <http://user/SendEmail.jtp?type=node&node=2956214&i=1>
>>> > Subject: Re: DropDownChoice/Model Confusion
>>> >
>>> >
>>> > Hi, instead of passing  "getMyRecords()" in the constructor wrap it
>>> > around
>>> > a LoadableDetachableModel and pass that model to the DDC. The
>>> difference
>>> > is
>>> > that your current list is fetch only once at construction of your
>>> pages
>>>
>>> > and
>>> > is considered static because its never get called again unless you
>>> > triggered
>>> > it by entering to a new page instance, while by using a LDM the
>>> > component
>>> > will ask for it every time it needs to re-render them.
>>> >
>>> >
>>> > On Mon, Oct 4, 2010 at 6:52 PM, Shelli Orton [via Apache Wicket] <
>>> > [hidden email]
>>>
>> <http://user/SendEmail.jtp?type=node&node=2956214&i=2><ml-node%2B2955144
>>> -66557051
>>>
>>> >
>>> > [hidden email]
>> <http://user/SendEmail.jtp?type=node&node=2956214&i=3>>
>>> > > wrote:
>>> >
>>> > > I am writing a (simple?) database CRUD app where I have multiple
>> tab
>>> > > panels that encapsulate the different tables in the database.  On
>> a
>>> > > panel there's a dropdownchoice which lists the existing records
>> for
>>> > that
>>> > > table.  There's also create, delete and edit buttons (and and edit
>>> > panel
>>> > > with save and cancel buttons).  When I create, edit or delete any
>> of
>>> > the
>>> > > records, the dropdownchoice list doesn't reflect the changes until
>> I
>>> > > open a new session.  So my question is how to reload the list
>> after
>>> > one
>>> > > of these actions is done?
>>> > >
>>> > > Currently my dropdownchoice model is set like this:
>>> > >
>>> > >     MyRecord selectedRecord;
>>> > >     ...
>>> > >     form.add(new DropDownChoice<MyRecord>("records",
>>> > >         new PropertyModel<MyRecord>(this, "selectedRecord"),
>>> > >         getMyRecords(), // method that retrieves from the database
>>> > (via
>>> > > JPA)
>>> > >         new MyRecordRenderer()).setNullValid(false)); // used to
>>> > return
>>> > > the display attribute of MyRecord
>>> > >
>>> > > I am trying to understand if using a LoadableDetachableModel will
>> do
>>> > the
>>> >
>>> > > reload that I want. Also, I don't know how to set the
>> selectedRecord
>>> > > using that type of model or if it's even possible.
>>> > >
>>> > > Any advice?
>>> > >
>>> > > Thanks!
>>> > >
>>> > > Shelli
>>> > >
>>> > >
>>> ---------------------------------------------------------------------
>>>
>>> > > To unsubscribe, e-mail: [hidden
>>> > email]<http://user/SendEmail.jtp?type=node&node=2955144&i=0>
>>> > > For additional commands, e-mail: [hidden
>>> > email]<http://user/SendEmail.jtp?type=node&node=2955144&i=1>
>>> > >
>>> > >
>>> > >
>>> > > ------------------------------
>>> > >  View message @
>>> > >
>>> >
>>>
>> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
>> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
>> o?by-user=t>
>>>
>> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
>> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
>> ?by-user=t>
>>> o?by-user=t>
>>> > n-tp2955144p2955144.html
>>> > > To start a new topic under Apache Wicket, email
>>> > >
>>> > [hidden email]
>>>
>> <http://user/SendEmail.jtp?type=node&node=2956214&i=4><ml-node%2B1842946
>>> -39801187
>>> >
>>> > [hidden email]
>> <http://user/SendEmail.jtp?type=node&node=2956214&i=5>>
>>> > > To unsubscribe from Apache Wicket, click
>>> >
>>>
>> here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp<
>> http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-us
>> er=t><
>>>
>>>
>> http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-us
>> <http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-u
>> s&by-user=t>
>>> er=t>?
>>> >
>>> >
>>>
>> tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
>>>
>>> > QyOTQ2fDEyNTYxMzc3ODY=>.
>>> > >
>>> > >
>>> > >
>>> >
>>> >
>>> > --
>>> > Sincerely,
>>> > JC (http://www.linkedin.com/in/jcgarciam)
>>> > Work smarter, not harder!.
>>> >
>>> > --
>>> > View this message in context:
>>> >
>>>
>> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
>> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
>> o?by-user=t>
>>>
>> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
>> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
>> ?by-user=t>
>>> o?by-user=t>
>>> > n-tp2955144p2955255.html
>>> > Sent from the Users forum mailing list archive at Nabble.com.
>>> >
>>> >
>> ---------------------------------------------------------------------
>>> > To unsubscribe, e-mail: [hidden
>>> email]<http://user/SendEmail.jtp?type=node&node=2956214&i=6>
>>> > For additional commands, e-mail: [hidden
>>> email]<http://user/SendEmail.jtp?type=node&node=2956214&i=7>
>>> >
>>> >
>>> >
>> ---------------------------------------------------------------------
>>> > To unsubscribe, e-mail: [hidden
>>> email]<http://user/SendEmail.jtp?type=node&node=2956214&i=8>
>>> > For additional commands, e-mail: [hidden
>>> email]<http://user/SendEmail.jtp?type=node&node=2956214&i=9>
>>> >
>>> >
>>> >
>>> > ------------------------------
>>> >  View message @
>>> >
>>>
>> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
>> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
>> o?by-user=t>
>>> n-tp2955144p2956214.html
>>> > To start a new topic under Apache Wicket, email
>>> >
>>> [hidden email]
>> <http://user/SendEmail.jtp?type=node&node=2956527&i=4><ml-node%2B1842946
>> -39801187
>>>
>>> [hidden email] <http://user/SendEmail.jtp?type=node&node=2956527&i=5>>
>>> > To unsubscribe from Apache Wicket, click
>>>
>> here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp<
>> http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-us
>> er=t>?
>>>
>>>
>> tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
>>> QyOTQ2fDEyNTYxMzc3ODY=>.
>>> >
>>> >
>>> >
>>>
>>>
>>> --
>>> Sincerely,
>>> JC (http://www.linkedin.com/in/jcgarciam)
>>> Work smarter, not harder!.
>>>
>>> --
>>> View this message in context:
>>>
>> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
>> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
>> o?by-user=t>
>>> n-tp2955144p2956283.html
>>> Sent from the Users forum mailing list archive at Nabble.com.
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2956527&i=6>
>>> For additional commands, e-mail: [hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2956527&i=7>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2956527&i=8>
>>> For additional commands, e-mail: [hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2956527&i=9>
>>>
>>>
>>>
>>> ------------------------------
>>>  View message @
>>>
>> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
>> n-tp2955144p2956527.html
>>> To start a new topic under Apache Wicket, email
>>>
>> ml-node+1842946-398011874-65838@n4.nabble.com<ml-node%2B1842946-39801187
>> 4-65838@n4.nabble.com>
>>> To unsubscribe from Apache Wicket, click
>> here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?
>> tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
>> QyOTQ2fDEyNTYxMzc3ODY=>.
>>>
>>>
>>>
>>
>>
>> --
>> Sincerely,
>> JC (http://www.linkedin.com/in/jcgarciam)
>> Work smarter, not harder!.
>>
>> --
>> View this message in context:
>> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
>> n-tp2955144p2956669.html
>> Sent from the Users forum mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


RE: DropDownChoice/Model Confusion

Posted by Shelli Orton <Sh...@sjrb.ca>.
I overrode the detach method in my class (which simply calls super.detach()) so I could set a breakpoint and see if it gets called and it does.

Shelli 

-----Original Message-----
From: Shelli Orton 
Sent: Tuesday, October 05, 2010 2:24 PM
To: users@wicket.apache.org
Subject: RE: DropDownChoice/Model Confusion

I don't know how to determine that.

-----Original Message-----
From: jcarman@carmanconsulting.com [mailto:jcarman@carmanconsulting.com] On Behalf Of James Carman
Sent: Tuesday, October 05, 2010 1:44 PM
To: users@wicket.apache.org
Subject: Re: DropDownChoice/Model Confusion

Is it being detached?

On Tue, Oct 5, 2010 at 3:26 PM, Shelli Orton <Sh...@sjrb.ca> wrote:
> No, I'm not using AJAX.  Is there a way to force the LDB to reload?
>
> Shelli
>
> -----Original Message-----
> From: jcgarciam [mailto:jcgarciam@gmail.com]
> Sent: Tuesday, October 05, 2010 12:52 PM
> To: users@wicket.apache.org
> Subject: Re: DropDownChoice/Model Confusion
>
>
> I dont think it may be related to the hierarchy, are you using AJAX?
>
> On Tue, Oct 5, 2010 at 2:38 PM, Shelli Orton [via Apache Wicket] <
> ml-node+2956527-385265518-65838@n4.nabble.com<ml-node%2B2956527-38526551
> 8-65838@n4.nabble.com>
>> wrote:
>
>> Hmm, that code sort of works.  When I create or edit a record, the
> list
>> is updated.  However, when I delete a record it is not.  My component
>> hierarchy is set up like this (hope it makes sense):
>>
>> TabPanel
>>   - SelectForEditForm
>>     - MyRecords (DDC)
>>     - Add (Button)
>>     - Edit (Button)
>>     - Delete (Button)
>>   - EditGroup (WebMarkupContainer)
>>     - EditForm
>>       - MyRecord Name (TextField)
>>       - MyRecord Attribute (DDC)
>>       - Save (Button)
>>       - Cancel (Button)
>>
>> I created the EditGroup so that I can hide/display the edit panel.
>> Debugging the application shows that the save button onSubmit is
> called
>> before the update of the myRecordsModel LDM and this is why the list
> is
>> updated when I create/edit a record. The delete button onSubmit is
>> called after the update of the myRecordsModel LDM and that is why a
>> deleted record is still visible in the list.
>>
>> I think the issue has something to do with the buttons being in
>> different places in the component hierarchy. Can you provide any
>> guidance on if there's some way to have the LDM updated after the
> delete
>> onSubmit?
>>
>> Thanks again,
>> Shelli
>>
>> -----Original Message-----
>> From: jcgarciam [mailto:[hidden
> email]<http://user/SendEmail.jtp?type=node&node=2956527&i=0>]
>>
>> Sent: Tuesday, October 05, 2010 9:33 AM
>> To: [hidden email]
> <http://user/SendEmail.jtp?type=node&node=2956527&i=1>
>> Subject: Re: DropDownChoice/Model Confusion
>>
>>
>> Yes, that should make your DDC to query the list any time it needs to
> re
>> render.
>>
>> To your 2nd. question in order to set a default or selected value,
> just
>> set
>> a "MyRecord" reference to your property, keep in mind that your
>> "MyRecord"
>> should implement and equals/hashcode correctly.
>>
>>
>> On Tue, Oct 5, 2010 at 12:00 PM, Shelli Orton [via Apache Wicket] <
>> [hidden email]
> <http://user/SendEmail.jtp?type=node&node=2956527&i=2><ml-node%2B2956214
> -1797994
>>
>> [hidden email] <http://user/SendEmail.jtp?type=node&node=2956527&i=3>>
>> > wrote:
>>
>> > Hi,
>> >
>> > Thanks for replying.  Just to clarify, do you mean do something like
>> > this:
>> >
>> >
>> >     LoadableDetachableModel<List<MyRecord>> myRecordsModel = new
>> > LoadableDetachableModel<List<MyRecord>>()
>> >     {
>> >         @Override
>> >         protected List<MyRecord> load()
>> >         {
>> >             return myRecordService.getList();
>> >         }
>> >     };
>> >
>> >     MyRecord selectedRecord;
>> >
>> >     form.add(new DropDownChoice<MyRecord>("records",
>> >         new PropertyModel<MyRecord>(this, "selectedRecord"),
>> >         myRecordsModel,
>> >         new MyRecordRenderer()).setNullValid(false));
>> >
>> > Shelli
>> >
>> > -----Original Message-----
>> > From: jcgarciam [mailto:[hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2956214&i=0>]
>> >
>> > Sent: Monday, October 04, 2010 6:27 PM
>> > To: [hidden email]
>> <http://user/SendEmail.jtp?type=node&node=2956214&i=1>
>> > Subject: Re: DropDownChoice/Model Confusion
>> >
>> >
>> > Hi, instead of passing  "getMyRecords()" in the constructor wrap it
>> > around
>> > a LoadableDetachableModel and pass that model to the DDC. The
>> difference
>> > is
>> > that your current list is fetch only once at construction of your
>> pages
>>
>> > and
>> > is considered static because its never get called again unless you
>> > triggered
>> > it by entering to a new page instance, while by using a LDM the
>> > component
>> > will ask for it every time it needs to re-render them.
>> >
>> >
>> > On Mon, Oct 4, 2010 at 6:52 PM, Shelli Orton [via Apache Wicket] <
>> > [hidden email]
>>
> <http://user/SendEmail.jtp?type=node&node=2956214&i=2><ml-node%2B2955144
>> -66557051
>>
>> >
>> > [hidden email]
> <http://user/SendEmail.jtp?type=node&node=2956214&i=3>>
>> > > wrote:
>> >
>> > > I am writing a (simple?) database CRUD app where I have multiple
> tab
>> > > panels that encapsulate the different tables in the database.  On
> a
>> > > panel there's a dropdownchoice which lists the existing records
> for
>> > that
>> > > table.  There's also create, delete and edit buttons (and and edit
>> > panel
>> > > with save and cancel buttons).  When I create, edit or delete any
> of
>> > the
>> > > records, the dropdownchoice list doesn't reflect the changes until
> I
>> > > open a new session.  So my question is how to reload the list
> after
>> > one
>> > > of these actions is done?
>> > >
>> > > Currently my dropdownchoice model is set like this:
>> > >
>> > >     MyRecord selectedRecord;
>> > >     ...
>> > >     form.add(new DropDownChoice<MyRecord>("records",
>> > >         new PropertyModel<MyRecord>(this, "selectedRecord"),
>> > >         getMyRecords(), // method that retrieves from the database
>> > (via
>> > > JPA)
>> > >         new MyRecordRenderer()).setNullValid(false)); // used to
>> > return
>> > > the display attribute of MyRecord
>> > >
>> > > I am trying to understand if using a LoadableDetachableModel will
> do
>> > the
>> >
>> > > reload that I want. Also, I don't know how to set the
> selectedRecord
>> > > using that type of model or if it's even possible.
>> > >
>> > > Any advice?
>> > >
>> > > Thanks!
>> > >
>> > > Shelli
>> > >
>> > >
>> ---------------------------------------------------------------------
>>
>> > > To unsubscribe, e-mail: [hidden
>> > email]<http://user/SendEmail.jtp?type=node&node=2955144&i=0>
>> > > For additional commands, e-mail: [hidden
>> > email]<http://user/SendEmail.jtp?type=node&node=2955144&i=1>
>> > >
>> > >
>> > >
>> > > ------------------------------
>> > >  View message @
>> > >
>> >
>>
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
> o?by-user=t>
>>
> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
> ?by-user=t>
>> o?by-user=t>
>> > n-tp2955144p2955144.html
>> > > To start a new topic under Apache Wicket, email
>> > >
>> > [hidden email]
>>
> <http://user/SendEmail.jtp?type=node&node=2956214&i=4><ml-node%2B1842946
>> -39801187
>> >
>> > [hidden email]
> <http://user/SendEmail.jtp?type=node&node=2956214&i=5>>
>> > > To unsubscribe from Apache Wicket, click
>> >
>>
> here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp<
> http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-us
> er=t><
>>
>>
> http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-us
> <http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-u
> s&by-user=t>
>> er=t>?
>> >
>> >
>>
> tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
>>
>> > QyOTQ2fDEyNTYxMzc3ODY=>.
>> > >
>> > >
>> > >
>> >
>> >
>> > --
>> > Sincerely,
>> > JC (http://www.linkedin.com/in/jcgarciam)
>> > Work smarter, not harder!.
>> >
>> > --
>> > View this message in context:
>> >
>>
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
> o?by-user=t>
>>
> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
> ?by-user=t>
>> o?by-user=t>
>> > n-tp2955144p2955255.html
>> > Sent from the Users forum mailing list archive at Nabble.com.
>> >
>> >
> ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: [hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2956214&i=6>
>> > For additional commands, e-mail: [hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2956214&i=7>
>> >
>> >
>> >
> ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: [hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2956214&i=8>
>> > For additional commands, e-mail: [hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2956214&i=9>
>> >
>> >
>> >
>> > ------------------------------
>> >  View message @
>> >
>>
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
> o?by-user=t>
>> n-tp2955144p2956214.html
>> > To start a new topic under Apache Wicket, email
>> >
>> [hidden email]
> <http://user/SendEmail.jtp?type=node&node=2956527&i=4><ml-node%2B1842946
> -39801187
>>
>> [hidden email] <http://user/SendEmail.jtp?type=node&node=2956527&i=5>>
>> > To unsubscribe from Apache Wicket, click
>>
> here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp<
> http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-us
> er=t>?
>>
>>
> tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
>> QyOTQ2fDEyNTYxMzc3ODY=>.
>> >
>> >
>> >
>>
>>
>> --
>> Sincerely,
>> JC (http://www.linkedin.com/in/jcgarciam)
>> Work smarter, not harder!.
>>
>> --
>> View this message in context:
>>
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
> o?by-user=t>
>> n-tp2955144p2956283.html
>> Sent from the Users forum mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden
> email]<http://user/SendEmail.jtp?type=node&node=2956527&i=6>
>> For additional commands, e-mail: [hidden
> email]<http://user/SendEmail.jtp?type=node&node=2956527&i=7>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden
> email]<http://user/SendEmail.jtp?type=node&node=2956527&i=8>
>> For additional commands, e-mail: [hidden
> email]<http://user/SendEmail.jtp?type=node&node=2956527&i=9>
>>
>>
>>
>> ------------------------------
>>  View message @
>>
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
> n-tp2955144p2956527.html
>> To start a new topic under Apache Wicket, email
>>
> ml-node+1842946-398011874-65838@n4.nabble.com<ml-node%2B1842946-39801187
> 4-65838@n4.nabble.com>
>> To unsubscribe from Apache Wicket, click
> here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?
> tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
> QyOTQ2fDEyNTYxMzc3ODY=>.
>>
>>
>>
>
>
> --
> Sincerely,
> JC (http://www.linkedin.com/in/jcgarciam)
> Work smarter, not harder!.
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
> n-tp2955144p2956669.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


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


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


RE: DropDownChoice/Model Confusion

Posted by Shelli Orton <Sh...@sjrb.ca>.
I don't know how to determine that.

-----Original Message-----
From: jcarman@carmanconsulting.com [mailto:jcarman@carmanconsulting.com] On Behalf Of James Carman
Sent: Tuesday, October 05, 2010 1:44 PM
To: users@wicket.apache.org
Subject: Re: DropDownChoice/Model Confusion

Is it being detached?

On Tue, Oct 5, 2010 at 3:26 PM, Shelli Orton <Sh...@sjrb.ca> wrote:
> No, I'm not using AJAX.  Is there a way to force the LDB to reload?
>
> Shelli
>
> -----Original Message-----
> From: jcgarciam [mailto:jcgarciam@gmail.com]
> Sent: Tuesday, October 05, 2010 12:52 PM
> To: users@wicket.apache.org
> Subject: Re: DropDownChoice/Model Confusion
>
>
> I dont think it may be related to the hierarchy, are you using AJAX?
>
> On Tue, Oct 5, 2010 at 2:38 PM, Shelli Orton [via Apache Wicket] <
> ml-node+2956527-385265518-65838@n4.nabble.com<ml-node%2B2956527-38526551
> 8-65838@n4.nabble.com>
>> wrote:
>
>> Hmm, that code sort of works.  When I create or edit a record, the
> list
>> is updated.  However, when I delete a record it is not.  My component
>> hierarchy is set up like this (hope it makes sense):
>>
>> TabPanel
>>   - SelectForEditForm
>>     - MyRecords (DDC)
>>     - Add (Button)
>>     - Edit (Button)
>>     - Delete (Button)
>>   - EditGroup (WebMarkupContainer)
>>     - EditForm
>>       - MyRecord Name (TextField)
>>       - MyRecord Attribute (DDC)
>>       - Save (Button)
>>       - Cancel (Button)
>>
>> I created the EditGroup so that I can hide/display the edit panel.
>> Debugging the application shows that the save button onSubmit is
> called
>> before the update of the myRecordsModel LDM and this is why the list
> is
>> updated when I create/edit a record. The delete button onSubmit is
>> called after the update of the myRecordsModel LDM and that is why a
>> deleted record is still visible in the list.
>>
>> I think the issue has something to do with the buttons being in
>> different places in the component hierarchy. Can you provide any
>> guidance on if there's some way to have the LDM updated after the
> delete
>> onSubmit?
>>
>> Thanks again,
>> Shelli
>>
>> -----Original Message-----
>> From: jcgarciam [mailto:[hidden
> email]<http://user/SendEmail.jtp?type=node&node=2956527&i=0>]
>>
>> Sent: Tuesday, October 05, 2010 9:33 AM
>> To: [hidden email]
> <http://user/SendEmail.jtp?type=node&node=2956527&i=1>
>> Subject: Re: DropDownChoice/Model Confusion
>>
>>
>> Yes, that should make your DDC to query the list any time it needs to
> re
>> render.
>>
>> To your 2nd. question in order to set a default or selected value,
> just
>> set
>> a "MyRecord" reference to your property, keep in mind that your
>> "MyRecord"
>> should implement and equals/hashcode correctly.
>>
>>
>> On Tue, Oct 5, 2010 at 12:00 PM, Shelli Orton [via Apache Wicket] <
>> [hidden email]
> <http://user/SendEmail.jtp?type=node&node=2956527&i=2><ml-node%2B2956214
> -1797994
>>
>> [hidden email] <http://user/SendEmail.jtp?type=node&node=2956527&i=3>>
>> > wrote:
>>
>> > Hi,
>> >
>> > Thanks for replying.  Just to clarify, do you mean do something like
>> > this:
>> >
>> >
>> >     LoadableDetachableModel<List<MyRecord>> myRecordsModel = new
>> > LoadableDetachableModel<List<MyRecord>>()
>> >     {
>> >         @Override
>> >         protected List<MyRecord> load()
>> >         {
>> >             return myRecordService.getList();
>> >         }
>> >     };
>> >
>> >     MyRecord selectedRecord;
>> >
>> >     form.add(new DropDownChoice<MyRecord>("records",
>> >         new PropertyModel<MyRecord>(this, "selectedRecord"),
>> >         myRecordsModel,
>> >         new MyRecordRenderer()).setNullValid(false));
>> >
>> > Shelli
>> >
>> > -----Original Message-----
>> > From: jcgarciam [mailto:[hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2956214&i=0>]
>> >
>> > Sent: Monday, October 04, 2010 6:27 PM
>> > To: [hidden email]
>> <http://user/SendEmail.jtp?type=node&node=2956214&i=1>
>> > Subject: Re: DropDownChoice/Model Confusion
>> >
>> >
>> > Hi, instead of passing  "getMyRecords()" in the constructor wrap it
>> > around
>> > a LoadableDetachableModel and pass that model to the DDC. The
>> difference
>> > is
>> > that your current list is fetch only once at construction of your
>> pages
>>
>> > and
>> > is considered static because its never get called again unless you
>> > triggered
>> > it by entering to a new page instance, while by using a LDM the
>> > component
>> > will ask for it every time it needs to re-render them.
>> >
>> >
>> > On Mon, Oct 4, 2010 at 6:52 PM, Shelli Orton [via Apache Wicket] <
>> > [hidden email]
>>
> <http://user/SendEmail.jtp?type=node&node=2956214&i=2><ml-node%2B2955144
>> -66557051
>>
>> >
>> > [hidden email]
> <http://user/SendEmail.jtp?type=node&node=2956214&i=3>>
>> > > wrote:
>> >
>> > > I am writing a (simple?) database CRUD app where I have multiple
> tab
>> > > panels that encapsulate the different tables in the database.  On
> a
>> > > panel there's a dropdownchoice which lists the existing records
> for
>> > that
>> > > table.  There's also create, delete and edit buttons (and and edit
>> > panel
>> > > with save and cancel buttons).  When I create, edit or delete any
> of
>> > the
>> > > records, the dropdownchoice list doesn't reflect the changes until
> I
>> > > open a new session.  So my question is how to reload the list
> after
>> > one
>> > > of these actions is done?
>> > >
>> > > Currently my dropdownchoice model is set like this:
>> > >
>> > >     MyRecord selectedRecord;
>> > >     ...
>> > >     form.add(new DropDownChoice<MyRecord>("records",
>> > >         new PropertyModel<MyRecord>(this, "selectedRecord"),
>> > >         getMyRecords(), // method that retrieves from the database
>> > (via
>> > > JPA)
>> > >         new MyRecordRenderer()).setNullValid(false)); // used to
>> > return
>> > > the display attribute of MyRecord
>> > >
>> > > I am trying to understand if using a LoadableDetachableModel will
> do
>> > the
>> >
>> > > reload that I want. Also, I don't know how to set the
> selectedRecord
>> > > using that type of model or if it's even possible.
>> > >
>> > > Any advice?
>> > >
>> > > Thanks!
>> > >
>> > > Shelli
>> > >
>> > >
>> ---------------------------------------------------------------------
>>
>> > > To unsubscribe, e-mail: [hidden
>> > email]<http://user/SendEmail.jtp?type=node&node=2955144&i=0>
>> > > For additional commands, e-mail: [hidden
>> > email]<http://user/SendEmail.jtp?type=node&node=2955144&i=1>
>> > >
>> > >
>> > >
>> > > ------------------------------
>> > >  View message @
>> > >
>> >
>>
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
> o?by-user=t>
>>
> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
> ?by-user=t>
>> o?by-user=t>
>> > n-tp2955144p2955144.html
>> > > To start a new topic under Apache Wicket, email
>> > >
>> > [hidden email]
>>
> <http://user/SendEmail.jtp?type=node&node=2956214&i=4><ml-node%2B1842946
>> -39801187
>> >
>> > [hidden email]
> <http://user/SendEmail.jtp?type=node&node=2956214&i=5>>
>> > > To unsubscribe from Apache Wicket, click
>> >
>>
> here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp<
> http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-us
> er=t><
>>
>>
> http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-us
> <http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-u
> s&by-user=t>
>> er=t>?
>> >
>> >
>>
> tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
>>
>> > QyOTQ2fDEyNTYxMzc3ODY=>.
>> > >
>> > >
>> > >
>> >
>> >
>> > --
>> > Sincerely,
>> > JC (http://www.linkedin.com/in/jcgarciam)
>> > Work smarter, not harder!.
>> >
>> > --
>> > View this message in context:
>> >
>>
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
> o?by-user=t>
>>
> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
> ?by-user=t>
>> o?by-user=t>
>> > n-tp2955144p2955255.html
>> > Sent from the Users forum mailing list archive at Nabble.com.
>> >
>> >
> ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: [hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2956214&i=6>
>> > For additional commands, e-mail: [hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2956214&i=7>
>> >
>> >
>> >
> ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: [hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2956214&i=8>
>> > For additional commands, e-mail: [hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2956214&i=9>
>> >
>> >
>> >
>> > ------------------------------
>> >  View message @
>> >
>>
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
> o?by-user=t>
>> n-tp2955144p2956214.html
>> > To start a new topic under Apache Wicket, email
>> >
>> [hidden email]
> <http://user/SendEmail.jtp?type=node&node=2956527&i=4><ml-node%2B1842946
> -39801187
>>
>> [hidden email] <http://user/SendEmail.jtp?type=node&node=2956527&i=5>>
>> > To unsubscribe from Apache Wicket, click
>>
> here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp<
> http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-us
> er=t>?
>>
>>
> tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
>> QyOTQ2fDEyNTYxMzc3ODY=>.
>> >
>> >
>> >
>>
>>
>> --
>> Sincerely,
>> JC (http://www.linkedin.com/in/jcgarciam)
>> Work smarter, not harder!.
>>
>> --
>> View this message in context:
>>
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
> o?by-user=t>
>> n-tp2955144p2956283.html
>> Sent from the Users forum mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden
> email]<http://user/SendEmail.jtp?type=node&node=2956527&i=6>
>> For additional commands, e-mail: [hidden
> email]<http://user/SendEmail.jtp?type=node&node=2956527&i=7>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden
> email]<http://user/SendEmail.jtp?type=node&node=2956527&i=8>
>> For additional commands, e-mail: [hidden
> email]<http://user/SendEmail.jtp?type=node&node=2956527&i=9>
>>
>>
>>
>> ------------------------------
>>  View message @
>>
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
> n-tp2955144p2956527.html
>> To start a new topic under Apache Wicket, email
>>
> ml-node+1842946-398011874-65838@n4.nabble.com<ml-node%2B1842946-39801187
> 4-65838@n4.nabble.com>
>> To unsubscribe from Apache Wicket, click
> here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?
> tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
> QyOTQ2fDEyNTYxMzc3ODY=>.
>>
>>
>>
>
>
> --
> Sincerely,
> JC (http://www.linkedin.com/in/jcgarciam)
> Work smarter, not harder!.
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
> n-tp2955144p2956669.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


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


Re: DropDownChoice/Model Confusion

Posted by James Carman <ja...@carmanconsulting.com>.
Is it being detached?

On Tue, Oct 5, 2010 at 3:26 PM, Shelli Orton <Sh...@sjrb.ca> wrote:
> No, I'm not using AJAX.  Is there a way to force the LDB to reload?
>
> Shelli
>
> -----Original Message-----
> From: jcgarciam [mailto:jcgarciam@gmail.com]
> Sent: Tuesday, October 05, 2010 12:52 PM
> To: users@wicket.apache.org
> Subject: Re: DropDownChoice/Model Confusion
>
>
> I dont think it may be related to the hierarchy, are you using AJAX?
>
> On Tue, Oct 5, 2010 at 2:38 PM, Shelli Orton [via Apache Wicket] <
> ml-node+2956527-385265518-65838@n4.nabble.com<ml-node%2B2956527-38526551
> 8-65838@n4.nabble.com>
>> wrote:
>
>> Hmm, that code sort of works.  When I create or edit a record, the
> list
>> is updated.  However, when I delete a record it is not.  My component
>> hierarchy is set up like this (hope it makes sense):
>>
>> TabPanel
>>   - SelectForEditForm
>>     - MyRecords (DDC)
>>     - Add (Button)
>>     - Edit (Button)
>>     - Delete (Button)
>>   - EditGroup (WebMarkupContainer)
>>     - EditForm
>>       - MyRecord Name (TextField)
>>       - MyRecord Attribute (DDC)
>>       - Save (Button)
>>       - Cancel (Button)
>>
>> I created the EditGroup so that I can hide/display the edit panel.
>> Debugging the application shows that the save button onSubmit is
> called
>> before the update of the myRecordsModel LDM and this is why the list
> is
>> updated when I create/edit a record. The delete button onSubmit is
>> called after the update of the myRecordsModel LDM and that is why a
>> deleted record is still visible in the list.
>>
>> I think the issue has something to do with the buttons being in
>> different places in the component hierarchy. Can you provide any
>> guidance on if there's some way to have the LDM updated after the
> delete
>> onSubmit?
>>
>> Thanks again,
>> Shelli
>>
>> -----Original Message-----
>> From: jcgarciam [mailto:[hidden
> email]<http://user/SendEmail.jtp?type=node&node=2956527&i=0>]
>>
>> Sent: Tuesday, October 05, 2010 9:33 AM
>> To: [hidden email]
> <http://user/SendEmail.jtp?type=node&node=2956527&i=1>
>> Subject: Re: DropDownChoice/Model Confusion
>>
>>
>> Yes, that should make your DDC to query the list any time it needs to
> re
>> render.
>>
>> To your 2nd. question in order to set a default or selected value,
> just
>> set
>> a "MyRecord" reference to your property, keep in mind that your
>> "MyRecord"
>> should implement and equals/hashcode correctly.
>>
>>
>> On Tue, Oct 5, 2010 at 12:00 PM, Shelli Orton [via Apache Wicket] <
>> [hidden email]
> <http://user/SendEmail.jtp?type=node&node=2956527&i=2><ml-node%2B2956214
> -1797994
>>
>> [hidden email] <http://user/SendEmail.jtp?type=node&node=2956527&i=3>>
>> > wrote:
>>
>> > Hi,
>> >
>> > Thanks for replying.  Just to clarify, do you mean do something like
>> > this:
>> >
>> >
>> >     LoadableDetachableModel<List<MyRecord>> myRecordsModel = new
>> > LoadableDetachableModel<List<MyRecord>>()
>> >     {
>> >         @Override
>> >         protected List<MyRecord> load()
>> >         {
>> >             return myRecordService.getList();
>> >         }
>> >     };
>> >
>> >     MyRecord selectedRecord;
>> >
>> >     form.add(new DropDownChoice<MyRecord>("records",
>> >         new PropertyModel<MyRecord>(this, "selectedRecord"),
>> >         myRecordsModel,
>> >         new MyRecordRenderer()).setNullValid(false));
>> >
>> > Shelli
>> >
>> > -----Original Message-----
>> > From: jcgarciam [mailto:[hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2956214&i=0>]
>> >
>> > Sent: Monday, October 04, 2010 6:27 PM
>> > To: [hidden email]
>> <http://user/SendEmail.jtp?type=node&node=2956214&i=1>
>> > Subject: Re: DropDownChoice/Model Confusion
>> >
>> >
>> > Hi, instead of passing  "getMyRecords()" in the constructor wrap it
>> > around
>> > a LoadableDetachableModel and pass that model to the DDC. The
>> difference
>> > is
>> > that your current list is fetch only once at construction of your
>> pages
>>
>> > and
>> > is considered static because its never get called again unless you
>> > triggered
>> > it by entering to a new page instance, while by using a LDM the
>> > component
>> > will ask for it every time it needs to re-render them.
>> >
>> >
>> > On Mon, Oct 4, 2010 at 6:52 PM, Shelli Orton [via Apache Wicket] <
>> > [hidden email]
>>
> <http://user/SendEmail.jtp?type=node&node=2956214&i=2><ml-node%2B2955144
>> -66557051
>>
>> >
>> > [hidden email]
> <http://user/SendEmail.jtp?type=node&node=2956214&i=3>>
>> > > wrote:
>> >
>> > > I am writing a (simple?) database CRUD app where I have multiple
> tab
>> > > panels that encapsulate the different tables in the database.  On
> a
>> > > panel there's a dropdownchoice which lists the existing records
> for
>> > that
>> > > table.  There's also create, delete and edit buttons (and and edit
>> > panel
>> > > with save and cancel buttons).  When I create, edit or delete any
> of
>> > the
>> > > records, the dropdownchoice list doesn't reflect the changes until
> I
>> > > open a new session.  So my question is how to reload the list
> after
>> > one
>> > > of these actions is done?
>> > >
>> > > Currently my dropdownchoice model is set like this:
>> > >
>> > >     MyRecord selectedRecord;
>> > >     ...
>> > >     form.add(new DropDownChoice<MyRecord>("records",
>> > >         new PropertyModel<MyRecord>(this, "selectedRecord"),
>> > >         getMyRecords(), // method that retrieves from the database
>> > (via
>> > > JPA)
>> > >         new MyRecordRenderer()).setNullValid(false)); // used to
>> > return
>> > > the display attribute of MyRecord
>> > >
>> > > I am trying to understand if using a LoadableDetachableModel will
> do
>> > the
>> >
>> > > reload that I want. Also, I don't know how to set the
> selectedRecord
>> > > using that type of model or if it's even possible.
>> > >
>> > > Any advice?
>> > >
>> > > Thanks!
>> > >
>> > > Shelli
>> > >
>> > >
>> ---------------------------------------------------------------------
>>
>> > > To unsubscribe, e-mail: [hidden
>> > email]<http://user/SendEmail.jtp?type=node&node=2955144&i=0>
>> > > For additional commands, e-mail: [hidden
>> > email]<http://user/SendEmail.jtp?type=node&node=2955144&i=1>
>> > >
>> > >
>> > >
>> > > ------------------------------
>> > >  View message @
>> > >
>> >
>>
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
> o?by-user=t>
>>
> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
> ?by-user=t>
>> o?by-user=t>
>> > n-tp2955144p2955144.html
>> > > To start a new topic under Apache Wicket, email
>> > >
>> > [hidden email]
>>
> <http://user/SendEmail.jtp?type=node&node=2956214&i=4><ml-node%2B1842946
>> -39801187
>> >
>> > [hidden email]
> <http://user/SendEmail.jtp?type=node&node=2956214&i=5>>
>> > > To unsubscribe from Apache Wicket, click
>> >
>>
> here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp<
> http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-us
> er=t><
>>
>>
> http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-us
> <http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-u
> s&by-user=t>
>> er=t>?
>> >
>> >
>>
> tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
>>
>> > QyOTQ2fDEyNTYxMzc3ODY=>.
>> > >
>> > >
>> > >
>> >
>> >
>> > --
>> > Sincerely,
>> > JC (http://www.linkedin.com/in/jcgarciam)
>> > Work smarter, not harder!.
>> >
>> > --
>> > View this message in context:
>> >
>>
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
> o?by-user=t>
>>
> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
> ?by-user=t>
>> o?by-user=t>
>> > n-tp2955144p2955255.html
>> > Sent from the Users forum mailing list archive at Nabble.com.
>> >
>> >
> ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: [hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2956214&i=6>
>> > For additional commands, e-mail: [hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2956214&i=7>
>> >
>> >
>> >
> ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: [hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2956214&i=8>
>> > For additional commands, e-mail: [hidden
>> email]<http://user/SendEmail.jtp?type=node&node=2956214&i=9>
>> >
>> >
>> >
>> > ------------------------------
>> >  View message @
>> >
>>
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
> o?by-user=t>
>> n-tp2955144p2956214.html
>> > To start a new topic under Apache Wicket, email
>> >
>> [hidden email]
> <http://user/SendEmail.jtp?type=node&node=2956527&i=4><ml-node%2B1842946
> -39801187
>>
>> [hidden email] <http://user/SendEmail.jtp?type=node&node=2956527&i=5>>
>> > To unsubscribe from Apache Wicket, click
>>
> here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp<
> http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-us
> er=t>?
>>
>>
> tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
>> QyOTQ2fDEyNTYxMzc3ODY=>.
>> >
>> >
>> >
>>
>>
>> --
>> Sincerely,
>> JC (http://www.linkedin.com/in/jcgarciam)
>> Work smarter, not harder!.
>>
>> --
>> View this message in context:
>>
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
> o?by-user=t>
>> n-tp2955144p2956283.html
>> Sent from the Users forum mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden
> email]<http://user/SendEmail.jtp?type=node&node=2956527&i=6>
>> For additional commands, e-mail: [hidden
> email]<http://user/SendEmail.jtp?type=node&node=2956527&i=7>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden
> email]<http://user/SendEmail.jtp?type=node&node=2956527&i=8>
>> For additional commands, e-mail: [hidden
> email]<http://user/SendEmail.jtp?type=node&node=2956527&i=9>
>>
>>
>>
>> ------------------------------
>>  View message @
>>
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
> n-tp2955144p2956527.html
>> To start a new topic under Apache Wicket, email
>>
> ml-node+1842946-398011874-65838@n4.nabble.com<ml-node%2B1842946-39801187
> 4-65838@n4.nabble.com>
>> To unsubscribe from Apache Wicket, click
> here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?
> tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
> QyOTQ2fDEyNTYxMzc3ODY=>.
>>
>>
>>
>
>
> --
> Sincerely,
> JC (http://www.linkedin.com/in/jcgarciam)
> Work smarter, not harder!.
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
> n-tp2955144p2956669.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


RE: DropDownChoice/Model Confusion

Posted by Shelli Orton <Sh...@sjrb.ca>.
The childRecordService is a stateless JPA bean and the getList method
executes a named query on the database.  The logs show that the SQL to
retrieve the list from the db is called every time (i.e. no caching).

Shelli

-----Original Message-----
From: Daniel Stoch [mailto:daniel.stoch@gmail.com] 
Sent: Wednesday, October 06, 2010 1:37 AM
To: users@wicket.apache.org
Subject: Re: DropDownChoice/Model Confusion

The code looks ok. Maybe the problem is in childRecordService:
childRecordService.getList()
when method getList() does not reflect changes until you create a new
session. So maybe the problem is related to your service layer? Have
you checked whet this method returns inside childRecordsModel.load() ?

--
Daniel

On Tue, Oct 5, 2010 at 10:23 PM, Shelli Orton <Sh...@sjrb.ca>
wrote:
> This is what my class basically looks like, hope it helps:

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


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


Re: DropDownChoice/Model Confusion

Posted by Daniel Stoch <da...@gmail.com>.
The code looks ok. Maybe the problem is in childRecordService:
childRecordService.getList()
when method getList() does not reflect changes until you create a new
session. So maybe the problem is related to your service layer? Have
you checked whet this method returns inside childRecordsModel.load() ?

--
Daniel

On Tue, Oct 5, 2010 at 10:23 PM, Shelli Orton <Sh...@sjrb.ca> wrote:
> This is what my class basically looks like, hope it helps:

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


RE: DropDownChoice/Model Confusion

Posted by Shelli Orton <Sh...@sjrb.ca>.
This is what my class basically looks like, hope it helps:

-----------------

package my.app;

import my.model.AlreadyExistsException;
import my.model.DoesNotExistException;
import my.model.FailedUpdateException;
import my.model.HasChildRelationsException;
import my.model.ParentRecord;
import my.model.ChildRecord;

import org.apache.wicket.behavior.SimpleAttributeModifier;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.Button;
import org.apache.wicket.markup.html.form.DropDownChoice;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.model.PropertyModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ChildRecordPanel // extends AbstractTabPanel
{
    private static final long serialVersionUID = 1L;
    private static Logger log =
LoggerFactory.getLogger(ChildRecordPanel.class);

    private ChildRecord selectedChildRecord;
    private String unmodifiedChildRecord;
        
    @SuppressWarnings({"rawtypes"})
    public ChildRecordPanel(String id)
    {
        super(id);

        Form selectForEditForm = new Form("selectForEditForm");
        
        editGroup = new EditGroup("editGroup");
        editGroup.setVisible(false);

        selectForEditForm.add(new
DropDownChoice<ChildRecord>("childRecords",
                new PropertyModel<ChildRecord>(this,
"selectedChildRecord"),
                childRecordsModel,
                new ChildRecordRenderer()).setNullValid(false));

        Button add = new Button("add")
        {
            private static final long serialVersionUID = 1L;

            public void onSubmit()
            {
                selectedChildRecord = new ChildRecord();
                isNew = true;
                editLegend = "New";
                editGroup.setVisible(true);
            } 
        };

        selectForEditForm.add(add);

        Button edit = new Button("edit")
        {
            private static final long serialVersionUID = 1L;

            public void onSubmit()
            {
                unmodifiedChildRecord = selectedChildRecord.getName();
                isNew = false;
                editLegend = "Edit";
                editGroup.setVisible(true);
            }
        };
        
        selectForEditForm.add(edit);

        Button delete = new Button("delete")
        {
            private static final long serialVersionUID = 1L;

            public void onSubmit()
            {
                try
                {
                    unmodifiedChildRecord =
selectedChildRecord.getName();
 
childRecordService.delete(selectedChildRecord.getName(), user);
                    selectedChildRecord = null;
                    info("Deleted '" + unmodifiedChildRecord + "'");
                }
                catch (DoesNotExistException e)
                {
                    error("'" + selectedChildRecord.getName() + "' does
not exist.");
                }
                catch (HasChildRelationsException e)
                {
                    error("Cannot delete until children have been
removed.");
                }

                // Update the dropdown list
                // TODO how?
                
                // Close the panel
                editGroup.setVisible(false);
            }
        };
        
        // Add confirmation dialog box
        delete.add(new SimpleAttributeModifier(
                "onclick", "if (!confirm('Please confirm you want to
delete...') ){ return false; }")); 

        selectForEditForm.add(delete);
        
        add(selectForEditForm);
        add(editGroup);
    }

    class EditGroup extends WebMarkupContainer
    {
        private static final long serialVersionUID = 1L;

        @SuppressWarnings("rawtypes")
        public EditGroup(String id)
        {
            super(id);
            add(new Label("editLegend", new
PropertyModel(ChildRecordPanel.this, "editLegend")));
            
            Form editForm = new Form("editForm");
            editForm.add(new Label("childRecordLabel", "Child"));
            editForm.add(new Label("parentRecordLabel", "Parent"));

            editForm.add(new TextField<String>("childRecordText",
                    new PropertyModel<String>(ChildRecordPanel.this,
                            "selectedChildRecord.name")));
            
            editForm.add(new DropDownChoice<ParentRecord>("parents",
                    new
PropertyModel<ParentRecord>(ChildRecordPanel.this,
"selectedChildRecord.parent"),
                    ChildRecordPanel.this.getParentRecords(),
                    new ParentRecordRenderer()).setNullValid(false));

            editForm.add(new Button("save")
            {
                private static final long serialVersionUID = 1L;

                public void onSubmit()
                {
                    if (isNew)
                    {
                        try
                        {
 
childRecordService.create(selectedChildRecord, user);
                            info("Created '" +
selectedChildRecord.getName() + "'");
                        }
                        catch (AlreadyExistsException e)
                        {
                            error(selectedChildRecord.getName() + "
already exists.");
                        }
                    }
                    else
                    {
                        try
                        {
                            
 
childRecordService.update(unmodifiedChildRecord, selectedChildRecord,
user);
                            info("Updated '" +
selectedChildRecord.getName() + "'");
                        }
                        catch (FailedUpdateException e)
                        {
                            log.error("Error updating '" +
selectedChildRecord.getName() + "'", e);
                            error("An error occured during update.
Please contact the system administrator.");
                        }
                        catch (DoesNotExistException e)
                        {
                            error("'" + selectedChildRecord.getName() +
"' does not exist.");
                        }
                    }
                    
                    // Update the dropdown list
                    // TODO how?

                    // Close the panel
                    editGroup.setVisible(false);
                }
            });

            editForm.add(new Button("cancel")
            {
                private static final long serialVersionUID = 1L;

                public void onSubmit()
                {
                    selectedChildRecord = null;
                    editGroup.setVisible(false);
                }
            }.setDefaultFormProcessing(false));

            add(editForm);
        }

    }
    
    // ***************************************************************
    // These variables/inner classes in the "real" code live in
    // AbstractTabPanel so that they are accessible by all tab panels
    // ***************************************************************
    
    // TODO set to the logged in user
    String user = "Unknown";

    private boolean isNew = false;
    private String editLegend;
    private EditGroup editGroup;

    class ChildRecordRenderer implements IChoiceRenderer<ChildRecord>
    {
        private static final long serialVersionUID = 1L;

        // Gets the display value that is visible to the end user.
        public Object getDisplayValue(ChildRecord childRecord)
        {
            return childRecord.getName();
        }

        // Gets the value that is invisble to the end user, and that is
used as
        // the selection id.
        public String getIdValue(ChildRecord childRecord, int index)
        {
            return childRecord.getName();
        }
    }

    class ParentRecordRenderer implements IChoiceRenderer<ParentRecord>
    {
        private static final long serialVersionUID = 1L;

        // Gets the display value that is visible to the end user.
        public Object getDisplayValue(ParentRecord childRecord)
        {
            return parentRecord.getName();
        }

        // Gets the value that is invisble to the end user, and that is
used as
        // the selection id.
        public String getIdValue(ParentRecord parentRecord, int index)
        {
            return parentRecord.getName();
        }
    }
    
    LoadableDetachableModel<List<ChildRecord>> childRecordsModel = new
LoadableDetachableModel<List<ChildRecord>>()
    {
        private static final long serialVersionUID = 1L;

        @Override
        protected List<ChildRecord> load()
        {
            return childRecordService.getList();
        }
    };
}

-----Original Message-----
From: jcgarciam [mailto:jcgarciam@gmail.com] 
Sent: Tuesday, October 05, 2010 1:31 PM
To: users@wicket.apache.org
Subject: Re: DropDownChoice/Model Confusion


There should not need to force the LDB to reload,

Can you share more code?



On Tue, Oct 5, 2010 at 4:27 PM, Shelli Orton [via Apache Wicket] <
ml-node+2956722-1309362030-65838@n4.nabble.com<ml-node%2B2956722-1309362
030-65838@n4.nabble.com>
> wrote:

> No, I'm not using AJAX.  Is there a way to force the LDB to reload?
>
> Shelli
>
> -----Original Message-----
> From: jcgarciam [mailto:[hidden
email]<http://user/SendEmail.jtp?type=node&node=2956722&i=0>]
>
> Sent: Tuesday, October 05, 2010 12:52 PM
> To: [hidden email]
<http://user/SendEmail.jtp?type=node&node=2956722&i=1>
> Subject: Re: DropDownChoice/Model Confusion
>
>
> I dont think it may be related to the hierarchy, are you using AJAX?
>
> On Tue, Oct 5, 2010 at 2:38 PM, Shelli Orton [via Apache Wicket] <
> [hidden email]
<http://user/SendEmail.jtp?type=node&node=2956722&i=2><ml-node%2B2956527
-38526551
>
> [hidden email] <http://user/SendEmail.jtp?type=node&node=2956722&i=3>>
> > wrote:
>
> > Hmm, that code sort of works.  When I create or edit a record, the
> list
>
> > is updated.  However, when I delete a record it is not.  My
component
> > hierarchy is set up like this (hope it makes sense):
> >
> > TabPanel
> >   - SelectForEditForm
> >     - MyRecords (DDC)
> >     - Add (Button)
> >     - Edit (Button)
> >     - Delete (Button)
> >   - EditGroup (WebMarkupContainer)
> >     - EditForm
> >       - MyRecord Name (TextField)
> >       - MyRecord Attribute (DDC)
> >       - Save (Button)
> >       - Cancel (Button)
> >
> > I created the EditGroup so that I can hide/display the edit panel.
> > Debugging the application shows that the save button onSubmit is
> called
> > before the update of the myRecordsModel LDM and this is why the list
> is
> > updated when I create/edit a record. The delete button onSubmit is
> > called after the update of the myRecordsModel LDM and that is why a
> > deleted record is still visible in the list.
> >
> > I think the issue has something to do with the buttons being in
> > different places in the component hierarchy. Can you provide any
> > guidance on if there's some way to have the LDM updated after the
> delete
> > onSubmit?
> >
> > Thanks again,
> > Shelli
> >
> > -----Original Message-----
> > From: jcgarciam [mailto:[hidden
> email]<http://user/SendEmail.jtp?type=node&node=2956527&i=0>]
> >
> > Sent: Tuesday, October 05, 2010 9:33 AM
> > To: [hidden email]
> <http://user/SendEmail.jtp?type=node&node=2956527&i=1>
> > Subject: Re: DropDownChoice/Model Confusion
> >
> >
> > Yes, that should make your DDC to query the list any time it needs
to
> re
> > render.
> >
> > To your 2nd. question in order to set a default or selected value,
> just
> > set
> > a "MyRecord" reference to your property, keep in mind that your
> > "MyRecord"
> > should implement and equals/hashcode correctly.
> >
> >
> > On Tue, Oct 5, 2010 at 12:00 PM, Shelli Orton [via Apache Wicket] <
> > [hidden email]
>
<http://user/SendEmail.jtp?type=node&node=2956527&i=2><ml-node%2B2956214
> -1797994
>
> >
> > [hidden email]
<http://user/SendEmail.jtp?type=node&node=2956527&i=3>>
> > > wrote:
> >
> > > Hi,
> > >
> > > Thanks for replying.  Just to clarify, do you mean do something
like
> > > this:
> > >
> > >
> > >     LoadableDetachableModel<List<MyRecord>> myRecordsModel = new
> > > LoadableDetachableModel<List<MyRecord>>()
> > >     {
> > >         @Override
> > >         protected List<MyRecord> load()
> > >         {
> > >             return myRecordService.getList();
> > >         }
> > >     };
> > >
> > >     MyRecord selectedRecord;
> > >
> > >     form.add(new DropDownChoice<MyRecord>("records",
> > >         new PropertyModel<MyRecord>(this, "selectedRecord"),
> > >         myRecordsModel,
> > >         new MyRecordRenderer()).setNullValid(false));
> > >
> > > Shelli
> > >
> > > -----Original Message-----
> > > From: jcgarciam [mailto:[hidden
> > email]<http://user/SendEmail.jtp?type=node&node=2956214&i=0>]
> > >
> > > Sent: Monday, October 04, 2010 6:27 PM
> > > To: [hidden email]
> > <http://user/SendEmail.jtp?type=node&node=2956214&i=1>
> > > Subject: Re: DropDownChoice/Model Confusion
> > >
> > >
> > > Hi, instead of passing  "getMyRecords()" in the constructor wrap
it
> > > around
> > > a LoadableDetachableModel and pass that model to the DDC. The
> > difference
> > > is
> > > that your current list is fetch only once at construction of your
> > pages
> >
> > > and
> > > is considered static because its never get called again unless you
> > > triggered
> > > it by entering to a new page instance, while by using a LDM the
> > > component
> > > will ask for it every time it needs to re-render them.
> > >
> > >
> > > On Mon, Oct 4, 2010 at 6:52 PM, Shelli Orton [via Apache Wicket] <
> > > [hidden email]
> >
>
<http://user/SendEmail.jtp?type=node&node=2956214&i=2><ml-node%2B2955144
> > -66557051
> >
> > >
> > > [hidden email]
> <http://user/SendEmail.jtp?type=node&node=2956214&i=3>>
> > > > wrote:
> > >
> > > > I am writing a (simple?) database CRUD app where I have multiple
> tab
> > > > panels that encapsulate the different tables in the database.
On
> a
> > > > panel there's a dropdownchoice which lists the existing records
> for
> > > that
> > > > table.  There's also create, delete and edit buttons (and and
edit
> > > panel
> > > > with save and cancel buttons).  When I create, edit or delete
any
> of
> > > the
> > > > records, the dropdownchoice list doesn't reflect the changes
until
> I
> > > > open a new session.  So my question is how to reload the list
> after
>
> > > one
> > > > of these actions is done?
> > > >
> > > > Currently my dropdownchoice model is set like this:
> > > >
> > > >     MyRecord selectedRecord;
> > > >     ...
> > > >     form.add(new DropDownChoice<MyRecord>("records",
> > > >         new PropertyModel<MyRecord>(this, "selectedRecord"),
> > > >         getMyRecords(), // method that retrieves from the
database
> > > (via
> > > > JPA)
> > > >         new MyRecordRenderer()).setNullValid(false)); // used to
> > > return
> > > > the display attribute of MyRecord
> > > >
> > > > I am trying to understand if using a LoadableDetachableModel
will
> do
> > > the
> > >
> > > > reload that I want. Also, I don't know how to set the
> selectedRecord
>
> > > > using that type of model or if it's even possible.
> > > >
> > > > Any advice?
> > > >
> > > > Thanks!
> > > >
> > > > Shelli
> > > >
> > > >
> >
---------------------------------------------------------------------
> >
> > > > To unsubscribe, e-mail: [hidden
> > > email]<http://user/SendEmail.jtp?type=node&node=2955144&i=0>
> > > > For additional commands, e-mail: [hidden
> > > email]<http://user/SendEmail.jtp?type=node&node=2955144&i=1>
> > > >
> > > >
> > > >
> > > > ------------------------------
> > > >  View message @
> > > >
> > >
> >
>
http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
o?by-user=t>
>
<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
?by-user=t>
> o?by-user=t>
> >
>
<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
?by-user=t>
>
<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
?by-user=t>
> ?by-user=t>
> > o?by-user=t>
> > > n-tp2955144p2955144.html
> > > > To start a new topic under Apache Wicket, email
> > > >
> > > [hidden email]
> >
>
<http://user/SendEmail.jtp?type=node&node=2956214&i=4><ml-node%2B1842946
> > -39801187
> > >
> > > [hidden email]
> <http://user/SendEmail.jtp?type=node&node=2956214&i=5>>
> > > > To unsubscribe from Apache Wicket, click
> > >
> >
>
here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp<
http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-us
er=t><
>
>
http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-us
<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-u
s&by-user=t>
> er=t><
> >
> >
>
http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-us
<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-u
s&by-user=t>
>
<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-u
<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-u
&by-user=t>
> s&by-user=t>
> > er=t>?
> > >
> > >
> >
>
tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
>
> >
> > > QyOTQ2fDEyNTYxMzc3ODY=>.
> > > >
> > > >
> > > >
> > >
> > >
> > > --
> > > Sincerely,
> > > JC (http://www.linkedin.com/in/jcgarciam)
> > > Work smarter, not harder!.
> > >
> > > --
> > > View this message in context:
> > >
> >
>
http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
o?by-user=t>
>
<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
?by-user=t>
> o?by-user=t>
> >
>
<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
?by-user=t>
>
<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
?by-user=t>
> ?by-user=t>
> > o?by-user=t>
> > > n-tp2955144p2955255.html
> > > Sent from the Users forum mailing list archive at Nabble.com.
> > >
> > >
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [hidden
> > email]<http://user/SendEmail.jtp?type=node&node=2956214&i=6>
> > > For additional commands, e-mail: [hidden
> > email]<http://user/SendEmail.jtp?type=node&node=2956214&i=7>
> > >
> > >
> > >
> ---------------------------------------------------------------------
>
> > > To unsubscribe, e-mail: [hidden
> > email]<http://user/SendEmail.jtp?type=node&node=2956214&i=8>
> > > For additional commands, e-mail: [hidden
> > email]<http://user/SendEmail.jtp?type=node&node=2956214&i=9>
> > >
> > >
> > >
> > > ------------------------------
> > >  View message @
> > >
> >
>
http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
o?by-user=t>
>
<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
?by-user=t>
> o?by-user=t>
> > n-tp2955144p2956214.html
> > > To start a new topic under Apache Wicket, email
> > >
> > [hidden email]
>
<http://user/SendEmail.jtp?type=node&node=2956527&i=4><ml-node%2B1842946
> -39801187
> >
> > [hidden email]
<http://user/SendEmail.jtp?type=node&node=2956527&i=5>>
> > > To unsubscribe from Apache Wicket, click
> >
>
here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp<
http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-us
er=t><
>
>
http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-us
<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-u
s&by-user=t>
> er=t>?
> >
> >
>
tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
>
> > QyOTQ2fDEyNTYxMzc3ODY=>.
> > >
> > >
> > >
> >
> >
> > --
> > Sincerely,
> > JC (http://www.linkedin.com/in/jcgarciam)
> > Work smarter, not harder!.
> >
> > --
> > View this message in context:
> >
>
http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
o?by-user=t>
>
<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
?by-user=t>
> o?by-user=t>
> > n-tp2955144p2956283.html
> > Sent from the Users forum mailing list archive at Nabble.com.
> >
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden
> email]<http://user/SendEmail.jtp?type=node&node=2956527&i=6>
> > For additional commands, e-mail: [hidden
> email]<http://user/SendEmail.jtp?type=node&node=2956527&i=7>
> >
> >
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden
> email]<http://user/SendEmail.jtp?type=node&node=2956527&i=8>
> > For additional commands, e-mail: [hidden
> email]<http://user/SendEmail.jtp?type=node&node=2956527&i=9>
> >
> >
> >
> > ------------------------------
> >  View message @
> >
>
http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
o?by-user=t>
> n-tp2955144p2956527.html
> > To start a new topic under Apache Wicket, email
> >
> [hidden email]
<http://user/SendEmail.jtp?type=node&node=2956722&i=4><ml-node%2B1842946
-39801187
>
> [hidden email] <http://user/SendEmail.jtp?type=node&node=2956722&i=5>>
> > To unsubscribe from Apache Wicket, click
>
here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp<
http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-us
er=t>?
>
>
tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
> QyOTQ2fDEyNTYxMzc3ODY=>.
> >
> >
> >
>
>
> --
> Sincerely,
> JC (http://www.linkedin.com/in/jcgarciam)
> Work smarter, not harder!.
>
> --
> View this message in context:
>
http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
o?by-user=t>
> n-tp2955144p2956669.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden
email]<http://user/SendEmail.jtp?type=node&node=2956722&i=6>
> For additional commands, e-mail: [hidden
email]<http://user/SendEmail.jtp?type=node&node=2956722&i=7>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden
email]<http://user/SendEmail.jtp?type=node&node=2956722&i=8>
> For additional commands, e-mail: [hidden
email]<http://user/SendEmail.jtp?type=node&node=2956722&i=9>
>
>
>
> ------------------------------
>  View message @
>
http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
n-tp2955144p2956722.html
> To start a new topic under Apache Wicket, email
>
ml-node+1842946-398011874-65838@n4.nabble.com<ml-node%2B1842946-39801187
4-65838@n4.nabble.com>
> To unsubscribe from Apache Wicket, click
here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?
tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
QyOTQ2fDEyNTYxMzc3ODY=>.
>
>
>


-- 
Sincerely,
JC (http://www.linkedin.com/in/jcgarciam)
Work smarter, not harder!.

-- 
View this message in context:
http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
n-tp2955144p2956729.html
Sent from the Users forum mailing list archive at Nabble.com.

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


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


Re: DropDownChoice/Model Confusion

Posted by jcgarciam <jc...@gmail.com>.
There should not need to force the LDB to reload,

Can you share more code?



On Tue, Oct 5, 2010 at 4:27 PM, Shelli Orton [via Apache Wicket] <
ml-node+2956722-1309362030-65838@n4.nabble.com<ml...@n4.nabble.com>
> wrote:

> No, I'm not using AJAX.  Is there a way to force the LDB to reload?
>
> Shelli
>
> -----Original Message-----
> From: jcgarciam [mailto:[hidden email]<http://user/SendEmail.jtp?type=node&node=2956722&i=0>]
>
> Sent: Tuesday, October 05, 2010 12:52 PM
> To: [hidden email] <http://user/SendEmail.jtp?type=node&node=2956722&i=1>
> Subject: Re: DropDownChoice/Model Confusion
>
>
> I dont think it may be related to the hierarchy, are you using AJAX?
>
> On Tue, Oct 5, 2010 at 2:38 PM, Shelli Orton [via Apache Wicket] <
> [hidden email] <http://user/SendEmail.jtp?type=node&node=2956722&i=2><ml-node%2B2956527-38526551
>
> [hidden email] <http://user/SendEmail.jtp?type=node&node=2956722&i=3>>
> > wrote:
>
> > Hmm, that code sort of works.  When I create or edit a record, the
> list
>
> > is updated.  However, when I delete a record it is not.  My component
> > hierarchy is set up like this (hope it makes sense):
> >
> > TabPanel
> >   - SelectForEditForm
> >     - MyRecords (DDC)
> >     - Add (Button)
> >     - Edit (Button)
> >     - Delete (Button)
> >   - EditGroup (WebMarkupContainer)
> >     - EditForm
> >       - MyRecord Name (TextField)
> >       - MyRecord Attribute (DDC)
> >       - Save (Button)
> >       - Cancel (Button)
> >
> > I created the EditGroup so that I can hide/display the edit panel.
> > Debugging the application shows that the save button onSubmit is
> called
> > before the update of the myRecordsModel LDM and this is why the list
> is
> > updated when I create/edit a record. The delete button onSubmit is
> > called after the update of the myRecordsModel LDM and that is why a
> > deleted record is still visible in the list.
> >
> > I think the issue has something to do with the buttons being in
> > different places in the component hierarchy. Can you provide any
> > guidance on if there's some way to have the LDM updated after the
> delete
> > onSubmit?
> >
> > Thanks again,
> > Shelli
> >
> > -----Original Message-----
> > From: jcgarciam [mailto:[hidden
> email]<http://user/SendEmail.jtp?type=node&node=2956527&i=0>]
> >
> > Sent: Tuesday, October 05, 2010 9:33 AM
> > To: [hidden email]
> <http://user/SendEmail.jtp?type=node&node=2956527&i=1>
> > Subject: Re: DropDownChoice/Model Confusion
> >
> >
> > Yes, that should make your DDC to query the list any time it needs to
> re
> > render.
> >
> > To your 2nd. question in order to set a default or selected value,
> just
> > set
> > a "MyRecord" reference to your property, keep in mind that your
> > "MyRecord"
> > should implement and equals/hashcode correctly.
> >
> >
> > On Tue, Oct 5, 2010 at 12:00 PM, Shelli Orton [via Apache Wicket] <
> > [hidden email]
> <http://user/SendEmail.jtp?type=node&node=2956527&i=2><ml-node%2B2956214
> -1797994
>
> >
> > [hidden email] <http://user/SendEmail.jtp?type=node&node=2956527&i=3>>
> > > wrote:
> >
> > > Hi,
> > >
> > > Thanks for replying.  Just to clarify, do you mean do something like
> > > this:
> > >
> > >
> > >     LoadableDetachableModel<List<MyRecord>> myRecordsModel = new
> > > LoadableDetachableModel<List<MyRecord>>()
> > >     {
> > >         @Override
> > >         protected List<MyRecord> load()
> > >         {
> > >             return myRecordService.getList();
> > >         }
> > >     };
> > >
> > >     MyRecord selectedRecord;
> > >
> > >     form.add(new DropDownChoice<MyRecord>("records",
> > >         new PropertyModel<MyRecord>(this, "selectedRecord"),
> > >         myRecordsModel,
> > >         new MyRecordRenderer()).setNullValid(false));
> > >
> > > Shelli
> > >
> > > -----Original Message-----
> > > From: jcgarciam [mailto:[hidden
> > email]<http://user/SendEmail.jtp?type=node&node=2956214&i=0>]
> > >
> > > Sent: Monday, October 04, 2010 6:27 PM
> > > To: [hidden email]
> > <http://user/SendEmail.jtp?type=node&node=2956214&i=1>
> > > Subject: Re: DropDownChoice/Model Confusion
> > >
> > >
> > > Hi, instead of passing  "getMyRecords()" in the constructor wrap it
> > > around
> > > a LoadableDetachableModel and pass that model to the DDC. The
> > difference
> > > is
> > > that your current list is fetch only once at construction of your
> > pages
> >
> > > and
> > > is considered static because its never get called again unless you
> > > triggered
> > > it by entering to a new page instance, while by using a LDM the
> > > component
> > > will ask for it every time it needs to re-render them.
> > >
> > >
> > > On Mon, Oct 4, 2010 at 6:52 PM, Shelli Orton [via Apache Wicket] <
> > > [hidden email]
> >
> <http://user/SendEmail.jtp?type=node&node=2956214&i=2><ml-node%2B2955144
> > -66557051
> >
> > >
> > > [hidden email]
> <http://user/SendEmail.jtp?type=node&node=2956214&i=3>>
> > > > wrote:
> > >
> > > > I am writing a (simple?) database CRUD app where I have multiple
> tab
> > > > panels that encapsulate the different tables in the database.  On
> a
> > > > panel there's a dropdownchoice which lists the existing records
> for
> > > that
> > > > table.  There's also create, delete and edit buttons (and and edit
> > > panel
> > > > with save and cancel buttons).  When I create, edit or delete any
> of
> > > the
> > > > records, the dropdownchoice list doesn't reflect the changes until
> I
> > > > open a new session.  So my question is how to reload the list
> after
>
> > > one
> > > > of these actions is done?
> > > >
> > > > Currently my dropdownchoice model is set like this:
> > > >
> > > >     MyRecord selectedRecord;
> > > >     ...
> > > >     form.add(new DropDownChoice<MyRecord>("records",
> > > >         new PropertyModel<MyRecord>(this, "selectedRecord"),
> > > >         getMyRecords(), // method that retrieves from the database
> > > (via
> > > > JPA)
> > > >         new MyRecordRenderer()).setNullValid(false)); // used to
> > > return
> > > > the display attribute of MyRecord
> > > >
> > > > I am trying to understand if using a LoadableDetachableModel will
> do
> > > the
> > >
> > > > reload that I want. Also, I don't know how to set the
> selectedRecord
>
> > > > using that type of model or if it's even possible.
> > > >
> > > > Any advice?
> > > >
> > > > Thanks!
> > > >
> > > > Shelli
> > > >
> > > >
> > ---------------------------------------------------------------------
> >
> > > > To unsubscribe, e-mail: [hidden
> > > email]<http://user/SendEmail.jtp?type=node&node=2955144&i=0>
> > > > For additional commands, e-mail: [hidden
> > > email]<http://user/SendEmail.jtp?type=node&node=2955144&i=1>
> > > >
> > > >
> > > >
> > > > ------------------------------
> > > >  View message @
> > > >
> > >
> >
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio?by-user=t>
> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi?by-user=t>
> o?by-user=t>
> >
> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi?by-user=t>
> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi?by-user=t>
> ?by-user=t>
> > o?by-user=t>
> > > n-tp2955144p2955144.html
> > > > To start a new topic under Apache Wicket, email
> > > >
> > > [hidden email]
> >
> <http://user/SendEmail.jtp?type=node&node=2956214&i=4><ml-node%2B1842946
> > -39801187
> > >
> > > [hidden email]
> <http://user/SendEmail.jtp?type=node&node=2956214&i=5>>
> > > > To unsubscribe from Apache Wicket, click
> > >
> >
> here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-user=t><
>
> http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-us<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-us&by-user=t>
> er=t><
> >
> >
> http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-us<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-us&by-user=t>
> <http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-u<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-u&by-user=t>
> s&by-user=t>
> > er=t>?
> > >
> > >
> >
> tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
>
> >
> > > QyOTQ2fDEyNTYxMzc3ODY=>.
> > > >
> > > >
> > > >
> > >
> > >
> > > --
> > > Sincerely,
> > > JC (http://www.linkedin.com/in/jcgarciam)
> > > Work smarter, not harder!.
> > >
> > > --
> > > View this message in context:
> > >
> >
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio?by-user=t>
> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi?by-user=t>
> o?by-user=t>
> >
> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi?by-user=t>
> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi?by-user=t>
> ?by-user=t>
> > o?by-user=t>
> > > n-tp2955144p2955255.html
> > > Sent from the Users forum mailing list archive at Nabble.com.
> > >
> > >
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [hidden
> > email]<http://user/SendEmail.jtp?type=node&node=2956214&i=6>
> > > For additional commands, e-mail: [hidden
> > email]<http://user/SendEmail.jtp?type=node&node=2956214&i=7>
> > >
> > >
> > >
> ---------------------------------------------------------------------
>
> > > To unsubscribe, e-mail: [hidden
> > email]<http://user/SendEmail.jtp?type=node&node=2956214&i=8>
> > > For additional commands, e-mail: [hidden
> > email]<http://user/SendEmail.jtp?type=node&node=2956214&i=9>
> > >
> > >
> > >
> > > ------------------------------
> > >  View message @
> > >
> >
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio?by-user=t>
> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi?by-user=t>
> o?by-user=t>
> > n-tp2955144p2956214.html
> > > To start a new topic under Apache Wicket, email
> > >
> > [hidden email]
> <http://user/SendEmail.jtp?type=node&node=2956527&i=4><ml-node%2B1842946
> -39801187
> >
> > [hidden email] <http://user/SendEmail.jtp?type=node&node=2956527&i=5>>
> > > To unsubscribe from Apache Wicket, click
> >
> here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-user=t><
>
> http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-us<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-us&by-user=t>
> er=t>?
> >
> >
> tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
>
> > QyOTQ2fDEyNTYxMzc3ODY=>.
> > >
> > >
> > >
> >
> >
> > --
> > Sincerely,
> > JC (http://www.linkedin.com/in/jcgarciam)
> > Work smarter, not harder!.
> >
> > --
> > View this message in context:
> >
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio?by-user=t>
> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi?by-user=t>
> o?by-user=t>
> > n-tp2955144p2956283.html
> > Sent from the Users forum mailing list archive at Nabble.com.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden
> email]<http://user/SendEmail.jtp?type=node&node=2956527&i=6>
> > For additional commands, e-mail: [hidden
> email]<http://user/SendEmail.jtp?type=node&node=2956527&i=7>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden
> email]<http://user/SendEmail.jtp?type=node&node=2956527&i=8>
> > For additional commands, e-mail: [hidden
> email]<http://user/SendEmail.jtp?type=node&node=2956527&i=9>
> >
> >
> >
> > ------------------------------
> >  View message @
> >
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio?by-user=t>
> n-tp2955144p2956527.html
> > To start a new topic under Apache Wicket, email
> >
> [hidden email] <http://user/SendEmail.jtp?type=node&node=2956722&i=4><ml-node%2B1842946-39801187
>
> [hidden email] <http://user/SendEmail.jtp?type=node&node=2956722&i=5>>
> > To unsubscribe from Apache Wicket, click
> here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-user=t>?
>
> tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
> QyOTQ2fDEyNTYxMzc3ODY=>.
> >
> >
> >
>
>
> --
> Sincerely,
> JC (http://www.linkedin.com/in/jcgarciam)
> Work smarter, not harder!.
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio?by-user=t>
> n-tp2955144p2956669.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=2956722&i=6>
> For additional commands, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=2956722&i=7>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=2956722&i=8>
> For additional commands, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=2956722&i=9>
>
>
>
> ------------------------------
>  View message @
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusion-tp2955144p2956722.html
> To start a new topic under Apache Wicket, email
> ml-node+1842946-398011874-65838@n4.nabble.com<ml...@n4.nabble.com>
> To unsubscribe from Apache Wicket, click here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxODQyOTQ2fDEyNTYxMzc3ODY=>.
>
>
>


-- 
Sincerely,
JC (http://www.linkedin.com/in/jcgarciam)
Work smarter, not harder!.

-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusion-tp2955144p2956729.html
Sent from the Users forum mailing list archive at Nabble.com.

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


RE: DropDownChoice/Model Confusion

Posted by Shelli Orton <Sh...@sjrb.ca>.
No, I'm not using AJAX.  Is there a way to force the LDB to reload?

Shelli

-----Original Message-----
From: jcgarciam [mailto:jcgarciam@gmail.com] 
Sent: Tuesday, October 05, 2010 12:52 PM
To: users@wicket.apache.org
Subject: Re: DropDownChoice/Model Confusion


I dont think it may be related to the hierarchy, are you using AJAX?

On Tue, Oct 5, 2010 at 2:38 PM, Shelli Orton [via Apache Wicket] <
ml-node+2956527-385265518-65838@n4.nabble.com<ml-node%2B2956527-38526551
8-65838@n4.nabble.com>
> wrote:

> Hmm, that code sort of works.  When I create or edit a record, the
list
> is updated.  However, when I delete a record it is not.  My component
> hierarchy is set up like this (hope it makes sense):
>
> TabPanel
>   - SelectForEditForm
>     - MyRecords (DDC)
>     - Add (Button)
>     - Edit (Button)
>     - Delete (Button)
>   - EditGroup (WebMarkupContainer)
>     - EditForm
>       - MyRecord Name (TextField)
>       - MyRecord Attribute (DDC)
>       - Save (Button)
>       - Cancel (Button)
>
> I created the EditGroup so that I can hide/display the edit panel.
> Debugging the application shows that the save button onSubmit is
called
> before the update of the myRecordsModel LDM and this is why the list
is
> updated when I create/edit a record. The delete button onSubmit is
> called after the update of the myRecordsModel LDM and that is why a
> deleted record is still visible in the list.
>
> I think the issue has something to do with the buttons being in
> different places in the component hierarchy. Can you provide any
> guidance on if there's some way to have the LDM updated after the
delete
> onSubmit?
>
> Thanks again,
> Shelli
>
> -----Original Message-----
> From: jcgarciam [mailto:[hidden
email]<http://user/SendEmail.jtp?type=node&node=2956527&i=0>]
>
> Sent: Tuesday, October 05, 2010 9:33 AM
> To: [hidden email]
<http://user/SendEmail.jtp?type=node&node=2956527&i=1>
> Subject: Re: DropDownChoice/Model Confusion
>
>
> Yes, that should make your DDC to query the list any time it needs to
re
> render.
>
> To your 2nd. question in order to set a default or selected value,
just
> set
> a "MyRecord" reference to your property, keep in mind that your
> "MyRecord"
> should implement and equals/hashcode correctly.
>
>
> On Tue, Oct 5, 2010 at 12:00 PM, Shelli Orton [via Apache Wicket] <
> [hidden email]
<http://user/SendEmail.jtp?type=node&node=2956527&i=2><ml-node%2B2956214
-1797994
>
> [hidden email] <http://user/SendEmail.jtp?type=node&node=2956527&i=3>>
> > wrote:
>
> > Hi,
> >
> > Thanks for replying.  Just to clarify, do you mean do something like
> > this:
> >
> >
> >     LoadableDetachableModel<List<MyRecord>> myRecordsModel = new
> > LoadableDetachableModel<List<MyRecord>>()
> >     {
> >         @Override
> >         protected List<MyRecord> load()
> >         {
> >             return myRecordService.getList();
> >         }
> >     };
> >
> >     MyRecord selectedRecord;
> >
> >     form.add(new DropDownChoice<MyRecord>("records",
> >         new PropertyModel<MyRecord>(this, "selectedRecord"),
> >         myRecordsModel,
> >         new MyRecordRenderer()).setNullValid(false));
> >
> > Shelli
> >
> > -----Original Message-----
> > From: jcgarciam [mailto:[hidden
> email]<http://user/SendEmail.jtp?type=node&node=2956214&i=0>]
> >
> > Sent: Monday, October 04, 2010 6:27 PM
> > To: [hidden email]
> <http://user/SendEmail.jtp?type=node&node=2956214&i=1>
> > Subject: Re: DropDownChoice/Model Confusion
> >
> >
> > Hi, instead of passing  "getMyRecords()" in the constructor wrap it
> > around
> > a LoadableDetachableModel and pass that model to the DDC. The
> difference
> > is
> > that your current list is fetch only once at construction of your
> pages
>
> > and
> > is considered static because its never get called again unless you
> > triggered
> > it by entering to a new page instance, while by using a LDM the
> > component
> > will ask for it every time it needs to re-render them.
> >
> >
> > On Mon, Oct 4, 2010 at 6:52 PM, Shelli Orton [via Apache Wicket] <
> > [hidden email]
>
<http://user/SendEmail.jtp?type=node&node=2956214&i=2><ml-node%2B2955144
> -66557051
>
> >
> > [hidden email]
<http://user/SendEmail.jtp?type=node&node=2956214&i=3>>
> > > wrote:
> >
> > > I am writing a (simple?) database CRUD app where I have multiple
tab
> > > panels that encapsulate the different tables in the database.  On
a
> > > panel there's a dropdownchoice which lists the existing records
for
> > that
> > > table.  There's also create, delete and edit buttons (and and edit
> > panel
> > > with save and cancel buttons).  When I create, edit or delete any
of
> > the
> > > records, the dropdownchoice list doesn't reflect the changes until
I
> > > open a new session.  So my question is how to reload the list
after
> > one
> > > of these actions is done?
> > >
> > > Currently my dropdownchoice model is set like this:
> > >
> > >     MyRecord selectedRecord;
> > >     ...
> > >     form.add(new DropDownChoice<MyRecord>("records",
> > >         new PropertyModel<MyRecord>(this, "selectedRecord"),
> > >         getMyRecords(), // method that retrieves from the database
> > (via
> > > JPA)
> > >         new MyRecordRenderer()).setNullValid(false)); // used to
> > return
> > > the display attribute of MyRecord
> > >
> > > I am trying to understand if using a LoadableDetachableModel will
do
> > the
> >
> > > reload that I want. Also, I don't know how to set the
selectedRecord
> > > using that type of model or if it's even possible.
> > >
> > > Any advice?
> > >
> > > Thanks!
> > >
> > > Shelli
> > >
> > >
> ---------------------------------------------------------------------
>
> > > To unsubscribe, e-mail: [hidden
> > email]<http://user/SendEmail.jtp?type=node&node=2955144&i=0>
> > > For additional commands, e-mail: [hidden
> > email]<http://user/SendEmail.jtp?type=node&node=2955144&i=1>
> > >
> > >
> > >
> > > ------------------------------
> > >  View message @
> > >
> >
>
http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
o?by-user=t>
>
<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
?by-user=t>
> o?by-user=t>
> > n-tp2955144p2955144.html
> > > To start a new topic under Apache Wicket, email
> > >
> > [hidden email]
>
<http://user/SendEmail.jtp?type=node&node=2956214&i=4><ml-node%2B1842946
> -39801187
> >
> > [hidden email]
<http://user/SendEmail.jtp?type=node&node=2956214&i=5>>
> > > To unsubscribe from Apache Wicket, click
> >
>
here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp<
http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-us
er=t><
>
>
http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-us
<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-u
s&by-user=t>
> er=t>?
> >
> >
>
tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
>
> > QyOTQ2fDEyNTYxMzc3ODY=>.
> > >
> > >
> > >
> >
> >
> > --
> > Sincerely,
> > JC (http://www.linkedin.com/in/jcgarciam)
> > Work smarter, not harder!.
> >
> > --
> > View this message in context:
> >
>
http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
o?by-user=t>
>
<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
?by-user=t>
> o?by-user=t>
> > n-tp2955144p2955255.html
> > Sent from the Users forum mailing list archive at Nabble.com.
> >
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden
> email]<http://user/SendEmail.jtp?type=node&node=2956214&i=6>
> > For additional commands, e-mail: [hidden
> email]<http://user/SendEmail.jtp?type=node&node=2956214&i=7>
> >
> >
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden
> email]<http://user/SendEmail.jtp?type=node&node=2956214&i=8>
> > For additional commands, e-mail: [hidden
> email]<http://user/SendEmail.jtp?type=node&node=2956214&i=9>
> >
> >
> >
> > ------------------------------
> >  View message @
> >
>
http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
o?by-user=t>
> n-tp2955144p2956214.html
> > To start a new topic under Apache Wicket, email
> >
> [hidden email]
<http://user/SendEmail.jtp?type=node&node=2956527&i=4><ml-node%2B1842946
-39801187
>
> [hidden email] <http://user/SendEmail.jtp?type=node&node=2956527&i=5>>
> > To unsubscribe from Apache Wicket, click
>
here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp<
http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-us
er=t>?
>
>
tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
> QyOTQ2fDEyNTYxMzc3ODY=>.
> >
> >
> >
>
>
> --
> Sincerely,
> JC (http://www.linkedin.com/in/jcgarciam)
> Work smarter, not harder!.
>
> --
> View this message in context:
>
http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
o?by-user=t>
> n-tp2955144p2956283.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden
email]<http://user/SendEmail.jtp?type=node&node=2956527&i=6>
> For additional commands, e-mail: [hidden
email]<http://user/SendEmail.jtp?type=node&node=2956527&i=7>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden
email]<http://user/SendEmail.jtp?type=node&node=2956527&i=8>
> For additional commands, e-mail: [hidden
email]<http://user/SendEmail.jtp?type=node&node=2956527&i=9>
>
>
>
> ------------------------------
>  View message @
>
http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
n-tp2955144p2956527.html
> To start a new topic under Apache Wicket, email
>
ml-node+1842946-398011874-65838@n4.nabble.com<ml-node%2B1842946-39801187
4-65838@n4.nabble.com>
> To unsubscribe from Apache Wicket, click
here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?
tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
QyOTQ2fDEyNTYxMzc3ODY=>.
>
>
>


-- 
Sincerely,
JC (http://www.linkedin.com/in/jcgarciam)
Work smarter, not harder!.

-- 
View this message in context:
http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
n-tp2955144p2956669.html
Sent from the Users forum mailing list archive at Nabble.com.

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


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


Re: DropDownChoice/Model Confusion

Posted by jcgarciam <jc...@gmail.com>.
I dont think it may be related to the hierarchy, are you using AJAX?

On Tue, Oct 5, 2010 at 2:38 PM, Shelli Orton [via Apache Wicket] <
ml-node+2956527-385265518-65838@n4.nabble.com<ml...@n4.nabble.com>
> wrote:

> Hmm, that code sort of works.  When I create or edit a record, the list
> is updated.  However, when I delete a record it is not.  My component
> hierarchy is set up like this (hope it makes sense):
>
> TabPanel
>   - SelectForEditForm
>     - MyRecords (DDC)
>     - Add (Button)
>     - Edit (Button)
>     - Delete (Button)
>   - EditGroup (WebMarkupContainer)
>     - EditForm
>       - MyRecord Name (TextField)
>       - MyRecord Attribute (DDC)
>       - Save (Button)
>       - Cancel (Button)
>
> I created the EditGroup so that I can hide/display the edit panel.
> Debugging the application shows that the save button onSubmit is called
> before the update of the myRecordsModel LDM and this is why the list is
> updated when I create/edit a record. The delete button onSubmit is
> called after the update of the myRecordsModel LDM and that is why a
> deleted record is still visible in the list.
>
> I think the issue has something to do with the buttons being in
> different places in the component hierarchy. Can you provide any
> guidance on if there's some way to have the LDM updated after the delete
> onSubmit?
>
> Thanks again,
> Shelli
>
> -----Original Message-----
> From: jcgarciam [mailto:[hidden email]<http://user/SendEmail.jtp?type=node&node=2956527&i=0>]
>
> Sent: Tuesday, October 05, 2010 9:33 AM
> To: [hidden email] <http://user/SendEmail.jtp?type=node&node=2956527&i=1>
> Subject: Re: DropDownChoice/Model Confusion
>
>
> Yes, that should make your DDC to query the list any time it needs to re
> render.
>
> To your 2nd. question in order to set a default or selected value, just
> set
> a "MyRecord" reference to your property, keep in mind that your
> "MyRecord"
> should implement and equals/hashcode correctly.
>
>
> On Tue, Oct 5, 2010 at 12:00 PM, Shelli Orton [via Apache Wicket] <
> [hidden email] <http://user/SendEmail.jtp?type=node&node=2956527&i=2><ml-node%2B2956214-1797994
>
> [hidden email] <http://user/SendEmail.jtp?type=node&node=2956527&i=3>>
> > wrote:
>
> > Hi,
> >
> > Thanks for replying.  Just to clarify, do you mean do something like
> > this:
> >
> >
> >     LoadableDetachableModel<List<MyRecord>> myRecordsModel = new
> > LoadableDetachableModel<List<MyRecord>>()
> >     {
> >         @Override
> >         protected List<MyRecord> load()
> >         {
> >             return myRecordService.getList();
> >         }
> >     };
> >
> >     MyRecord selectedRecord;
> >
> >     form.add(new DropDownChoice<MyRecord>("records",
> >         new PropertyModel<MyRecord>(this, "selectedRecord"),
> >         myRecordsModel,
> >         new MyRecordRenderer()).setNullValid(false));
> >
> > Shelli
> >
> > -----Original Message-----
> > From: jcgarciam [mailto:[hidden
> email]<http://user/SendEmail.jtp?type=node&node=2956214&i=0>]
> >
> > Sent: Monday, October 04, 2010 6:27 PM
> > To: [hidden email]
> <http://user/SendEmail.jtp?type=node&node=2956214&i=1>
> > Subject: Re: DropDownChoice/Model Confusion
> >
> >
> > Hi, instead of passing  "getMyRecords()" in the constructor wrap it
> > around
> > a LoadableDetachableModel and pass that model to the DDC. The
> difference
> > is
> > that your current list is fetch only once at construction of your
> pages
>
> > and
> > is considered static because its never get called again unless you
> > triggered
> > it by entering to a new page instance, while by using a LDM the
> > component
> > will ask for it every time it needs to re-render them.
> >
> >
> > On Mon, Oct 4, 2010 at 6:52 PM, Shelli Orton [via Apache Wicket] <
> > [hidden email]
> <http://user/SendEmail.jtp?type=node&node=2956214&i=2><ml-node%2B2955144
> -66557051
>
> >
> > [hidden email] <http://user/SendEmail.jtp?type=node&node=2956214&i=3>>
> > > wrote:
> >
> > > I am writing a (simple?) database CRUD app where I have multiple tab
> > > panels that encapsulate the different tables in the database.  On a
> > > panel there's a dropdownchoice which lists the existing records for
> > that
> > > table.  There's also create, delete and edit buttons (and and edit
> > panel
> > > with save and cancel buttons).  When I create, edit or delete any of
> > the
> > > records, the dropdownchoice list doesn't reflect the changes until I
> > > open a new session.  So my question is how to reload the list after
> > one
> > > of these actions is done?
> > >
> > > Currently my dropdownchoice model is set like this:
> > >
> > >     MyRecord selectedRecord;
> > >     ...
> > >     form.add(new DropDownChoice<MyRecord>("records",
> > >         new PropertyModel<MyRecord>(this, "selectedRecord"),
> > >         getMyRecords(), // method that retrieves from the database
> > (via
> > > JPA)
> > >         new MyRecordRenderer()).setNullValid(false)); // used to
> > return
> > > the display attribute of MyRecord
> > >
> > > I am trying to understand if using a LoadableDetachableModel will do
> > the
> >
> > > reload that I want. Also, I don't know how to set the selectedRecord
> > > using that type of model or if it's even possible.
> > >
> > > Any advice?
> > >
> > > Thanks!
> > >
> > > Shelli
> > >
> > >
> ---------------------------------------------------------------------
>
> > > To unsubscribe, e-mail: [hidden
> > email]<http://user/SendEmail.jtp?type=node&node=2955144&i=0>
> > > For additional commands, e-mail: [hidden
> > email]<http://user/SendEmail.jtp?type=node&node=2955144&i=1>
> > >
> > >
> > >
> > > ------------------------------
> > >  View message @
> > >
> >
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio?by-user=t>
> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi?by-user=t>
> o?by-user=t>
> > n-tp2955144p2955144.html
> > > To start a new topic under Apache Wicket, email
> > >
> > [hidden email]
> <http://user/SendEmail.jtp?type=node&node=2956214&i=4><ml-node%2B1842946
> -39801187
> >
> > [hidden email] <http://user/SendEmail.jtp?type=node&node=2956214&i=5>>
> > > To unsubscribe from Apache Wicket, click
> >
> here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-user=t><
>
> http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-us<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-us&by-user=t>
> er=t>?
> >
> >
> tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
>
> > QyOTQ2fDEyNTYxMzc3ODY=>.
> > >
> > >
> > >
> >
> >
> > --
> > Sincerely,
> > JC (http://www.linkedin.com/in/jcgarciam)
> > Work smarter, not harder!.
> >
> > --
> > View this message in context:
> >
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio?by-user=t>
> <http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi?by-user=t>
> o?by-user=t>
> > n-tp2955144p2955255.html
> > Sent from the Users forum mailing list archive at Nabble.com.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden
> email]<http://user/SendEmail.jtp?type=node&node=2956214&i=6>
> > For additional commands, e-mail: [hidden
> email]<http://user/SendEmail.jtp?type=node&node=2956214&i=7>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden
> email]<http://user/SendEmail.jtp?type=node&node=2956214&i=8>
> > For additional commands, e-mail: [hidden
> email]<http://user/SendEmail.jtp?type=node&node=2956214&i=9>
> >
> >
> >
> > ------------------------------
> >  View message @
> >
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio?by-user=t>
> n-tp2955144p2956214.html
> > To start a new topic under Apache Wicket, email
> >
> [hidden email] <http://user/SendEmail.jtp?type=node&node=2956527&i=4><ml-node%2B1842946-39801187
>
> [hidden email] <http://user/SendEmail.jtp?type=node&node=2956527&i=5>>
> > To unsubscribe from Apache Wicket, click
> here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-user=t>?
>
> tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
> QyOTQ2fDEyNTYxMzc3ODY=>.
> >
> >
> >
>
>
> --
> Sincerely,
> JC (http://www.linkedin.com/in/jcgarciam)
> Work smarter, not harder!.
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio?by-user=t>
> n-tp2955144p2956283.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=2956527&i=6>
> For additional commands, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=2956527&i=7>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=2956527&i=8>
> For additional commands, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=2956527&i=9>
>
>
>
> ------------------------------
>  View message @
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusion-tp2955144p2956527.html
> To start a new topic under Apache Wicket, email
> ml-node+1842946-398011874-65838@n4.nabble.com<ml...@n4.nabble.com>
> To unsubscribe from Apache Wicket, click here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxODQyOTQ2fDEyNTYxMzc3ODY=>.
>
>
>


-- 
Sincerely,
JC (http://www.linkedin.com/in/jcgarciam)
Work smarter, not harder!.

-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusion-tp2955144p2956669.html
Sent from the Users forum mailing list archive at Nabble.com.

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


RE: DropDownChoice/Model Confusion

Posted by Shelli Orton <Sh...@sjrb.ca>.
Hmm, that code sort of works.  When I create or edit a record, the list
is updated.  However, when I delete a record it is not.  My component
hierarchy is set up like this (hope it makes sense):

TabPanel
  - SelectForEditForm
    - MyRecords (DDC)
    - Add (Button)
    - Edit (Button)
    - Delete (Button)
  - EditGroup (WebMarkupContainer)
    - EditForm
      - MyRecord Name (TextField)
      - MyRecord Attribute (DDC)
      - Save (Button)
      - Cancel (Button)

I created the EditGroup so that I can hide/display the edit panel.
Debugging the application shows that the save button onSubmit is called
before the update of the myRecordsModel LDM and this is why the list is
updated when I create/edit a record. The delete button onSubmit is
called after the update of the myRecordsModel LDM and that is why a
deleted record is still visible in the list.

I think the issue has something to do with the buttons being in
different places in the component hierarchy. Can you provide any
guidance on if there's some way to have the LDM updated after the delete
onSubmit?

Thanks again,
Shelli
 
-----Original Message-----
From: jcgarciam [mailto:jcgarciam@gmail.com] 
Sent: Tuesday, October 05, 2010 9:33 AM
To: users@wicket.apache.org
Subject: Re: DropDownChoice/Model Confusion


Yes, that should make your DDC to query the list any time it needs to re
render.

To your 2nd. question in order to set a default or selected value, just
set
a "MyRecord" reference to your property, keep in mind that your
"MyRecord"
should implement and equals/hashcode correctly.


On Tue, Oct 5, 2010 at 12:00 PM, Shelli Orton [via Apache Wicket] <
ml-node+2956214-1797994246-65838@n4.nabble.com<ml-node%2B2956214-1797994
246-65838@n4.nabble.com>
> wrote:

> Hi,
>
> Thanks for replying.  Just to clarify, do you mean do something like
> this:
>
>
>     LoadableDetachableModel<List<MyRecord>> myRecordsModel = new
> LoadableDetachableModel<List<MyRecord>>()
>     {
>         @Override
>         protected List<MyRecord> load()
>         {
>             return myRecordService.getList();
>         }
>     };
>
>     MyRecord selectedRecord;
>
>     form.add(new DropDownChoice<MyRecord>("records",
>         new PropertyModel<MyRecord>(this, "selectedRecord"),
>         myRecordsModel,
>         new MyRecordRenderer()).setNullValid(false));
>
> Shelli
>
> -----Original Message-----
> From: jcgarciam [mailto:[hidden
email]<http://user/SendEmail.jtp?type=node&node=2956214&i=0>]
>
> Sent: Monday, October 04, 2010 6:27 PM
> To: [hidden email]
<http://user/SendEmail.jtp?type=node&node=2956214&i=1>
> Subject: Re: DropDownChoice/Model Confusion
>
>
> Hi, instead of passing  "getMyRecords()" in the constructor wrap it
> around
> a LoadableDetachableModel and pass that model to the DDC. The
difference
> is
> that your current list is fetch only once at construction of your
pages
> and
> is considered static because its never get called again unless you
> triggered
> it by entering to a new page instance, while by using a LDM the
> component
> will ask for it every time it needs to re-render them.
>
>
> On Mon, Oct 4, 2010 at 6:52 PM, Shelli Orton [via Apache Wicket] <
> [hidden email]
<http://user/SendEmail.jtp?type=node&node=2956214&i=2><ml-node%2B2955144
-66557051
>
> [hidden email] <http://user/SendEmail.jtp?type=node&node=2956214&i=3>>
> > wrote:
>
> > I am writing a (simple?) database CRUD app where I have multiple tab
> > panels that encapsulate the different tables in the database.  On a
> > panel there's a dropdownchoice which lists the existing records for
> that
> > table.  There's also create, delete and edit buttons (and and edit
> panel
> > with save and cancel buttons).  When I create, edit or delete any of
> the
> > records, the dropdownchoice list doesn't reflect the changes until I
> > open a new session.  So my question is how to reload the list after
> one
> > of these actions is done?
> >
> > Currently my dropdownchoice model is set like this:
> >
> >     MyRecord selectedRecord;
> >     ...
> >     form.add(new DropDownChoice<MyRecord>("records",
> >         new PropertyModel<MyRecord>(this, "selectedRecord"),
> >         getMyRecords(), // method that retrieves from the database
> (via
> > JPA)
> >         new MyRecordRenderer()).setNullValid(false)); // used to
> return
> > the display attribute of MyRecord
> >
> > I am trying to understand if using a LoadableDetachableModel will do
> the
>
> > reload that I want. Also, I don't know how to set the selectedRecord
> > using that type of model or if it's even possible.
> >
> > Any advice?
> >
> > Thanks!
> >
> > Shelli
> >
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden
> email]<http://user/SendEmail.jtp?type=node&node=2955144&i=0>
> > For additional commands, e-mail: [hidden
> email]<http://user/SendEmail.jtp?type=node&node=2955144&i=1>
> >
> >
> >
> > ------------------------------
> >  View message @
> >
>
http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
o?by-user=t>
> n-tp2955144p2955144.html
> > To start a new topic under Apache Wicket, email
> >
> [hidden email]
<http://user/SendEmail.jtp?type=node&node=2956214&i=4><ml-node%2B1842946
-39801187
>
> [hidden email] <http://user/SendEmail.jtp?type=node&node=2956214&i=5>>
> > To unsubscribe from Apache Wicket, click
>
here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp<
http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-us
er=t>?
>
>
tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
> QyOTQ2fDEyNTYxMzc3ODY=>.
> >
> >
> >
>
>
> --
> Sincerely,
> JC (http://www.linkedin.com/in/jcgarciam)
> Work smarter, not harder!.
>
> --
> View this message in context:
>
http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
o?by-user=t>
> n-tp2955144p2955255.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden
email]<http://user/SendEmail.jtp?type=node&node=2956214&i=6>
> For additional commands, e-mail: [hidden
email]<http://user/SendEmail.jtp?type=node&node=2956214&i=7>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden
email]<http://user/SendEmail.jtp?type=node&node=2956214&i=8>
> For additional commands, e-mail: [hidden
email]<http://user/SendEmail.jtp?type=node&node=2956214&i=9>
>
>
>
> ------------------------------
>  View message @
>
http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
n-tp2955144p2956214.html
> To start a new topic under Apache Wicket, email
>
ml-node+1842946-398011874-65838@n4.nabble.com<ml-node%2B1842946-39801187
4-65838@n4.nabble.com>
> To unsubscribe from Apache Wicket, click
here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?
tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
QyOTQ2fDEyNTYxMzc3ODY=>.
>
>
>


-- 
Sincerely,
JC (http://www.linkedin.com/in/jcgarciam)
Work smarter, not harder!.

-- 
View this message in context:
http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
n-tp2955144p2956283.html
Sent from the Users forum mailing list archive at Nabble.com.

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


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


Re: DropDownChoice/Model Confusion

Posted by jcgarciam <jc...@gmail.com>.
Yes, that should make your DDC to query the list any time it needs to re
render.

To your 2nd. question in order to set a default or selected value, just set
a "MyRecord" reference to your property, keep in mind that your "MyRecord"
should implement and equals/hashcode correctly.


On Tue, Oct 5, 2010 at 12:00 PM, Shelli Orton [via Apache Wicket] <
ml-node+2956214-1797994246-65838@n4.nabble.com<ml...@n4.nabble.com>
> wrote:

> Hi,
>
> Thanks for replying.  Just to clarify, do you mean do something like
> this:
>
>
>     LoadableDetachableModel<List<MyRecord>> myRecordsModel = new
> LoadableDetachableModel<List<MyRecord>>()
>     {
>         @Override
>         protected List<MyRecord> load()
>         {
>             return myRecordService.getList();
>         }
>     };
>
>     MyRecord selectedRecord;
>
>     form.add(new DropDownChoice<MyRecord>("records",
>         new PropertyModel<MyRecord>(this, "selectedRecord"),
>         myRecordsModel,
>         new MyRecordRenderer()).setNullValid(false));
>
> Shelli
>
> -----Original Message-----
> From: jcgarciam [mailto:[hidden email]<http://user/SendEmail.jtp?type=node&node=2956214&i=0>]
>
> Sent: Monday, October 04, 2010 6:27 PM
> To: [hidden email] <http://user/SendEmail.jtp?type=node&node=2956214&i=1>
> Subject: Re: DropDownChoice/Model Confusion
>
>
> Hi, instead of passing  "getMyRecords()" in the constructor wrap it
> around
> a LoadableDetachableModel and pass that model to the DDC. The difference
> is
> that your current list is fetch only once at construction of your pages
> and
> is considered static because its never get called again unless you
> triggered
> it by entering to a new page instance, while by using a LDM the
> component
> will ask for it every time it needs to re-render them.
>
>
> On Mon, Oct 4, 2010 at 6:52 PM, Shelli Orton [via Apache Wicket] <
> [hidden email] <http://user/SendEmail.jtp?type=node&node=2956214&i=2><ml-node%2B2955144-66557051
>
> [hidden email] <http://user/SendEmail.jtp?type=node&node=2956214&i=3>>
> > wrote:
>
> > I am writing a (simple?) database CRUD app where I have multiple tab
> > panels that encapsulate the different tables in the database.  On a
> > panel there's a dropdownchoice which lists the existing records for
> that
> > table.  There's also create, delete and edit buttons (and and edit
> panel
> > with save and cancel buttons).  When I create, edit or delete any of
> the
> > records, the dropdownchoice list doesn't reflect the changes until I
> > open a new session.  So my question is how to reload the list after
> one
> > of these actions is done?
> >
> > Currently my dropdownchoice model is set like this:
> >
> >     MyRecord selectedRecord;
> >     ...
> >     form.add(new DropDownChoice<MyRecord>("records",
> >         new PropertyModel<MyRecord>(this, "selectedRecord"),
> >         getMyRecords(), // method that retrieves from the database
> (via
> > JPA)
> >         new MyRecordRenderer()).setNullValid(false)); // used to
> return
> > the display attribute of MyRecord
> >
> > I am trying to understand if using a LoadableDetachableModel will do
> the
>
> > reload that I want. Also, I don't know how to set the selectedRecord
> > using that type of model or if it's even possible.
> >
> > Any advice?
> >
> > Thanks!
> >
> > Shelli
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden
> email]<http://user/SendEmail.jtp?type=node&node=2955144&i=0>
> > For additional commands, e-mail: [hidden
> email]<http://user/SendEmail.jtp?type=node&node=2955144&i=1>
> >
> >
> >
> > ------------------------------
> >  View message @
> >
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio?by-user=t>
> n-tp2955144p2955144.html
> > To start a new topic under Apache Wicket, email
> >
> [hidden email] <http://user/SendEmail.jtp?type=node&node=2956214&i=4><ml-node%2B1842946-39801187
>
> [hidden email] <http://user/SendEmail.jtp?type=node&node=2956214&i=5>>
> > To unsubscribe from Apache Wicket, click
> here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-user=t>?
>
> tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
> QyOTQ2fDEyNTYxMzc3ODY=>.
> >
> >
> >
>
>
> --
> Sincerely,
> JC (http://www.linkedin.com/in/jcgarciam)
> Work smarter, not harder!.
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio<http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio?by-user=t>
> n-tp2955144p2955255.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=2956214&i=6>
> For additional commands, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=2956214&i=7>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=2956214&i=8>
> For additional commands, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=2956214&i=9>
>
>
>
> ------------------------------
>  View message @
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusion-tp2955144p2956214.html
> To start a new topic under Apache Wicket, email
> ml-node+1842946-398011874-65838@n4.nabble.com<ml...@n4.nabble.com>
> To unsubscribe from Apache Wicket, click here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxODQyOTQ2fDEyNTYxMzc3ODY=>.
>
>
>


-- 
Sincerely,
JC (http://www.linkedin.com/in/jcgarciam)
Work smarter, not harder!.

-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusion-tp2955144p2956283.html
Sent from the Users forum mailing list archive at Nabble.com.

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


RE: DropDownChoice/Model Confusion

Posted by Shelli Orton <Sh...@sjrb.ca>.
Hi,

Thanks for replying.  Just to clarify, do you mean do something like
this:


    LoadableDetachableModel<List<MyRecord>> myRecordsModel = new
LoadableDetachableModel<List<MyRecord>>()
    {
        @Override
        protected List<MyRecord> load()
        {
            return myRecordService.getList();
        }
    };

    MyRecord selectedRecord;

    form.add(new DropDownChoice<MyRecord>("records",
        new PropertyModel<MyRecord>(this, "selectedRecord"),
        myRecordsModel,
        new MyRecordRenderer()).setNullValid(false));

Shelli

-----Original Message-----
From: jcgarciam [mailto:jcgarciam@gmail.com] 
Sent: Monday, October 04, 2010 6:27 PM
To: users@wicket.apache.org
Subject: Re: DropDownChoice/Model Confusion


Hi, instead of passing  "getMyRecords()" in the constructor wrap it
around
a LoadableDetachableModel and pass that model to the DDC. The difference
is
that your current list is fetch only once at construction of your pages
and
is considered static because its never get called again unless you
triggered
it by entering to a new page instance, while by using a LDM the
component
will ask for it every time it needs to re-render them.


On Mon, Oct 4, 2010 at 6:52 PM, Shelli Orton [via Apache Wicket] <
ml-node+2955144-665570512-65838@n4.nabble.com<ml-node%2B2955144-66557051
2-65838@n4.nabble.com>
> wrote:

> I am writing a (simple?) database CRUD app where I have multiple tab
> panels that encapsulate the different tables in the database.  On a
> panel there's a dropdownchoice which lists the existing records for
that
> table.  There's also create, delete and edit buttons (and and edit
panel
> with save and cancel buttons).  When I create, edit or delete any of
the
> records, the dropdownchoice list doesn't reflect the changes until I
> open a new session.  So my question is how to reload the list after
one
> of these actions is done?
>
> Currently my dropdownchoice model is set like this:
>
>     MyRecord selectedRecord;
>     ...
>     form.add(new DropDownChoice<MyRecord>("records",
>         new PropertyModel<MyRecord>(this, "selectedRecord"),
>         getMyRecords(), // method that retrieves from the database
(via
> JPA)
>         new MyRecordRenderer()).setNullValid(false)); // used to
return
> the display attribute of MyRecord
>
> I am trying to understand if using a LoadableDetachableModel will do
the
> reload that I want. Also, I don't know how to set the selectedRecord
> using that type of model or if it's even possible.
>
> Any advice?
>
> Thanks!
>
> Shelli
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden
email]<http://user/SendEmail.jtp?type=node&node=2955144&i=0>
> For additional commands, e-mail: [hidden
email]<http://user/SendEmail.jtp?type=node&node=2955144&i=1>
>
>
>
> ------------------------------
>  View message @
>
http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
n-tp2955144p2955144.html
> To start a new topic under Apache Wicket, email
>
ml-node+1842946-398011874-65838@n4.nabble.com<ml-node%2B1842946-39801187
4-65838@n4.nabble.com>
> To unsubscribe from Apache Wicket, click
here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?
tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD
QyOTQ2fDEyNTYxMzc3ODY=>.
>
>
>


-- 
Sincerely,
JC (http://www.linkedin.com/in/jcgarciam)
Work smarter, not harder!.

-- 
View this message in context:
http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
n-tp2955144p2955255.html
Sent from the Users forum mailing list archive at Nabble.com.

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


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


Re: DropDownChoice/Model Confusion

Posted by jcgarciam <jc...@gmail.com>.
Hi, instead of passing  "getMyRecords()" in the constructor wrap it around
a LoadableDetachableModel and pass that model to the DDC. The difference is
that your current list is fetch only once at construction of your pages and
is considered static because its never get called again unless you triggered
it by entering to a new page instance, while by using a LDM the component
will ask for it every time it needs to re-render them.


On Mon, Oct 4, 2010 at 6:52 PM, Shelli Orton [via Apache Wicket] <
ml-node+2955144-665570512-65838@n4.nabble.com<ml...@n4.nabble.com>
> wrote:

> I am writing a (simple?) database CRUD app where I have multiple tab
> panels that encapsulate the different tables in the database.  On a
> panel there's a dropdownchoice which lists the existing records for that
> table.  There's also create, delete and edit buttons (and and edit panel
> with save and cancel buttons).  When I create, edit or delete any of the
> records, the dropdownchoice list doesn't reflect the changes until I
> open a new session.  So my question is how to reload the list after one
> of these actions is done?
>
> Currently my dropdownchoice model is set like this:
>
>     MyRecord selectedRecord;
>     ...
>     form.add(new DropDownChoice<MyRecord>("records",
>         new PropertyModel<MyRecord>(this, "selectedRecord"),
>         getMyRecords(), // method that retrieves from the database (via
> JPA)
>         new MyRecordRenderer()).setNullValid(false)); // used to return
> the display attribute of MyRecord
>
> I am trying to understand if using a LoadableDetachableModel will do the
> reload that I want. Also, I don't know how to set the selectedRecord
> using that type of model or if it's even possible.
>
> Any advice?
>
> Thanks!
>
> Shelli
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=2955144&i=0>
> For additional commands, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=2955144&i=1>
>
>
>
> ------------------------------
>  View message @
> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusion-tp2955144p2955144.html
> To start a new topic under Apache Wicket, email
> ml-node+1842946-398011874-65838@n4.nabble.com<ml...@n4.nabble.com>
> To unsubscribe from Apache Wicket, click here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxODQyOTQ2fDEyNTYxMzc3ODY=>.
>
>
>


-- 
Sincerely,
JC (http://www.linkedin.com/in/jcgarciam)
Work smarter, not harder!.

-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusion-tp2955144p2955255.html
Sent from the Users forum mailing list archive at Nabble.com.

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