Advice: Adding dynamically created button components to a table
I am attempting to add a number of dynamically created buttons to a table. The table is bound to a DataProvider and is pulling information from my Database. I'm wanting to add the buttons into the table as a new column, but I'm unsure how I should approach this.
Is there a way to either bind the buttons to a column in the table? Should I be using something else other than the standard Table Component?
Does anyone have any suggestions or experience with something like this?
Thanks
# 1
Hi!Did You read following: http://blogs.sun.com/winston/entry/creating_dynamic_table http://blogs.sun.com/winston/entry/dynamic_button_tableThanks,Roman.
# 2
No I haven't, but I'll check them out. Thanks :)
# 3
Thank you Roman for those links, they are excellent and that site has a lot of really great articles.
Although you answered my question perfectly, I unfortunately am attempting something more complicated than I described, and none of the articles I've read have answered my problem.
I'm wanting to add multiple buttons/items/whatever into a column in a table. Each row may have 0 or More buttons in this column. To do this I'm assuming I will need to be able to individually access specific cells within the table.
Winston Prakash's website had articles talking about dynamic tables and creating buttons within that dynamic table, but he is only using one button and that button, not a dynamic number of buttons.
Does anyone have any suggestions for how to approach this?
Thanks
Jesse
# 4
> I'm wanting to add multiple buttons/items/whatever
> into a column in a table. Each row may have 0 or
> More buttons in this column. To do this I'm assuming
> I will need to be able to individually access
> specific cells within the table.
> (...)
> Does anyone have any suggestions for how to approach
> this?
It's quite simple - right click table in designer and choose "Table Layout ...", then set column "Component Type" to "Group Panel". After that you can add other components like buttons, hyperlinks, etc to group panel simply by dragging and dropping them in the Outline Window.
regards
Grzegorz
# 5
Hey Grzegorz,
Thanks for the tip, I see what you're saying but I don't think it solves my particular problem. Creating a group panel which contains buttons will allow me to create the same buttons for each row.
What I'm attempting to do is add different sets of buttons for each row in the table. I'm starting to realize that this may not be a good way to do this but I'm kind of wanting to find an answer to this.
I'll give a better example of what I'm trying to attempt:
RadioButtonsnameButtons
OAllNew|Profile AllNew 1||Profile AllNew 2|
OkDude|Profile kDude 1|
ObrandNew|Profile brandNew 1||Profile brandNew 2||Profile brandNew 3|
So each row might have a couple of buttons relating to the user in that row. I already have the buttons generated and they work fine, I just need to place them inside the table.
Any more suggestions? They've been really good so far :)
Thanks
Jesse
# 6
> Creating a group panel which contains buttons will
> allow me to create the same buttons for each
> row.
> (...)
> What I'm attempting to do is add different sets of
> buttons for each row in the table.
You could set rendered property - you will have same buttons for each row but some of them will not be displayed.
First create methods in your page bean, one for each button that you have in table. Code should look like this:
public boolean isButton1Displayed() {
// determine whether to display button1. for example if value in
// column COLUMN_NAME is "VALUE" then button will be displayed
String value = (String)getValue("#{currentRow.value['COLUMN_NAME']}");
return "VALUE".equals(value);
}
Now go to designer and bind button1 rendered property to PageName.button1Displayed.
Repeat this steps for each button.
regards
Grzegorz
# 7
Hey Grzegorz,
Thanks again for the reply. I don't know if this idea works for dynamically created buttons, but it probably can be tooled to work that way.
For now I think I'm going to do it differently because it's too difficult to get it working the way I originally wanted. But I used your ideas to produce a similar solution so it was a lot of help in the end.
Thanks for all the help, you guys have brought up a lot of interesting ideas.
Jesse