Surely this is what you want for a non-ajax solution:

class MyPage extends Page {
 private TabbedPanel tabPanel;
 ...
 public MyPage() {
   tabPanel = new TabPanel(...);
   add( tabPanel );
   ...
   confirmBtn = new Button("confirm") {
     private static final long serialVersionUID = 1L;

     @Override
     public void onSubmit() {
       tabPanel.setSelectedTab(0);
     }
   };
   add( confirmBtn );
 }
}

And for an ajax solution, just add tabPanel to the ajax request in the submit handler?

Sorry if this isn't right, but I don't see what the issue is.

Gajo Csaba wrote:
That may be true Igor, but there doesn't seem to be any other solution to make this work:

confirmBtn = new Button("confirm") {
   private static final long serialVersionUID = 1L;
   @Override
   public void onSubmit() {
       Page page = getPage();
TabbedPanel tabPanel = ((HomePage)getWebPage()).getTabbedPanel(); tabPanel.setSelectedTab(0);
       setResponsePage(page);
   }
};

I cannot repaint the tabPanel (either with render() or renderComponent()), cannot repaint the whole page, cannot go with Linda's suggestion because even after Martin's fix it still generates an error. I just want to set the tabbedpanel's selected tab to be #0. It's not that complicated. In Swing, I would write: tabPanel.setSelectedTab(0); and that would be it.

Now I'm not very critical about how software systems are constructed, and don't care if some features may cause minor side-effects, or cause the programmer to write a bit hacky code. But having the setSelectedTab() method detach the page for no apparent reason and without any warning is as bad as having a goto command in a programming language. "Side effects" are one of the first thing that you learn in college, and why you should avoid them at all cost. The documentation for the setSelectedTab() says "sets the selected tab". What it's missing is a big warning sign "WARNING!!!! IT DETACHES THE PAGE!!!! WILL CAUSE UNRELATED ERROR MESSAGES!!!"

So what is your suggestion Igor? How should I use the framework properly?

Regards,
Csaba


Igor Vaynberg wrote:
of course there is no reason to use an ajax link if all you are going
to do is repaint the entire page anyways...

also code like this: setresponsepage(getpage()) is always suspect. by
default wicket repaints the same page so there is no need to call
this. when inside ajax you should add components you want repainted to
the request target that is passed in to you.

setresponsepage should only be used when actually going to a different
page. you are not using the framework properly...

-igor

2009/7/29 Martin Makundi <martin.maku...@koodaripalvelut.com>:
1.

You can fix linda's suggestion by calling setOutputMarkupId(true) on
your tabbedpanel.

2. The reason for:

10:42:27 ERROR [RequestCycle] - No Page found for component
[MarkupContainer [Component id = panel]]
java.lang.IllegalStateException: No Page found for component
[MarkupContainer [Component id = panel]]
     at org.apache.wicket.Component.getPage(Component.java:1729)

Is that you just called setSelectedTab() which DISCONNECTS the current
tab from the page hierarcy. Try getting the page before that:
onClick() {
 Page page = getPage();
 tabbedPanel.setSelectedTab(0);
 setREsponsePage(page);
}


**
Martin


**
Martin

2009/7/29 Gajo Csaba <cg...@i-rose.si>:
Hmm there's something very wrong here...

I try to refresh the page like this:
setResponsePage(getPage());

When this is the only action, the current page is refreshed. When I write
setSelectedTab(0) above it, I get an error.

10:42:27 ERROR [RequestCycle] - No Page found for component [MarkupContainer
[Component id = panel]]
java.lang.IllegalStateException: No Page found for component
[MarkupContainer [Component id = panel]]
      at org.apache.wicket.Component.getPage(Component.java:1729)
      at
si.irose.iprojekti.treeview.TreeViewPanel.deleteBtnClick(TreeViewPanel.java:160)
      at
si.irose.iprojekti.treeview.TreeViewPanel.access$200(TreeViewPanel.java:45)
      at
si.irose.iprojekti.treeview.TreeViewPanel$3.onSubmit(TreeViewPanel.java:95)
      at
org.apache.wicket.ajax.markup.html.form.AjaxFallbackButton$1.onSubmit(AjaxFallbackButton.java:74)
      at
org.apache.wicket.ajax.form.AjaxFormSubmitBehavior.onEvent(AjaxFormSubmitBehavior.java:140)
      at
