Thank you very much .It worked well with submitlinks. I thought it would be 
better with AjaxSubmitlink but i couldn't get it working on that. It doesn't 
move the item when i click first time. next time it gives me 
WicketMessage: org.apache.wicket.WicketRuntimeException: component 
form:masterChainList:1:moveUp not found on page 
com.swishmark.tugboat.tools.MasterChainListPage[id = 8], listener interface = 
[RequestListenerInterface name=IActivePageBehaviorListener, method=public 
abstract void org.apache.wicket.behavior.IBehaviorListener.onRequest()]
Root cause:
org.apache.wicket.WicketRuntimeException: component 
form:masterChainList:1:moveUp not found on page 
com.swishmark.tugboat.tools.MasterChainListPage[id = 8], listener interface = 
[RequestListenerInterface name=IActivePageBehaviorListener, method=public 
abstract void org.apache.wicket.behavior.IBehaviorListener.onRequest()]
     at 
org.apache.wicket.request.AbstractRequestCycleProcessor.resolveListenerInterfaceTarget(AbstractRequestCycleProcessor.java:426)
     at 
org.apache.wicket.request.AbstractRequestCycleProcessor.resolveRenderedPage(AbstractRequestCycleProcessor.java:471)
     at 
org.apache.wicket.protocol.http.WebRequestCycleProcessor.resolve(WebRequestCycleProcessor.java:144)
     at org.apache.wicket.RequestCycle.step(RequestCycle.java:1301)
     at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1419)
     at org.apache.wicket.RequestCycle.request(RequestCycle.java:545)
     at 
org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:456)
     at 
org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:289)
     at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
     at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
     at 
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:204)
     at 
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
     at 
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
     at 
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
     at 
org.apache.catalina.valves.FastCommonAccessLogValve.invoke(FastCommonAccessLogValve.java:482)
     at 
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
     at 
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
     at 
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:875)
     at 
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
     at 
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
     at 
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
     at 
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
     at java.lang.Thread.run(Thread.java:595)
Complete stack:
org.apache.wicket.protocol.http.request.InvalidUrlException: 
org.apache.wicket.WicketRuntimeException: component 
form:masterChainList:1:moveUp not found on page 
com.swishmark.tugboat.tools.MasterChainListPage[id = 8], listener interface = 
[RequestListenerInterface name=IActivePageBehaviorListener, method=public 
abstract void org.apache.wicket.behavior.IBehaviorListener.onRequest()]


Here is my code .
 


