Overriding newLink() was the key. However, rather than using a
SubmitLink, I decided to bypass the whole issue entirely by simply
disabling the currently selected link. In my page's constructor, I
added the following code:
TabbedPanel tabbedPanel = new TabbedPanel(tabs, tabs) {
@Override
protected WebMarkupContainer newLink(String linkId, final
int index) {
Link link = new Link(linkId) {
private static final long serialVersionUID = 1L;
@Override
public void onClick() {
setSelectedTab(index);
}
};
link.setEnabled(getSelectedTab() != index);
return link;
}
};
tabbedPanel.setSelectedTab(0);
add(tabbedPanel);
A couple of minor CSS tweaks were needed so the tabs would display
correctly since the disabled a link turns into a span instead.
Anyway, it works like a charm.
Just a suggestion...It would be great if TabbedPanel had a boolean
method called, for example, wantsDisabledSelectedTab() which could be
easily overridden to provide this behavior for us; the default
implementation of newLink() could incorporate this check and disable
the selected tab appropriately.
Thanks,
Justin
On May 21, 2008, at 10:43 PM, Igor Vaynberg wrote:
you can override tabbedpanel.newlink and return a submitlink
instead.that way the form has to be submitted/validated before tabs
can be switched.
-igor
On Wed, May 21, 2008 at 9:51 PM, Justin Morgan - Logic Sector
[EMAIL PROTECTED] wrote:
Hi all,
I'm running into an issue with my TabbedPanel. Currently I have a
TabbedPanel containing two tabs. Each tab panel contains a form.
Here's my
problem scenario:
1. User clicks on a tab to view it (which is really just a link
with fancy
CSS styling)
2. User enters text in that tab's form
3. Without submitting the form via submit button, the user clicks
the tab
again
4. User loses everything typed in the form (DOH!)
The problem occurs because the user clicked on a link which didn't
submit
the form, and so the form contents were lost.
My question is: Is there any way to configure a TabbedPanel to
*not* make a
live link for the currently selected tab?
Thanks for any help,
Justin
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]