wood burning stoves 2.0*
The moose likes JSF and the fly likes Add component on a button click Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSF
Bookmark "Add component on a button click" Watch "Add component on a button click" New topic
Author

Add component on a button click

Joe Jose
Ranch Hand

Joined: Jan 14, 2004
Posts: 125
Hi,

I have been trying to add componenets checkbox and an input text box since last week. I was using selectmany check box ,that didn't work out. Now when I went through the forum, I found that I can use selectBooleanCheckbox for dynamically adding. Now, when I press the button for the first time I got a checkbox and an input text. But when I press the button second time, nothing happens instead of adding one more checkbox and input text.

I am confused now. I am putting my code here, please anyone direct me from here ?

jsp:


bean:


More clearly, if I press the Add button two time, I need to get 2 checkboxes and input boxes.
Bauke gave me initial idea, but still am confused.
Please help me.

Thanks,
Joe.
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
I have suggested you to use DTO's instead.
http://www.coderanch.com/t/212251/JSF/java/selectManyCheckbox
Check my posting there at October 11, 2006 08:44 AM.
Joe Jose
Ranch Hand

Joined: Jan 14, 2004
Posts: 125
Hi,

I have tried with DTO. But the added values doesn't diplay in datatable.

What I am trying to do is, enter value through input text and display it in a datatable.

Here is my code :

jsp:
<h:commandButton id="addAdhocs" action="#{CreateQuoteBean.addAdhocs}"
value="Add" styleClass="focusButton" />

<h:dataTable value="#{CreateQuoteBean.taskDataList}">
<h:column>
<hutputText id ="tk" value="#{TaskSelected.taskData}" />
<h:message for="tk"/>
</h:column>
<h:column>
<hutputText id="td" value="#{TaskSelected.taskQt}" />
</h:column>
</h:dataTable> [/CODE]

bean:



I don't understand why the values not setting in output text. Please help me.

Thanks,
Joe.
Joe Jose
Ranch Hand

Joined: Jan 14, 2004
Posts: 125
I got it. I hadn't given var attribute in datatable tag.

Thank you very much Bauke.
 
GeeCON Prague 2014
 
subject: Add component on a button click