[jboss-user] [JBoss Seam] - Wannabe-Example needs help growing up

stephen.friedrich do-not-reply at jboss.com
Mon Sep 17 17:37:16 EDT 2007


Every now and then someone asked in the forum how to best implement a common UI for editing master data with Seam:
Multiple tabs/areas where each tab shows a list of items plus details for the item currently selected in the list.

Last time we talked about it was here:
http://www.jboss.com/index.html?module=bb&op=viewtopic&t=117825

I tried and created a first draft of the most basic example of them all - see screenshot: 
http://www.eekboom.com/jboss-seam-work/work.png
(Why can't I attach files here?)
A single area, an Employee entitiy with only first name and last name properties (plus id), an EmployeeHome component, single query defined in components.xml, list and "detail" form in xhtml file. (I started with the seampay example and changed/stripped it to arrive at this.)

Currently it is not (explicitly) using conversations in any way.
To run the example simply download here
http://www.eekboom.com/jboss-seam-work/seamwork.zip
unzip into <seam-1.2.1-root-dir>/examples, build with ant and open http://localhost:8080/jboss-seam-work

There is nothing really remarkable about the single xhtml file.
The table has an edit button in each row that refreshes the page with the employee id in a request parameter:

  |     <s:link view="/employees.xhtml">
  |         <f:param name="employeeId" value="#{employee.id}"/>
  | 		<img src="img/edit.gif" alt="#{employee.id}" border="0"/>
  |     </s:link>
  | 
A delete button in each row directly calls into the EntityHome:

  | 	<s:link action="#{employeeHome.remove}">
  | 		<f:param name="employeeId" value="#{employee.id}"/>
  | 		<img src="img/delete.gif" alt="#{employee.id}" border="0"/>
  | 	</s:link>
  | 
The f:param "outjects" the selected employee's id as a request parameter.
The request parameter is forwarded to the EmployeeHome by using a page parameter
(pages.xml):

  |    <page view-id="/employees.xhtml">
  |           <param name="employeeId" value="#{employeeHome.id}" converterId="javax.faces.Long" />
  |    </page>
  | 


Open issues / questions in the example

* Is it ok to "manually" add a newly created entity to the entity query's result list like this (in EmployeeHome):

  | 	public String persist() {
  | 		String outcome = super.persist();
  | 		employees.getResultList().add(getInstance());
  | 		return outcome;
  | 	}
  | 

* At first after deleting an employee the employee's details were still shown in the detail form (but editing/resubmitting the form caused an exception of course). I tried to get around this by overriding the remove method in EmployeeHome:

  | 	public String remove() {
  | 		String outcome = super.remove();
  | 		setId(null);
  | 		return outcome;
  | 	}
  | 
  After that the detail form was indeed empty after deleting an employee.
  Still when you delete an employee, then fill in data in the detail form (without first selecting another employee or clicking on "Create New Employee) and click on "Create" it still crashes with an exception. Any idea?

* Why do I need to add a newly created employee to the list myself, but a deleted employee is removed from the list automatically?

* Currently it seems that the whole list of employees is reloaded from DB each time I select another employee in the list (by clicking the edit button).
  How can I achieve this behaviour:
  - The list should only be reloaded when selecting the "area", i.e. when clicking on the "Employees" link in the header.
  - However when a single employee is selected that single employee  should be reloaded from DB prior to showing it in the details area. (To be sure to 
    start the edit using the most up-to-date data.) When the employee has already been deleted, then a message should be shown instead and it should be removed from the list.
  - Ideally when opening another employee "area" in a new browser tab (by ctrl-clicking (with firefox) on an edit button or the "Employees" header) then the new tab should act independently from the first (i.e. loading the employee list once, when opened and refreshing a single employee on each selection).

* In seampay the PaymentHome had a "@RequestParameter Long paymentId;" declaration. Is it really needed? Seems to be unused, but it's hard to tell because there's always so much going on behind the scene when using seam.

If somebody could help me understanding / fixing these issues I can write some more explanatory text plus enhance the example with one or two more entities, relations and details.

When it's done I can also update it to work with Seam 2.0.0 - for now I'd like to stick with 1.2.1, because that's the version our small app will go live with.


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

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



More information about the jboss-user mailing list