Display Data table on Click

Hi,

I am new to JSF and strugling to create a data table dynamicaly.

I created a Data table, which needs to be displayed only after I click on submit button. After button click data table should be displayed on the same page as submit button.

Please share your ideas.

Thanks,

[306 byte] By [gsrya] at [2007-11-26 22:49:30]
# 1
You can use the 'rendered' attribute of the datatable.
BalusCa at 2007-7-10 12:10:01 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Thanks for your response. Is there any where I can find the sample code for doing this. I am using RAD6.0Thanks
gsrya at 2007-7-10 12:10:01 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
<h:dataTable rendered="#{myBean.booleanValue}">
BalusCa at 2007-7-10 12:10:01 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

Data table is not being displayed after clicking submit button. I have added the rendered attribute to the data table. Please advise

Here is the code I have written:

ForgotPassword.jsp

<h:dataTable border="0" cellpadding="2" cellspacing="0"

columnClasses="columnClass1" headerClass="headerClass"

footerClass="footerClass" rowClasses="rowClass1"

styleClass="dataTable" id="table1" value="#{pc_ForgotPassword.secBean}" var="varsecBean" rendered="#{varsecBean.booleanValue}">

<h:column id="column2" >

<f:facet name="header">

<h:outputText styleClass="outputText" value="QuestionID:" id="text2"></h:outputText>

</f:facet>

<h:outputText id="text3" value="#{varsecBean.questionID}" styleClass="outputText" >

</h:outputText></h:column>

<h:column id="column3" >

<f:facet name="header">

<h:outputText styleClass="outputText" value="QuestionText:" id="text4"></h:outputText>

</f:facet>

<h:outputText id="text5" value="#{varsecBean.questionText}" styleClass="outputText" >

</h:outputText></h:column>

<h:column id="column4" >

<f:facet name="header">

<h:outputText styleClass="outputText" value="Answer:" id="text6"></h:outputText>

</f:facet>

<h:outputText id="text7" value="#{varsecBean.answer}" styleClass="outputText" >

</h:outputText></h:column>

</h:dataTable>

<h:form styleClass="form" id="form1">

<hx:commandExButton type="submit" value="Submit"

styleClass="commandExButton" id="button1" action="#{pc_ForgotPassword.doButton1Action}"></hx:commandExButton>

</h:form>

SecurityQuestionsBean.java

public class SecurityQuestionsBean {

private String questionID;

private String questionText;

private String answer;

public String getQuestionText() {

return questionText;

}

public void setQuestionText(String questionText) {

this.questionText = questionText;

}

public String getquestionID() {

return questionID;

}

public void setquestionID(String questionID) {

this.questionID = questionID;

}

public String getanswer() {

return answer;

}

public void setanswer(String answer) {

this.answer = answer;

}

}

ForgotPassword.java:

public String doButton1Action() {

SecurityQuestions sec = new SecurityQuestions();

sec.setquestionID("001");

sec.setQuestionText("What is your pet name");

sec.setanswer("Answer1");

return "";

}

gsrya at 2007-7-10 12:10:01 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5

The booleanValue should be set in the managed bean, not in the datamodel value.

On the other hand, if the datamodel is not populated yet before submitting the form, then you can use the following boolean expression:

<h:dataTable rendered="#{!empty pc_ForgotPassword.secBean}">

BalusCa at 2007-7-10 12:10:01 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...