Databinding.
I am using Hibernate for the DataProvider say for example 'Person' object
//////////////////////
Person( ){
String name;
String address;
Integer telephone'
Collection Cars;
...
////////////////////
Theoritically, i can display all the particulars of a Person object (name, address and telephone) in a datatable and binding to the column.
But now my Collection 'Cars' is another object type.
JSC bind the whole object to the column....
/////////////////
Car(){
String carName;
String carNumber;
..
/////////////////////////
How can i do the binding so that the column display the carName?
DK.
[718 byte] By [
Deepakarun] at [2007-11-26 9:34:37]

# 1
Instead of binding directly to Hibernate, in Creator 2, use an ObjectListDataProvider.
A Tutorial has just been published on using Hibernate with Creator:
http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/hib ernate.html
See code sample3 where the hibernate object is wrapped with
a TripDataProvider (extends ObjectListDataProvider)
The Table component is bound to the TripDataProvider and not Hibernate.
I suggest to try out the tutorial .
Feel free to give feedback, ask questions
John
jawbe at 2007-7-7 0:24:04 >

# 2
Hi John,
I am using ObjectListDataProvider only. I am also binding it to the table like this in the jsp...
text="#{currentRow.value['userGroupCode']}" ////Fine here////
My question is suppose I have another Object along with Usergroup Object say role how do I access from jsp.
I tried like this...
text="#{currentRow.value['role.getRoleName()']}"
Obviously this thing failed.
I am posting the POJO for the idea...
public class Usergroup {
/** Creates a new instance of Usergroup */
public Usergroup() {
}
/**
* Holds value of property userGroupCode.
*/
private String userGroupCode;
/**
* Getter for property userGroupCode.
* @return Value of property userGroupCode.
*/
public String getUserGroupCode() {
return this.userGroupCode;
}
/**
* Setter for property userGroupCode.
* @param userGroupCode New value of property userGroupCode.
*/
public void setUserGroupCode(String userGroupCode) {
this.userGroupCode = userGroupCode;
}
/**
* Holds value of property role.
*/
private Userroles role;
/**
* Getter for property role.
* @return Value of property role.
*/
public Userroles getRole() {
return this.role;
}
/**
* Setter for property role.
* @param role New value of property role.
*/
public void setRole(Userroles role) {
this.role = role;
}
}
# 3
For binding the rolename,
> text="#{currentRow.value['role.getRoleName()']}"
methods aren't supported in the Expression Language
instead, you might try this:
In your bean, declare a String property roleName
Then, in the prerender() method of your bean
// presuming getRoleName is supported for object role.
this.setRoleName(role.getRoleName()) ;
your binding would then look like
text="#{currentRow.value['roleName']}"
jawbe at 2007-7-7 0:24:04 >

# 4
The best solution is to try out the tutorial http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/hib ernate.htmlJohn
jawbe at 2007-7-7 0:24:04 >

# 5
John,
I am able to get the Role Object's values and set it to Jsp by having similar variable in the class(POJO) it is holding and then I iterate it to set the value.
But I want it to access directly the Role Object from the jsp page I am calling.....Is it possible?
thanks
DK
# 6
Alternatively, you could create an array property of type POJO then
create a binding expression
e.g.
in Page1.java
int roleCols = 5;
Role[] aRole = new Role[roleCols];
for (int i=0; i< roleCols; i++) {
aRole = getRoleName(role);
...
The binding expression could be
//For a Table component where the Table has 5 columns
#{currentRow.aRole}
If you're binding to StaticTexts
#{currentRow.aRole.rowProp1}
#{currentRow.aRole.rowProp2}
#{currentRow.aRole.rowProp3}
...
John
jawbe at 2007-7-7 0:24:04 >
