-
FEATURED COMPONENTS
First time here? Check out the FAQ!
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
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.
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;
}
Asked: 2013-03-11 10:40:03 +0800
Seen: 609 times
Last updated: Mar 11 '13