You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Bürgel, Andreas <An...@de.bucyrus.com> on 2009/05/25 16:51:41 UTC

Panel switching in LinkTree.onNodeLinkClicked() doesn't work

Hi folks,

I want to exchange panels when special nodes of my main navigation tree object are clicked

------------------------8<--------------------------------
public class Index extends AbstractPage {
	// constants

	private static String ID_MAIN_PANEL = "main_panel";
	private static String ID_NAVIGATION_TREE = "fbc_navigation_tree";
	
	// attributes
	
	private LinkTree myNavigationTree = null;
	protected Panel myMainPanel = null;
	
	// constructors

	public Index ( final PageParameters pParameters) {
		final EmptyPanel lEmptyPanel = new EmptyPanel ( ID_MAIN_PANEL);
		final MMCSystemPanel lMMCSystemPanel = new MMCSystemPanel ( ID_MAIN_PANEL, new MMCSystem ());
				 
		myMainPanel = lEmptyPanel;
		add ( myMainPanel);
		
		myNavigationTree = new LinkTree ( ID_NAVIGATION_TREE, getApp().getNavigationTreeModel ()) {
			@Override
			protected void onNodeLinkClicked ( Object pNode, BaseTree pTree, AjaxRequestTarget pTarget) {
				NavigationTreeNode lNode = (NavigationTreeNode) pNode;

				switch ( lNode.getType ()) {
					case PANEL:
						System.out.println ( "PANEL_NODE");
						Object lPayLoad = lNode.getPayLoad ();
						//MMCSystemPanel lPanel = new MMCSystemPanel ( ID_MAIN_PANEL, (MMCSystem) lPayLoad);
						setMainPanel ( lMMCSystemPanel);	
						break;

					case SUB_TREE_ROOT:
						setMainPanel ( lEmptyPanel);
						
						if ( pTree.getTreeState().isNodeExpanded ( pNode)) {
							pTree.getTreeState().collapseNode ( pNode);
						} else {
							pTree.getTreeState().expandNode ( pNode);
						}
						break;

					case DEAD:
						System.out.println ( "DEAD_NODE");
						break;
				}
			}
		};
		
		add ( myNavigationTree);    
		
		add ( new Link ( "swap") {
			private boolean myFlag = true;
			
			@Override
			public void onClick () {
				if ( myFlag) {
					setMainPanel ( lMMCSystemPanel);
				} else {
					setMainPanel ( lEmptyPanel);
				}
				
				myFlag = ! myFlag;
			}
		
		});
		
		myNavigationTree.getTreeState().expandAll ();
	}
	 

	// methods
	 
	public void setMainPanel ( Panel pPanel) {
		myMainPanel.replaceWith ( pPanel);
		myMainPanel = pPanel;
	}
------------------------>8-------------------------------- 

For testing I also added a link (id=swap) that should toggle between two panels when clicked.
While clicking the swap-link produces the expected result, clicking nodes of my tree doesn't switch the panel (but produces the output "PANEL_NODE" to console).
Any ideas?
I'm using Firefox 3.0.10, SUN Java(TM) SE Runtime Environment (build 1.6.0_10-b33), wicket 1.4-rc4 (also tested 1.4-rc2) on Linux

Thanks in advance.

Mit freundlichen Grueszen, / With kind regards,
 
i.A. Andreas Buergel
BUCYRUS (R)
Engineering Center
Automation
Longwall Division
Industriestr. 1, D-44534 Luenen
Tel: +49 (2306) 709 2509
Fax: +49 (2306) 709 1315 2509
mailto: andreas.buergel@de.bucyrus.com
http://www.bucyrus.com____________________________________________________________________________________________________________________
Bucyrus DBT Europe GmbH
Sitz der Gesellschaft: Luenen, Registergericht: Amtsgericht Dortmund, Handelsregister HRB 17120
Geschaeftsfuehrung: Luis de Leon (Sprecher), Dr. Ulrich Noll  Vorsitzender des Aufsichtsrates: Dr. Juergen W. Stadelhofer
____________________________________________________________________________________________________________________
Diese E-Mail enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen. Wenn Sie nicht der richtige Adressat sind oder 
diese E-Mail irrtuemlich erhalten haben, informieren Sie bitte unverzueglich den Absender und vernichten Sie diese E-Mail. Das 
unerlaubte Kopieren sowie die unbefugte Weitergabe dieser E-Mail sind nicht gestattet.

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient or have received this 
e-mail in error, please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or 
distribution of the material in this e-mail is strictly forbidden


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


Re: Panel switching in LinkTree.onNodeLinkClicked() doesn't work

Posted by "Andreas Bürgel (Bucyrus)" <an...@de.bucyrus.com>.


Andreas Bürgel (Bucyrus) wrote:
> 
> Im using a org.apache.wicket.extensions.markup.html.tree.Tree now instead
> of a LinkTree. This seems to work.
> Don't forget to call "setOutputMarkupId ( true)" for all panels before
> they get displayed.
> 

I forgot to say that had to add the panel to the AjaxRequestTarget to make
it really work: 

-----------------------------8<---------------------------------------------
protected void onNodeLinkClicked ( AjaxRequestTarget pTarget, TreeNode
pNode) {
    NavigationTreeNode lNode = (NavigationTreeNode) pNode;
    switch ( lNode.getType ()) {
    case PANEL:
        System.out.println ( "PANEL_NODE");
        Object lPayLoad = lNode.getPayLoad ();
        setMainPanel ( lMMCSystemPanel);	
						
        if ( null != pTarget) {
            pTarget.addComponent ( lMMCSystemPanel);
        }
        break;
----------------------------->8----------------------------------------------

Enough said on this issue, I hope.
-- 
View this message in context: http://www.nabble.com/Panel-switching-in-LinkTree.onNodeLinkClicked%28%29-doesn%27t-work-tp23708299p23738707.html
Sent from the Wicket - User 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: Panel switching in LinkTree.onNodeLinkClicked() doesn't work

Posted by "Andreas Bürgel (Bucyrus)" <an...@de.bucyrus.com>.
Im using a org.apache.wicket.extensions.markup.html.tree.Tree now instead of
a LinkTree. This seems to work.
Don't forget to call "setOutputMarkupId ( true)" for all panels before they
get displayed.
-- 
View this message in context: http://www.nabble.com/Panel-switching-in-LinkTree.onNodeLinkClicked%28%29-doesn%27t-work-tp23708299p23738359.html
Sent from the Wicket - User 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