[Conception] question about mixed entities and model

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[Conception] question about mixed entities and model

myrz
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.



Reply | Threaded
Open this post in threaded view
|

Re: [Conception] question about mixed entities and model

Francois Meillet 3
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: [Conception] question about mixed entities and model

myrz
In reply to this post by myrz
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
Reply | Threaded
Open this post in threaded view
|

Re: [Conception] question about mixed entities and model

Francois Meillet
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: [hidden email]
> For additional commands, e-mail: [hidden email]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [Conception] question about mixed entities and model

myrz
Ok thanks it was my idea too but I didn't know if it was right to do this.

Thank you very much