I am new to JSF as well as stack overflow, I want to hide and show the components according to the button click. If button clicked then component should be visible and next time it should be invisible and so on. I tried below program
My jsg page
<p:commandButton value="submit" action="#{exampleBean.hideOrShow}"
update=":test" />
<h:inputText value="#{exampleBean.hidden}"/>
<h:inputText value="#{exampleBean.i}"/>
<h:panelGroup layout="block" rendered="#{exampleBean.hidden}">
<div>
Hello,<h:inputText value="hi"/>
testing,<h:inputText />
addr:<h:inputText/>
</div>
</h:panelGroup>
</h:form>
and
My bean
public void hideOrShow(){
if (!hidden)
{
i++;
hidden=true;
}
else
{
i++;
hidden=false;
}
}
/**
* @return the hidden
*/
public boolean isHidden() {
return hidden;
}
/**
* @param hidden the hidden to set
*/
public void setHidden(boolean hidden) {
this.hidden = hidden;
}
/**
* @return the i
*/
public int getI() {
return i;
}
/**
* @param i the i to set
*/
public void setI(int i) {
this.i = i;
}
}
NOTE:for first two click it working properly then it is not working.
Thanks in Advance