0

problem when zul file have a same id with different zul file

asked 2010-01-30 21:07:29 +0800

ibsolution gravatar image ibsolution
468 1 1 6

hai,

how zk know a component that have a same name but diffrent zul file ?

first.zul
<? init class="com.samejava" />
<window id="firstzul" use="com.firstjava">
<combobox id="list"/>
</window>

second.zul
<? init class="com.samejava" />
<window id="secondzul" use="com.secondjava">
<combobox id="list"/>
</window>

i implement aftercompose using <?init> tag, but when i run this,

test1
if a open firstzul my combobox has a value, but when i open secondzul window without close firstzul window, my combobox does not have a value.

test2
if a open secondzul my combobox has a value, but when i open firstzul window without close secondzul window, my combobox does not have a value.

how can i get a combobox value, because combobox value always same. in my java file i just use getFellow("<component_name>"), and i build three java file, first java file for the init and the other to manage a different behavior from firstzul and secondzul


Note :
zk 3.6.3

TIA,

Andy Susanto

delete flag offensive retag edit

9 Replies

Sort by ยป oldest newest

answered 2010-01-31 07:55:13 +0800

ibsolution gravatar image ibsolution
468 1 1 6

hai,

need a feedback

link publish delete flag offensive edit

answered 2010-01-31 08:03:52 +0800

caclark gravatar image caclark
1753 2 5
http://clarktrips.intltwi...

You'll have to supply the code for your init classes. Window is an id container, so neither window's "list" component is known by the anyone outside of its parent window unless you've done something in the init class.

link publish delete flag offensive edit

answered 2010-01-31 08:56:33 +0800

ibsolution gravatar image ibsolution
468 1 1 6

updated 2010-01-31 09:04:03 +0800

hai,

menu.zul

<zk>
	<window title="Menu" id="testcase" border="normal" use="testing.TestingComponent">
                <menubar>
                    <menuitem label="first" onClick="testcase.callfirstzul()"/>
                    <menuitem label="second" onClick="testcase.callsecondzul()"/>
                </menubar>
                </window>
</zk>

first.zul
<?page title="new page title" contentType="text/html;charset=UTF-8"?>
<?init class="initzul.SetDefaultValue" ?>
<zk>
	<window title="First" border="normal" use="initzul.SetDefaultValue" closable="true">
		<textbox id="testing" />
	</window>
</zk>

second.zul

<?page title="new page title" contentType="text/html;charset=UTF-8"?>
<?init class="initzul.SetDefaultValue" ?>
<zk>
<window title="Second" border="normal" use="initzul.SetDefaultValue" closable="true">
<textbox id="testing" />
</window>
</zk>

java file

package initzul;

import java.util.Iterator;
import java.util.Map;

import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.ComponentNotFoundException;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.Page;
import org.zkoss.zk.ui.util.Initiator;
import org.zkoss.zul.Textbox;
import org.zkoss.zul.Window;

public class SetDefaultValue extends Window implements Initiator{

	/**
	 * 
	 */
	private static final long serialVersionUID = 2236908200220933372L;

	public void doAfterCompose(Page page) throws Exception {
		((Textbox)getComponent("testing")).setValue("same id"); 
	}

	public boolean doCatch(Throwable throwable) throws Exception {
		// TODO Auto-generated method stub
		return false;
	}

	public void doFinally() throws Exception {
		// TODO Auto-generated method stub
		
	}

	public void doInit(Page page, Map map) throws Exception {
		// TODO Auto-generated method stub
		
	}

    public Component getComponent(String compId)
    {
        Component comp = null;
        try
        {
            comp = getFellow(compId);
        }
        catch(ComponentNotFoundException e1)
        {
            for(Iterator iter = Executions.getCurrent().getDesktop().getComponents().iterator(); iter.hasNext();)
            {
                comp = (Component)iter.next();
                if(comp.getId().indexOf("z_") == -1 && comp.getId().equals(compId))
                    break;
                comp = null;
            }

        }
        return comp;
    }	
}

testing class

package testing;

import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.naming.Context;
import javax.naming.InitialContext;

import org.apache.tomcat.dbcp.dbcp.BasicDataSource;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zul.Window;
public class TestingComponent extends Window {

	/**
	 * 
	 */
	private static final long serialVersionUID = -1241658806203814897L;

	
    public void callfirstzul()
    {
        Window window = null;
        try
        {
            window = (Window)Executions.createComponents("../testing/first.zul", null, null);
            window.invalidate();
            window.doOverlapped();
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }
    
    public void callsecondzul()
    {
        Window window = null;
        try
        {
            window = (Window)Executions.createComponents("../testing/second.zul", null, null);
            window.invalidate();
            window.doOverlapped();
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }    
}

link publish delete flag offensive edit

answered 2010-01-31 18:44:08 +0800

ibsolution gravatar image ibsolution
468 1 1 6

hai,

i need a walkthorugh to solve this problem


Regards,

Andy Susanto

link publish delete flag offensive edit

answered 2010-02-01 00:52:25 +0800

ibsolution gravatar image ibsolution
468 1 1 6

hai,

need a response

Regards,

Andy Susanto

link publish delete flag offensive edit

answered 2010-02-01 03:09:28 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

updated 2010-02-01 03:11:47 +0800

Why have your two windows ( first.zul; second.zul ) not an unique ID?


For searching such problems
here is a helper class for showing the whole component tree in the console

/**
 * Helper class for showing the zkoss component tree in the console for a root
 * component.
 * 
 * Call it with ZkossComponentTreeUtil.getZulTree(aComponent)
 * 
 * @author bbruhns
 * 
 */
public class ZkossComponentTreeUtil {

	static public CharSequence getZulTree(Component component) {
		return new ZkossComponentTreeUtil().getZulTreeImpl(component);
	}

	private ZkossComponentTreeUtil() {
		super();
	}

	private CharSequence getZulTreeImpl(Component component) {
		return getZulTreeImpl(component, new StringBuilder(6000), -1);
	}

	@SuppressWarnings("unchecked")
	private StringBuilder getZulTreeImpl(Component component,
			StringBuilder result, int tiefe) {
		++tiefe;
		result.append(StringUtils.leftPad("", tiefe << 2) + "-> " + component
				+ "\n");
		if (component.getChildren() != null) {
			for (Iterator iterator = component.getChildren().iterator(); iterator
					.hasNext();) {
				getZulTreeImpl((Component) iterator.next(), result, tiefe);
			}
		}

		result.append(StringUtils.leftPad("", tiefe << 2) + "<- " + component
				+ "\n");
		return result;
	}
}

best
Stephan

link publish delete flag offensive edit

answered 2010-02-01 07:20:58 +0800

ibsolution gravatar image ibsolution
468 1 1 6

actually i am create a sales invoice and sales order form, that form has a same data. but when i try to use that. only one form that have a value.

i would like use can open any window, so he/she can use cascade.

i do not understand about your example. can give me a clear sample

regards,

Andy Susanto

link publish delete flag offensive edit

answered 2010-02-03 13:04:19 +0800

ibsolution gravatar image ibsolution
468 1 1 6

hai,

my problem for a while solved. i am using getComponent method from Path classes,

it that possible to zk team, enhanced getFellow method, that method check what window is actived

Regards,

Andy Susanto

link publish delete flag offensive edit

answered 2010-02-03 18:55:50 +0800

PeterKuo gravatar image PeterKuo
481 2

@ibsolution
If you can clearify the feature spec you want,
the use case, the benefit of it.
You may post it to feature request.

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2010-01-30 21:07:29 +0800

Seen: 694 times

Last updated: Feb 03 '10

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More