Creator Tip: Adding components to dynamically created table

I saw some query in the Sun Java Studio Creator forum about adding components dynamically to a Table component if the table itself is dynamically created. I've already blogged on how to dynamically create a Table component. Read about how to add a Button component to the dynamic table at

http://winstonprakash.com/articles/jsf/dynamic_table2

Comments:

Winston, this worked Great! I now have a dynamic grid being populated froma a set of database tables. One table defines the header and SQL, the second defines the fields. I am using the same page to do lookup grids for two of our apps and will expand it to be used throughout out app. I plan to add jasper reporting as optional output off the original query. I have a problem, when I add setSort(fieldnam) it makes the column sortable, but does not seem to work if you try to sort by more then one column. Help?

Posted by Joel Fradkin on June 01, 2006 at 04:45 AM PDT #

Great post, but i have a dude: You have one action method for each button. How can i have a method for all buttons?

Posted by Ismael Sanchez on June 15, 2006 at 06:38 PM PDT #

Ismael, only one action method is required for all the buttons in the rows of a particular column. But if you need buttons in more than one column, then more action methods are required.

Posted by guest on June 15, 2006 at 11:59 PM PDT #

Hi, this post is very helpful. Just wondering if I have checkbox in the table, how do I determine which rows have been checked when a button outside the table component is submitted? Also, how can I highlight even row if I create the table dynamically? I tried your other sample on other post to alternate row highlighting, and it works with normal table component, but not with dynamic table. I tried this binding: tableColumn1.setStyle(String.valueOf(getValue("#{page1.columnStyle}"))); and this is the method binded: public String getColumnStyle(){ TableRowDataProvider trdp = (TableRowDataProvider) getBean("currentRow"); RowKey rowKey = trdp.getTableRow(); System.out.println(rowKey); if ((Integer.parseInt(rowKey.getRowId()) % 2) == 0){ return " "; } else { return "background-color: #eeeeee"; } \*\*/ } Thanks in advance.

Posted by Sudiyanto on September 20, 2006 at 05:19 PM PDT #

Hi, this post is very helpful. Just wondering if I have checkbox in the table, how do I determine which rows have been checked when a button outside the table component is submitted? Also, how can I highlight even row if I create the table dynamically? I tried your other sample on other post to alternate row highlighting, and it works with normal table component, but not with dynamic table. I tried this binding:
tableColumn1.setStyle(String.valueOf(getValue("#{page1.columnStyle}")));

and this is the method binded:
    public String getColumnStyle(){
        TableRowDataProvider trdp = (TableRowDataProvider) getBean("currentRow");
        RowKey rowKey = trdp.getTableRow();
        System.out.println(rowKey);
        if ((Integer.parseInt(rowKey.getRowId()) % 2) == 0){
            return " ";
        }
        else {
            return "background-color: #eeeeee";
        }
    }
Thanks in advance.

Posted by Sudiyanto on September 20, 2006 at 05:25 PM PDT #

I have a (master)table getting data from DB table. Is it possible to add an (inner)table in a column of this (master)table and the (inner)table dynamically created getting data from a second DB table. Also the (inner)table is depended on each row of the (master)table ?

Posted by Kapsalis Nikos on September 28, 2006 at 02:35 AM PDT #

I have a (master)table getting data from DB table. Is it possible to add an (inner)table in a column of this (master)table and the (inner)table dynamically created getting data from a second DB table. Also the (inner)table is depended on each row of the (master)table ?

Posted by Kapsalis Nikos on September 28, 2006 at 02:35 AM PDT #

Hi, this post is very helpful. But pagination is not working. how to do that? thanks i advance,

Posted by Abdul ghani on June 06, 2007 at 05:06 PM PDT #

Hi, Winston, thanks for your work...I need to make work checkbox selection in dynamically created table, from a button created outside the table or from button in header.

Posted by Mohammed Rizwan on June 12, 2007 at 03:25 PM PDT #

Hello, Winston Prakash!! How to communicate with external database (for example MySQL) without making JNDI reference.... Using java class (for example DBConnection.java) and database connector (for example mysql-connector-5.01.jar)communication with database is successful... But how to bind MySQL database's table with JSF table component. Waiting here anxiously for your reply... Thanx

Posted by Waseem Kayani on July 27, 2007 at 10:22 PM PDT #

Hello Winston,
I am tired, Please give me some suggections.
I am using studio creator 2 update 1 and mysql.

I created a Dynamic table for Emp Names and Emp Skills, in that table for Emp Skills i put Text Feild.I am getting text feild in my table.

here is my doubt
I am trying to implement the functionality of editing table cells when clicked/doubleclicked on it. I am trying to make the cells editable(textboxes) only after clicking/double clicking them. It should display static text otherwise.
I am trying to do this one in Javascript onClick event.

Any sample code I can refer to.Help me.

Thanks in advance,
Jose

Posted by jose on August 21, 2007 at 04:35 PM PDT #

Hi Jose, unfortunately this kind of direct support is not there in Java Studio Creator components. However, the new woodstock components included in VWP (NB 6.0) has such support.

Posted by Winston Prakash on August 22, 2007 at 02:50 PM PDT #

Hello winston,

I am trying to get Text feild in my dynamic table in studio creator 2 update 1.

please look at the below link and tell me how to implement javascript in jsc 2 update 1.

http://iharder.sourceforge.net/current/misc/inlineeditor/index.html

Please tell me what are the changes i have to do in that havascript page.
i thing it may work, please help me to do this.

Regards,
Jose.p

Posted by jose on August 28, 2007 at 08:10 PM PDT #

Hi Prakash,

I am not sure whether this is the right place to post my requirement. Here is the requirement.

I have a table which has 3 columns (2 columns contain database data - one is a staticText component and the other is textfield component) and the 3rd column is a buttton(with value "Save"). Now when I click on the save button in one of the rows, That particular row's button's text should change to "Update" and that row's second column should change from textfield component to static text. Please let me know whether this is possible and how?

Thanks a lot,
Srinivas

Posted by Srinivas on November 16, 2007 at 02:32 AM PST #

I am developing a test engin with netbean 6.0. using visual web included with the ide.
I binded some labels to database columns that represent the question. I used the code clip

TableRowDataProvider.cursorNext(). It only retrieved my first row that come with page load, and second one when I click the button. There are more than two records in the database. How can i make it to retrieve everything (each every time I click the button)?
Here is my sample code:
public String button1_action() {// Next Row in DB Rowset
try {
boolean cursorNext = questionsDataProvider.cursorNext();\*/
} catch (Exception ex) {
throw new FacesException(ex);
}

return null;

Posted by Ogunfunminiyi Frankfurt on February 28, 2008 at 11:01 PM PST #

Hi Ogunfunminiyi, What I would suggest you is to create the List of objects of your questions from the database once in the session bean. In your pages access that list from the session bean, rather than retrieving the questions from the database for each click.

Posted by Winston Prakash on March 02, 2008 at 11:58 PM PST #

Hello Jose P., I would strongly recommend you to move Netbeans 6.0.1 and use the visual web. It comes wit state of the art Woodstock components which supports client side JavaScript rendering which would allow you to do stuff as in http://iharder.sourceforge.net/current/misc/inlineeditor/index.html

Posted by Winston Prakash on March 03, 2008 at 12:01 AM PST #

Post a Comment:
  • HTML Syntax: NOT allowed
Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today