PDA

View Full Version : How to display the enclosing beanmodel attribute in grid widget



shingocat
16 May 2012, 5:26 AM
Hi everyone,

Just like the following code, I have two javabeans , and the Address javabean is enclosed in the Company javabean. After adding Company to a ListStore, If I want display the Company in Grid of two columns´╝łName, Location), how to correctly show such information ? The Location's ColumnConfig of Grid
is what?? How to make the enclosing class show the attributes?

Thanks!




// The enclosing javabean
// The address javabean
package test.beanmodel;
import java.io.Serializable;


class Address implements Serializable{
private Integer addressId;
private String location;

public Address(){}


public Integer getAddressId(){
return addressId;
}
public void setAddressId(Integer addressId){
this.addressId = addressId;
}


public String getLocation(){
return location;
}
public void setLocation(String location){
this.location = location;
}
}


// The marker Address javabean
import com.extjs.gxt.ui.client.data.BeanModelMarker;
import com.extjs.gxt.ui.client.data.BeanModelMarker.BEAN;


@BEAN(test.beanmodel.Address.class)
public class AddressBeanModel implements BeanModelMarker {


}


// the nesting javabean
// the company javabean
package test.beanmodel;


import java.io.Serializable;


class Company implements Serializable{
private String companyName;
private Address address;

public Company(){
}

public String getCompanyName(){
return companyName;
}
public void setCompanyName(String companyName){
this.companyName = companyName;
}
public Address getAddress(){
return address;
}
public void setAddress(Address address){
this.address = address;
}
}
// the marker javabean of Company
import com.extjs.gxt.ui.client.data.BeanModelMarker;
import com.extjs.gxt.ui.client.data.BeanModelMarker.BEAN;


@BEAN(test.beanmodel.Company.class)
class CompanyBeanModel implements BeanModelMarker{
}