org.apache.wicket.ajax.AjaxEventBehavior.respond(AjaxEventBehavior.java:166)
      at
org.apache.wicket.ajax.AbstractDefaultAjaxBehavior.onRequest(AbstractDefaultAjaxBehavior.java:299)
      at
org.apache.wicket.request.target.component.listener.BehaviorRequestTarget.processEvents(BehaviorRequestTarget.java:105)
      at
org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:92)
      at
org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1192)
      at org.apache.wicket.RequestCycle.step(RequestCycle.java:1271)
      at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1370)
      at org.apache.wicket.RequestCycle.request(RequestCycle.java:501)
      at
org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:455)
      at
org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:288)
      at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
      at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
      at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
      at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
      at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
      at
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
      at java.lang.Thread.run(Thread.java:619)


I've also tried with render() and renderComponent(), on a page and on the
tabPanel level...

Linda's suggestion also generates an error, albeit a different one.
"innertabs" is found in HomePage.html, which looks like this:

<html>
<head>
</head>
<body>
  <wicket:extend>
<div wicket:id="innertabs" class="innertabpanel">[inner tabbed panel
will be here]</div>
  </wicket:extend>
</body>
</html>

The tabbed panel is the "innertabs". The generated exception is:

java.lang.IllegalArgumentException: cannot update component that does not have setOutputMarkupId property set to true. Component: [MarkupContainer
[Component id = innertabs]]
   at
org.apache.wicket.ajax.AjaxRequestTarget.addComponent(AjaxRequestTarget.java:345)
   at
si.irose.iprojekti.treeview.TreeViewPanel.deleteBtnClick(TreeViewPanel.java:161)
   at
si.irose.iprojekti.treeview.TreeViewPanel.access$200(TreeViewPanel.java:45)
   at
si.irose.iprojekti.treeview.TreeViewPanel$3.onSubmit(TreeViewPanel.java:95)
   at
org.apache.wicket.ajax.markup.html.form.AjaxFallbackButton$1.onSubmit(AjaxFallbackButton.java:74)
   at
org.apache.wicket.ajax.form.AjaxFormSubmitBehavior.onEvent(AjaxFormSubmitBehavior.java:140)
   at
org.apache.wicket.ajax.AjaxEventBehavior.respond(AjaxEventBehavior.java:166)
   at
org.apache.wicket.ajax.AbstractDefaultAjaxBehavior.onRequest(AbstractDefaultAjaxBehavior.java:299)
   at
org.apache.wicket.request.target.component.listener.BehaviorRequestTarget.processEvents(BehaviorRequestTarget.java:105)
   at
org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:92)
   at
org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1192)
   at org.apache.wicket.RequestCycle.step(RequestCycle.java:1271)
   at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1370)
   at org.apache.wicket.RequestCycle.request(RequestCycle.java:501)
   at
org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:455)
   at
org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:288)
   at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
   at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
   at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
   at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
   at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
   at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
   at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
   at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
   at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
   at
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
   at java.lang.Thread.run(Thread.java:619)


getPage().addOrReplace(tabPanel); also generates some third error...

tabPanel.addOrReplace(tabPanel); generates an error saying I can't replace a
component with itself :)

Writing the complete URL
?wicket:interface=:2:innertabs:tabs-container:tabs:0:link:1:ILinkListener::
seems to be the only suggestion which actually works for now.





Martin Makundi wrote:
Ah.. do you repaint the page after your ajax button call?

**
Martin

2009/7/29 Gajo Csaba <cg...@i-rose.si>:

This is what the link does in Wicket's source code:

new Link(linkId) {
         private static final long serialVersionUID = 1L;

         @Override
         public void onClick() {
             setSelectedTab(index);   // <-----
         }
     };


This is my code:
 /** Click on the Delete button */
private void deleteBtnClick(AjaxRequestTarget target, Form<?> form) { TabbedPanel tabPanel = ((HomePage)getWebPage()).getTabbedPanel();
     tabPanel.setSelectedTab(0);      // <-------
 }

Wicket's code works, mine doesn't. I've tried with a button and an
ajaxfallbacklink... Maybe I really should redirect to the same page with
another parameter, like you did.

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


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


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



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



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



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

Reply via email to