0

zk button onclick event

asked 2013-03-11 10:40:03 +0800

shashir gravatar image shashir
3 2

updated 2013-03-11 12:30:49 +0800

sjoshi gravatar image sjoshi flag of India
3493 1 8
http://zkframeworkhint.bl...

Hi guys ,

i am trying to make a button visible when i click on another button.

<div id="div" visible="false" width="100%">
            <hlayout width="100%">
                <hlayout>
                    <button id="backButton" label="Back" mold="trendy" visible = "false" autodisable="self" 
                        onClick="@command('goBack')">
                    </button>
                    <label>Page No</label>
                    <intbox id="pageSize" value="1"  readonly="true" ></intbox>
                    <button id="nextLinkButton" label="Next" type="button" mold="trendy" autodisable="self"
                        onClick="@command('goNext')">
                    </button> 

                </hlayout>
            </hlayout>
        </div>

in the java file:

it does

@Wire
private Button backButton;

go next(){

backButton.setVisible(true);

}

but when i do i am getting a null pointer exception, please help me on this issue

delete flag offensive retag edit

2 Answers

Sort by ยป oldest newest most voted
3

answered 2013-03-11 12:35:18 +0800

sjoshi gravatar image sjoshi flag of India
3493 1 8
http://zkframeworkhint.bl...

Which Architecture you are using MVC or MVVM if MVC then no need to set visible="false" if you will do buttonID.setVisibility("false"); it will not visible and If you are using MVVM architecture then you have to use variable in visible attribute something like this visible="@load("vm.myVisibility") you have to change it dynamically by Java code and NotifyChange in Java Code.

link publish delete flag offensive edit
2

answered 2013-03-11 13:21:40 +0800

hswain gravatar image hswain flag of India
1763 3 10
http://corejavaexample.bl...

In your ZUL

<div id="div" visible="true" width="100%">
        <hlayout width="100%">
            <hlayout>
                <button id="backButton" label="Back" mold="trendy" visible="@load(vm.myVisibility)" autodisable="self" 
                    onClick="@command('goBack')">
                </button>
                <label>Page No</label>
                <intbox id="pageSize" value="1"  readonly="true" ></intbox>
                <button id="nextLinkButton" label="Next" type="button" mold="trendy" autodisable="self"
                    onClick="@command('goNext')">
                </button> 

            </hlayout>
        </hlayout>
     </div>

add code inside java class

Boolean myVisibility;
public Boolean getMyVisibility() {
    return myVisibility;
}

public void setMyVisibility(Boolean myVisibility) {
    this.myVisibility = myVisibility;
}

@NotifyChange("myVisibility")
    @Command
    public void goNext(@ContextParam(ContextType.VIEW) Component view) {
        myVisibility=true;
    }
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
2 followers

RSS

Stats

Asked: 2013-03-11 10:40:03 +0800

Seen: 609 times

Last updated: Mar 11 '13

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