I tried to create a sample by using UiRenderer. But Showing null values as
result. And as the UiRenderer code implementation is generated I am not
even able to debug it. Following is the sample I tried.
Person.java
--------------------------------------------------------------------------------------------------------------------------
public class Person {
private String fname;
private String lname;
private String emailid;
private int age;
/**
* @return the fname
*/
public String getFname() {
return fname;
}
/**
* @param fname
* the fname to set
*/
public void setFname(String fname) {
this.fname = fname;
}
/**
* @return the lname
*/
public String getLname() {
return lname;
}
/**
* @param lname
* the lname to set
*/
public void setLname(String lname) {
this.lname = lname;
}
/**
* @return the emailid
*/
public String getEmailid() {
return emailid;
}
/**
* @param emailid
* the emailid to set
*/
public void setEmailid(String emailid) {
this.emailid = emailid;
}
/**
* @return the age
*/
public int getAge() {
return age;
}
/**
* @param age
* the age to set
*/
public void setAge(int age) {
this.age = age;
}
}
--------------------------------------------------------------------------------------------------------------------------
PersonCell.ui.xml
--------------------------------------------------------------------------------------------------------------------------
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'>
<ui:with field='person' type='com.sample.renderer.Person' />
<div>
First Name :
<span>
<ui:text from='{person.getFname}' />
</span>
<p>
Last Name :
<span>
<ui:text from='{person.getLname}' />
</span>
</p>
<p>
Email :
<span>
<ui:text from='{person.getEmailid}' />
</span>
</p>
</div>
</ui:UiBinder>
--------------------------------------------------------------------------------------------------------------------------
PersonCell.java
--------------------------------------------------------------------------------------------------------------------------
public class PersonCell extends AbstractCell<Person> {
interface MyUiRenderer extends UiRenderer {
void render(SafeHtmlBuilder sb, Person person);
}
private static MyUiRenderer renderer =
GWT.create(MyUiRenderer.class);
@Override
public void render(com.google.gwt.cell.client.Cell.Context context,
Person value, SafeHtmlBuilder sb) {
renderer.render(sb, value);
}
}
--------------------------------------------------------------------------------------------------------------------------
onModuleLoad implementation
--------------------------------------------------------------------------------------------------------------------------
PersonCell cell = new PersonCell();
CellList<Person> cellList = new CellList<Person>(cell);
List<Person> list = new ArrayList<Person>();
Person p = new Person();
p.setFname("Pranoti");
p.setLname("Patil");
p.setEmailid("[email protected]");
p.setAge(30);
list.add(p);
p = new Person();
p.setFname("Pandurang");
p.setLname("Patil");
p.setEmailid("[email protected]");
p.setAge(30);
list.add(p);
p = new Person();
p.setFname("Ravi");
p.setLname("Kumar");
p.setEmailid("[email protected]");
p.setAge(30);
list.add(p);
cellList.setRowCount(list.size(), true);
cellList.setRowData(list);
RootPanel.get().add(cellList);
--------------------------------------------------------------------------------------------------------------------------
output:
--------------------------------------------------------------------------------------------------------------------------
First Name : null
Last Name : null
Email : null
First Name : null
Last Name : null
Email : null
First Name : null
Last Name : null
Email : null
--------------------------------------------------------------------------------------------------------------------------
Any help would be much appriciated. I am not getting if I am
missing something. Even I tried the sample given on GWT documenntation
located at
refer<https://developers.google.com/web-toolkit/doc/latest/DevGuideUiBinder#Rendering_HTML_for_Cells>,
getting similar results.
When I tried to debug above code by applying break points inside
redner() method of PersonCell, to check if I get required object over
there, while it renders every cell. And I am able to see proper object is
getting passed over there. But When apply break point in any of the getter
of Person class, and try to see what value person object has. Then it is
surprising to see it has all null values. Need to understand if its bug in
GWT library or I am missing anything while using it.
Thanks,
-Pandurang Patil.
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-web-toolkit/-/6u1S-d5lPbIJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.