Developed sample application - HiddenColumn.zip provides JSPX page with a table component, that allows to create new data for Employees entity. Five columns are available in the table - First name, Last name, Email, Hire date and Job Id. But along with data for those five columns, data for Salary column is stored into database as well. Value that is inserted into Salary column is retrieved from Resources.properties file. Now I will describe how actually data is inserted into a column, that is not available in af:table component.
First step is to use the same technique, which I have successfully used in my previous samples - to include managed bean method call into let's say ReadOnly property of any column available in the table. In developed sample application, I have included #{valueHolder.readOnly} into ReadOnly property of First name column. This technique allows to invoke managed bean method, when each row of af:table component is rendered. Managed bean method code:
Developed method always return false value, it is because we always want to have editable column and are using this method for other purpose. Method is used to set Salary value #{row.Salary} for newly created row. Row is determined as a newly created using #{row.EmployeeId}. If DBSequence value is negative this means that row is newly created and we set value for #{row.Salary}.
Let's say we create new row and provide values for all columns:
When Save button is pressed, new row is inserted into database. Value for Salary column is inserted as well:
When running sample application, don't forget to add adf-faces-impl.jar and jsf-impl.jar to application's WEB-INF\lib directory.
No comments:
Post a Comment