/**
     * Returns a link that will move the given item "up" (towards the 
beginning) in the listView.
     * 
     * @param id
     *            Name of move-up link component to create
     * @param item
     * @param form 
     * @return The link component
     */
    public final AjaxSubmitLink moveMyUpLink(final String id, final ListItem<T> 
item, MasterChainListForm form)
    {
        return new AjaxSubmitLink(id)
        {
            private static final long serialVersionUID = 1L;

            /**
             * @see org.apache.wicket.markup.html.link.Link#onClick()
             */
    

            /**
             * @see org.apache.wicket.Component#onBeforeRender()
             */
            @Override
            protected void onBeforeRender()
            {
                super.onBeforeRender();
                //setAutoEnable(false);
                if (getList().indexOf(item.getModelObject()) == 0)
                {
                    setEnabled(false);
                }
            }
            @Override
            protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
                {
                    final int index = getList().indexOf(item.getModelObject());
                    if (index != -1)
                    {   
                        addStateChange(new Change()
                        {
                            private static final long serialVersionUID = 1L;

                            final int oldIndex = index;

                            @Override
                            public void undo()
                            {
                                Collections.swap(getList(), oldIndex - 1, 
oldIndex);
                            }

                        });

                        // Swap items and invalidate listView
                        Collections.swap(getList(), index, index - 1);
                        MasterChainListView.this.removeAll();
                    }
                    
                }
            }

        };
    }

    ListView propertiesList = new MyListView("masterChainList", 
masterChainList) {

            @Override
            protected void populateItem(ListItem item) {
                LeadTransnodeChain leadTransnodeChain = (LeadTransnodeChain) 
item.getModelObject();
                
                  
                item.add(new Label("masterChain", new 
PropertyModel(leadTransnodeChain, "m_masterChainID")));
                item.add(new DropDownChoice("runAs", new 
PropertyModel(leadTransnodeChain, "m_mode"), 
Arrays.asList(LeadTransnodeChain.MODE.values()), new IChoiceRenderer() {
                    public Object getDisplayValue(Object mode) {
                            return ((LeadTransnodeChain.MODE) mode).toString();
                    }

                    public String getIdValue(Object obj, int index) {
                            return obj.toString();
                    }
                    }
                   
                ));
                item.add(moveMyUpLink("moveUp", item, form));
                item.add(moveMyDownLink("moveDown", item, form)); 

    
            }



> From: [email protected]


> Date: Sat, 7 Nov 2009 17:58:01 -0800
> Subject: Re: model update in moveuplink and movedownlink onclick
> To: [email protected]
> 
> you have to use submitlinks for move up/down.
> 
> -igor
> 
> On Sat, Nov 7, 2009 at 4:31 PM, Swarnim Ranjitkar <[email protected]> 
> wrote:
> >
> > Is there anyway that you can update model before you move the item up or 
> > down using moveuplink and movedownlink in listview. My goal is to save the 
> > input data to the model so that I don't loose use input on the item before 
> > moving the item. I did try to extend the ListView and added my own 
> > moveuplink and downlink code called form's updateFormComponentModels() 
> > ámethod but that didn't really help. Does anyone have any idea how this can 
> > be done.
> >
> > LeadTransnodeChain lc = new LeadTransnodeChain(1, 2, 3, 4, 5, 
> > LeadTransnodeChain.MODE.ASYNC);
> > á á á ámasterChainList.add(lc);
> > á á á ámasterChainList.add(new LeadTransnodeChain(11, 12, 13, 14, 15, 
> > LeadTransnodeChain.MODE.SYNC));
> > á á á ámasterChainList.add(new LeadTransnodeChain(21, 22, 23, 24, 25, 
> > LeadTransnodeChain.MODE.SYNC));
> >
> > á á á áListView propertiesList = new MyListView("masterChainList", 
> > masterChainList) {
> >
> > á á á á á �...@override
> > á á á á á áprotected void populateItem(ListItem item) {
> > á á á á á á á áLeadTransnodeChain leadTransnodeChain = (LeadTransnodeChain) 
> > item.getModelObject();
> >
> >
> > á á á á á á á áitem.add(new Label("masterChain", new 
> > PropertyModel(leadTransnodeChain, "m_masterChainID")));
> > á á á á á á á áitem.add(new DropDownChoice("runAs", new 
> > PropertyModel(leadTransnodeChain, "m_mode"), 
> > Arrays.asList(LeadTransnodeChain.MODE.values()), new IChoiceRenderer() {
> > á á á á á á á á á ápublic Object getDisplayValue(Object mode) {
> > á á á á á á á á á á á á á áreturn ((LeadTransnodeChain.MODE) 
> > mode).toString();
> > á á á á á á á á á á}
> >
> > á á á á á á á á á ápublic String getIdValue(Object obj, int index) {
> > á á á á á á á á á á á á á áreturn obj.toString();
> > á á á á á á á á á á}
> > á á á á á á á á á á}
> >
> > á á á á á á á á));
> > á á á á á á á áitem.add(moveMyUpLink("moveUp", item, form));
> > á á á á á á á áitem.add(moveMyDownLink("moveDown", item, form));
> >
> >
> > á á á á á á}
> > á á á á};
> > á áadd(new Button("submitButton"));
> >
> > á á á ápropertiesList.setReuseItems(true);
> > á á á áadd(propertiesList);
> > }public void updateComponentModels(){
> > á á á ásuper.updateFormComponentModels();
> > á á}
> >
> >
> > public abstract class MyListView<T> extends ListView<T> {
> >
> > á á...
> >
> > á áprotected abstract void populateItem(ListItem item) ;
> >
> > á á/**
> > á á * Returns a link that will move the given item "down" (towards the end) 
> > in the listView.
> > á á *
> > á á * @param id
> > á á * á á á á á áName of move-down link component to create
> > á á * @param item
> > á á * @return The link component
> > á á */
> > á ápublic final Link<Void> moveMyDownLink(final String id, final 
> > ListItem<T> item, final MasterChainListForm form)
> > á á{
> > á á á áreturn new Link<Void>(id)
> > á á á á{
> > á á á á á áprivate static final long serialVersionUID = 1L;
> >
> > á á á á á á/**
> > á á á á á á * @see org.apache.wicket.markup.html.link.Link#onClick()
> > á á á á á á */
> > á á á á á �...@override
> > á á á á á ápublic void onClick()
> > á á á á á á{
> > á á á á á á á áfinal int index = getList().indexOf(item.getModelObject());
> > á á á á á á á áif (index != -1)
> > á á á á á á á á{
> > á á á á á á á á á áform.updateComponentModels();
> > á á á á á á á á á áaddStateChange(new Change()
> > á á á á á á á á á á{
> > á á á á á á á á á á á áprivate static final long serialVersionUID = 1L;
> >
> > á á á á á á á á á á á áfinal int oldIndex = index;
> >
> > á á á á á á á á á á á �...@override
> > á á á á á á á á á á á ápublic void undo()
> > á á á á á á á á á á á á{
> > á á á á á á á á á á á á á áCollections.swap(getList(), oldIndex + 1, 
> > oldIndex);
> > á á á á á á á á á á á á}
> >
> > á á á á á á á á á á});
> >
> > á á á á á á á á á á// Swap list items and invalidate listView
> > á á á á á á á á á áCollections.swap(getList(), index, index + 1);
> > á á á á á á á á á áMasterChainListView.this.removeAll();
> > á á á á á á á á}
> > á á á á á á}
> >
> > á á á á á á/**
> > á á á á á á * @see org.apache.wicket.Component#onBeforeRender()
> > á á á á á á */
> > á á á á á �...@override
> > á á á á á áprotected void onBeforeRender()
> > á á á á á á{
> > á á á á á á á ásuper.onBeforeRender();
> > á á á á á á á ásetAutoEnable(false);
> > á á á á á á á áif (getList().indexOf(item.getModelObject()) == 
> > (getList().size() - 1))
> > á á á á á á á á{
> > á á á á á á á á á ásetEnabled(false);
> > á á á á á á á á}
> > á á á á á á}
> > á á á á};
> > á á}
> >
> > á á/**
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 
                                          

Reply via email to