[JBoss Seam] - NPE in Param.validateConvertedValue
by pgmjsd
I've been getting null pointer exceptions with Seam 2.0.0.GA with a .page.xml file / application that used to work fine in 1.2.1.GA. The error happens when processing the restful parameters:
| 2008-01-23 14:44:57,532 [http-0.0.0.0-8080-1] ERROR SeamPhaseListener - uncaught exception
| java.lang.NullPointerException
| at org.jboss.seam.navigation.Param.validateConvertedValue(Param.java:246)
| at org.jboss.seam.navigation.Pages.convertAndValidateStringValuesInPageContext(Pages.java:743)
| at org.jboss.seam.navigation.Pages.postRestore(Pages.java:393)
|
This is the code in Param.java that fails:
| if (valueExpression!=null)
| {
| //TODO: note that this code is duplicated from ModelValidator!!
| ELContext elContext = facesContext.getELContext();
| InvalidValue[] invalidValues;
| try
| {
| invalidValues = Validators.instance().validate( valueExpression.toUnifiedValueExpression(), elContext, value );
| }
| catch (ELException ele)
| {
| Throwable cause = ele.getCause();
| if (cause==null) cause = ele;
| throw new ValidatorException( createMessage(cause), cause );
| }
|
| if ( invalidValues.length>0 ) // <== Boom! NPE
| {
| throw new ValidatorException( createMessage(invalidValues) );
| }
| }
|
I took a look at the code and saw that there is an array of 'invalid values' which is expected to be of zero length if there are no errors but in this case it's null. The strange thing is that there are other places in the application where restful parameters work just fine. The only thing I can think of is that in this case, the restful parameter is being used inside a facelets template (the parameter turns the top nav bar off).
Anyone see this before?
I suppose I could fix it by overriding the definition of Validators with my own, or perhaps patching Param.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4123857#4123857
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4123857
18 years, 3 months
[JBoss Seam] - Type Checking in Expression Language
by mykey
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
18 years, 3 months