[jboss-user] [JBoss Seam] - Type Checking in Expression Language

mykey do-not-reply at jboss.com
Sun Jan 27 09:36:22 EST 2008


I have to handle a list with students who are either inscribben or matriculated. To model this I used @Inheritance. Now I want to show all of them in a Table, but with different attributes - depending on the subclass. My idea was mask the attributes with the rendered attribute in the JSF. Unfortunately I don't know how to do this. I already searched the internet, but I found now solution. Can somebody here help me?

The JSF:

  |     <h:dataTable value="#{studentList}" var="stud" rendered="#{studentList.rowCount>0}" border="1">
  | 	    <h:column>
  | 	    	<f:facet name="header">Name</f:facet>
  | 	    	<s:link action="#{inscription.startEdit}" value="#{stud.givenName} #{stud.familyName}" />
  | 	    </h:column>
  | 	    <h:column>
  | 	    	<f:facet name="header">Loeschen</f:facet>
  | 	    	<s:link action="#{inscription.delete}" value="loeschen" />
  | 	    </h:column>
  | 	    <h:column>
  | 	    	<f:facet name="header">Prozent</f:facet>
  | 	    	<h:outputText value="#{stud.percentage}" />
  | 	    </h:column>
  | 	    <h:column>
  | 	    	<f:facet name="header">Perzentil</f:facet>
  | 	    	<h:outputText value="#{stud.percentil}" />
  | 	    </h:column>
  | 	    <h:column>
  | 	    	<f:facet name="header">Rang</f:facet>
  | 	    	<h:outputText value="#{stud.rank}" />
  | 	    </h:column>
  | 	    <h:column>
  | 	    	<f:facet name="header">Durchschnitt</f:facet>
  | 	    	<h:outputText value="#{stud.mean}" />
  | 	    </h:column>
  | 	    <h:column>
  | 	    	<f:facet name="header">Aequivalenz</f:facet>
  | 	    	<h:outputText value="#{stud.equivalence}" />
  | 	    </h:column>
  |     </h:dataTable>
  | 
The accessed attributes (e.g. stud.mean) are from "inscribben" (that was the class I started with) ---^

The Session-Bean:

  | @Stateless
  | @Name("inscription")
  | public class InscriptionAction implements InscriptionFacade {
  | 		
  | 	@Logger private Log log;
  | 	@PersistenceContext EntityManager em;
  | 	@DataModel private List<Student> studentList;;
  | 	
  | 	@In(required=false)
  | 	@Out(required=false) 
  | 	@DataModelSelection
  | 	private StudentInsc inscribben;
  | 	
  | 	@In(required=false)
  | 	@Out(required=false) 
  | 	private Representative representative;
  | 
  | 	@Factory("studentList")
  | 	public List<Student> getStudentList() {
  | 		studentList = (List<Student>) em.createQuery("from Student").getResultList();
  | 		return studentList;
  | 	}
  | 
  | 	public void setStudentList(List<Student> studentList) {
  | 		this.studentList = studentList;
  | 	}
  | ....
  | 

And the Entity Beans:

  | @Entity
  | @Inheritance(strategy = InheritanceType.SINGLE_TABLE)
  | public class Student implements Serializable {
  | 
  | 	@Id @GeneratedValue
  | 	protected long id;
  | .....
  | 

  | @Entity
  | @Name("inscribben")
  | public class StudentInsc extends Student {
  | 
  | 	@Length(max=30)	private String kindergarten;
  | 	
  | 	@NotNull	private boolean behavior;
  | 	@NotNull	private boolean utilization;
  | 	@NotNull	private boolean language;
  | 	@NotNull	private boolean materials;
  | 	
  | 	@Range(min=0, max=50)	private int percentage;
  | 	@Range(min=0, max=100)	private int percentil;
  | 	@Range(min=0, max=6)	private int rank;
  | 	@Range(min=0, max=20)	private int mean;
  | 	@Length(max=15) 		private String equivalence;	
  | ....
  | 

  | @Entity
  | @Name("matriculated")
  | public class StudentMat extends Student {
  | ....
  | 

Thanks

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

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



More information about the jboss-user mailing list