You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by myrz <my...@gmail.com> on 2012/04/12 15:06:40 UTC
[Conception] question about mixed entities and model
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: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: [Conception] question about mixed entities and model
Posted by myrz <my...@gmail.com>.
Ok thanks it was my idea too but I didn't know if it was right to do this.
Thank you very much
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Conception-question-about-mixed-entities-and-model-tp4551789p4554139.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: [Conception] question about mixed entities and model
Posted by Francois Meillet <fr...@gmail.com>.
This is just an idea
public class UserDetails {
public UserDetails( Person person, Event event, Mail mail ) {
// here you use the properties you need
this.firstName = person.getFirstName();
this.xxx = event.getXXX();
.....
}
}
And by the way you keep the bean population in you business layer.
François
Le 12 avr. 2012 à 17:33, myrz a écrit :
> Thanks François for your reply.
>
> But my real question is. "UserDetails" is it a bean that you created "by
> hand"?
> How do you populate it?
>
> Thanks again
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Conception-question-about-mixed-entities-and-model-tp4551789p4552250.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: [Conception] question about mixed entities and model
Posted by myrz <my...@gmail.com>.
Thanks François for your reply.
But my real question is. "UserDetails" is it a bean that you created "by
hand"?
How do you populate it?
Thanks again
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Conception-question-about-mixed-entities-and-model-tp4551789p4552250.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: [Conception] question about mixed entities and model
Posted by Francois Meillet <qq...@gmail.com>.
Hi,
using a fragment or a panel will help you
public class MyMixedEntitiesPane extends Panel {
public MyMixedEntitiesPanel(IModel<UserDetails> userDetails) {
myMixedEntitiesPanel.add( new Label("x", xxxx);
myMixedEntitiesPanel.add( new Label("y", yyyy);
myMixedEntitiesPanel.add( new Label("z", zzzz);
}
}
and you populate the table like this :
public void populateItem(final ListItem<UserDetails> item)
{
item.add(new MyMixedEntitiesPanel("id", item.getDefaultModel());
}
François
Le 12 avr. 2012 à 15:06, myrz a écrit :
> 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: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org