Hi,
Is it possible to copy a pre existing grid on the page on a button press,my requirement is that a user presses a button and a copy of the current grid is creatd on the page along side the original grid.
Is there some way I can do that.?
Sure, but I want to make sure that I'm understanding the issue you're facing.
The grid gets its data from a collection type, usually an ArrayList. The ArrayList contains ordinary Java Beans - these are the objects that will provide you with your getters and setters. So when you said:
"Although creating a Arraylist at at run time is not a problem , the problem comes as there are no getters/setters for the newly created list."
I thought I should point out that the getters and setters aren't in the ArrayList object, they are in teh ebans that the ArrayList holds.
Is this the problem, or have I misunderstood you?
Thanks,Jim
Jim:
I could not understand clearly what you meant above.
Can u pls clarify a bit..??
Well, the ArrayList needs to be populated with Beans - the Grid will pull its columns from the getters and setters in the Bean, not in the ArrayList itself.
Then when you're building the grid, you will need to assign the attribute from the bean to a column. To do this use the setUnifiedValueExpression. This method is in the UnifiedColumn class, which is an ancestor of both HtmlColumn and Column.
setUnifiedValueExpression.
UnifiedColumn class,
HtmlColumn
Column.
Best,Jim
I have been able to create a grid on the page dynamically using Java code, the problem I am facing now is that, since the no. of grids is not fixed I need to create a new data source at run time.
Although creating a Arraylist at at run time is not a problem , the problem comes as there are no getters/setters for the newly created list.
I will be highly obliged if you could give me some suggestions or pointers for solviong this problem.
Another query that I had is:
In a simple grid that I created, even when I edit the values of a cell, the setter for the list is never called but the edited values are always available in the list. Please tell me how this works.
Regards,
Avijit
Avijit:
Sure. When you create a grid as a server-side object, its not really connected to the browser. So to get it to appear on the page, you have to connect it to a tag in teh JSP.
Since you're going to have several grids - and since the number of grids needs to change synamically, you're going to need a container object (like an h:panelGrid on your page. You must bind the panel to the server and then you can add your grids to the panel, as children.
When you add the panle to the page, be sire to use a binding attribute to connect it to a server-side attribute.