0

using constant value from class directly in zhtml

asked 2011-06-15 02:51:49 +0800

Vardhini gravatar image Vardhini
3

Hi,

I have a java file which has constant declaration.
Can i get the constant directly in zhtml using EL .

In older versions we get them from in the zscript and use them in zhtml.

<zscript>Tab_create = com.vzbi.Iamconstants.Tab_Create</zscript>


we use it as ${Tab_create}

Is there a way to access that Iamconstants.Tab_Create directly in zhtml.

delete flag offensive retag edit

1 Reply

Sort by ยป oldest newest

answered 2011-06-15 05:58:47 +0800

benbai gravatar image benbai
2228 6
http://www.zkoss.org

do you mean access constant without zscript?
try composer

assume we have 2 java beans as follows

test.constant.TestConstant

package test.constant;

public class TestConstant {
	public static String consStr = "the constant value";
}

and

test.composer.TestComposer

package test.composer;

import org.zkoss.zk.ui.util.GenericComposer;

public class TestComposer extends GenericComposer {

	public String getConstant() {
		return test.constant.TestConstant.consStr;
	}
}

then we can get constant value by TestComposer in zul file as follows:

<zk>
	<window id="win" title="test win" border="normal" apply="test.composer.TestComposer"> 
		<textbox value="${win$composer.constant}" /> 
	</window> 
</zk>

ben

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: 2011-06-15 02:51:49 +0800

Seen: 359 times

Last updated: Jun 15 '11

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