[jboss-user] [JBoss Seam] - Creating components

cfthomas do-not-reply at jboss.com
Fri Oct 12 06:11:40 EDT 2007


Hi there!

I'm new to SEAM so maybe you can give me some hints:

I want to create a generic component (not a component as in SEAM but a component as in "reusable building block")

I have a nice JavaScript Table that features all nice things you can imagine. It's written completely in Javascript and support event-handlers.
So What you need to do is write your JavaScript code to setup the table and add event-handler that then call e.g. SEAM components via remoting.
That works fine but for my likings is too much reapeated code every time you want to display some tables.

I want to create a SEAM component that encapsulates the initial creation of the table and handles all the events (sorting, paging, ..).
The only thing you need to do is just configure it what entity/datasource it should use.

E.g.:

  | @Stateful
  | public TableBean extends Table
  | {
  |   int currentPage; // Remembers the current page
  |   String sortedColumn; // The name of column that is currently sorted or null
  |   String entityName; // Name of the entity to use (componentName or className)
  |   List<String> propertyNames; // Names of properties to display
  |   List<String> columnTitles; // Column Titles for the displayed columns
  | 
  |   // Returns the JavaScript neccessary to setup the table in the browser
  |   String create() {}
  | 
  |   // Returns a list of queried data
  |   List getData() {}
  | 
  |   // Sets the current page
  |   void pageTo(int newPage);
  | 
  |   // Sets the sortedColumn
  |   void sort(String column);
  | 
  |   void select(Integer id);
  | }
  | 
The idea behind is to somehow (is this even possible in SEAM?) create multisple instances and configure them:

  | <component name="customerTable">
  |   <type class="TableBean"/>
  |   <property name="entityName">acme.Customer</property>
  |   <property name="propertyNames">
  |     <list>
  |       <value>name</value>
  |       <value>email</value>
  |     </list>
  |    </property>
  |   <property name="columnTitles">
  |     <list>
  |        <value>Cust. Name</value>
  |        <value>Email-Address</value>
  |     </list>
  |    </property>
  | </component>
  | 
in that way I want to configure say an "articleTable", "companyTable" etc. etc. without writing any new java or javascript code.

please help me with that:

* How can I configure multiple "instances" of the same component/ejb

* Can conversations help me manage the state of such a component (currentPage, sortedColumn ..)


Thank you very much!

Thomas

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4094455#4094455

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4094455



More information about the jboss-user mailing list