hi everybody,,
I'm new into the forum and i'm french so i'm begging you to excuse my
english.
I have to create a panel which contains a ListView of a mixed entity object.
A little example:
public Person implements Serializable{
getName()
}
public Event implements Serializable{
getType()
}
public Mail implements Serializable{
getText()
}
These objects are generated by wsdl2java because my IHM layer communicate
with my business layer by web service. It's like that and I can't change the
architecture.
I would like to print something like that:
"There are 3 lines"
colomn "Name" -- colomn "value"
person1.getName() -- event1.getType()
person2.getName() -- mail2.getText()
person3.getName() -- event3.getType()
But every examples found are about somethings like that
ListView<Book> new Listview<Book>("id",listModel);
with Book is a persisted object from Hibernate.
My question is: Is it a good or bad practice to do that
MyPanel extends Panel{
@SpringBean
public TableService tableService
public MyPanel(String id){
super(id);
IModel<List<Line>> listModel = new AbstractReadOnlyModel(){
getObject(){ tableService.getLines();}
}
List<Line> lines = (List<Line>) listModel.getObject();
int current;
if(lines.size() > 2){
current = lines.size();
}else{
current = 0;
}
add(new Label("count", current);
add(new ListView("list", listModel){
populateItems(){
Item item = (Line) getModel();
add(new Label("name",item.getName());
add(new Label("value",item..getValue());
}
};);
}
}
public TableauServiceImpl implements TableauService{
public List<Line> getLines(){
List<Line> lines = new ArrayList<Line>();
Line line1 = new Line();
// person and event are retrieve by others services
line1.setName(person1.getName());
line1.setValue(event1.getType());
lines.add(line1);
line2.setName(person1.getName());
line2.setValue(mail1.gettext());
lines.add(line2);
return lines;
}
}
It's a stupid example but i have to do something like this. And i'm afraid
not to respect good practices presents here
(http://www.devproof.org/wicket_best_practice) and not understand something.
--
View this message in context:
http://apache-wicket.1842946.n4.nabble.com/Conception-question-about-mixed-entities-and-model-tp4551789p4551789.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]