0

Why is @Init not evaluated in parent classes?

asked 2015-01-21 15:16:45 +0800

thomasbecker gravatar image thomasbecker
1

Hi everybody,

I've got an abstract class where all my VMs inherit from. I could have an @Init annotated method in the abstract class, but ZK won't evaluate it. So I have to have this init method in every subclass:

@Init
@Override public void init()
{
    super.init();
}

I've read the docs on how to call an additional init() method in the parent class. But there seems to be no way to have the @Init method ONLY in the parent class, right? Why is that?

I'm happy to provide a patch which fixes this if there's no reason to not do it.

Cheers, Thomas

delete flag offensive retag edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2015-01-21 16:17:13 +0800

cyiannoulis gravatar image cyiannoulis
1201 10

I think the ZK guys assumed that in most cases you will always need an @init method in your view model to retrieve parameters and prepare data models. Anyway, i believe that a declaration like this is not a big thing:

@Init(superclass=true)
public void init() { }

Costas

link publish delete flag offensive edit
0

answered 2015-01-23 22:44:20 +0800

enferx gravatar image enferx
13 3

updated 2015-01-23 22:45:35 +0800

Hi Thomas. Yes, it's possible.

In your concrete viewmodel define the annotation at class level:

@Init(superclass = true)

public class ManageCitiesViewModel extends CrudViewModel<city>

Then in yout abstract class:

@Init

public void load()

It's working fine for me. If this is what you want please vote me. Regards!

link publish delete flag offensive 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
1 follower

RSS

Stats

Asked: 2015-01-21 15:16:45 +0800

Seen: 24 times

Last updated: Jan 23 '15

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