Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to create copy/delete buttons for Input Text in JSF  RSS feed

 
Mehr Aman
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to have a jsf form with an input text and two buttons, copy and delete. When the copy button is pressed, the input text along with the two buttons needs to be copied to allow the same functions(copy/delete) for the copied input text. When the delete button is pressed, the input text along with its two buttons needs to be deleted. Could anyone give me some hints on how to do that? Thanks.
 
Rajeev Ravindran
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont really understand the copy/delete functionality. if you are trying to add new components dynamically on clicking a button its very much possible using JSF.

create a panelgroup/panelgrid that holds your inputtext and button, when you click the copy button, get the id of panelgroup in backing bean and add new button and inputtext to the panelgroup.

Thanks,
 
Mehr Aman
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your response Rajeev. The copy function that I have in my mind is to copy the text inside the inputtext box as well. Example:
1- User displays the page that has an inputtext and the two buttons.
2- User enters the "TEXT1" on the inputtext and clicks the copy button.
3- A new inputtext with "TEXT1" with the two buttons will be added.
4- User changes "TEXT1" to "TEXT2" on the second inputtext and clicks copy.
5- We end up with three sets of inputtext and buttons. The first text is "TEXT1" and the other two shows "TEXT2".
6- The same applies to deleted button that should delete the approprite inputtext and its buttons.
Thanks.
 
Rajeev Ravindran
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Creating new inputtext is straight forward but a little bit of logic seems to be involved here for copying the content of one inputtext to another. Maybe you can define an list to hold the managedbean and tied it to the inputtext. you can create a new inputtext in the backing bean , get the last value of list and assing to the new inputtext..I may be wrong about the logic here but I dont think its really hard !

Thanks,
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!