0

How to access static member field of a class in zul without zscript

asked 2013-02-01 11:21:04 +0800

pmmendescsw gravatar image pmmendescsw
8 1

I need to access constants to load as value in a label (eg.) Can I do it with EL ?

delete flag offensive retag edit

Comments

Are yo using MVC or MVVM Architecture? and what issue you are getting to access static variables?

sjoshi ( 2013-02-01 11:23:09 +0800 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2013-02-02 17:31:06 +0800

jj gravatar image jj
638 3

I might be wrong, but I don't think you can do it with built-in EL, maybe some other supported EL (e.g. OGNL) can allow this. Alternatively, you can just create instance getters to return the static variable

link publish delete flag offensive edit
0

answered 2014-04-01 10:43:59 +0800

chillworld gravatar image chillworld flag of Belgium
5322 4 9
https://github.com/chillw...

bump bump bump

Have the same issue MVVM with version 6.5.3

zul :

@load("vm.GET_PAGING_SIZE")

vm try 1:

private static final int PAGING_ENTRY_SIZE = 15;

public static int getPAGING_ENTRY_SIZE() {
    return PAGING_ENTRY_SIZE;
}

vm try 2:

public static final int PAGING_ENTRY_SIZE = 15;

public static int getPAGING_ENTRY_SIZE() {
    return PAGING_ENTRY_SIZE;
}

It works when I remove the static from the getter. This is of course not how to implement it correct.

Greetz chill.

link publish delete flag offensive edit

Comments

just saw you had it already ... sorry for the confusion

cor3000 ( 2014-05-29 11:53:20 +0800 )edit

Indeed, but if you make a static var, you want o alter in a static way. Little overkill to instanciate the object to change a static var? Or doubling the method, a static and a non static one isn't also that nice, if you understand what I mean.

chillworld ( 2014-05-29 21:04:51 +0800 )edit

statics are somewhat unhandy in many ways, especially when it comes to testing, they are hard to mock. how about a single bean in the application scope or a singleton spring bean?

cor3000 ( 2014-05-30 03:54:52 +0800 )edit
Your answer
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
2 followers

RSS

Stats

Asked: 2013-02-01 11:21:04 +0800

Seen: 104 times

Last updated: Apr 01 '14

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