[jboss-user] [JBoss Seam] - Re: selectOneMenu - NullPointerException
siobhan.ernest
do-not-reply at jboss.com
Wed Nov 21 00:15:22 EST 2007
Hi all -
I actually scrapped this code and changed it to the following:
components.xml
<persistence:managed-persistence-context name="entityManager"
| auto-create="true"
| persistence-unit-jndi-name="java:/rte_trackerEntityManagerFactory"/>
plus a list seam-gen generated list bean:
@Name("uploadDefinitionList")
| public class UploadDefinitionList extends EntityQuery {
|
| private static final String[] RESTRICTIONS = {
| "lower(uploadDefinition.name) like concat(lower(#{uploadDefinitionList.uploadDefinition.name}),'%')",
| "lower(uploadDefinition.headers) like concat(lower(#{uploadDefinitionList.uploadDefinition.headers}),'%')",
| "lower(uploadDefinition.matchOn) like concat(lower(#{uploadDefinitionList.uploadDefinition.matchOn}),'%')",
| "lower(uploadDefinition.uploadType) like concat(lower(#{uploadDefinitionList.uploadDefinition.uploadType}),'%')",};
|
| private UploadDefinition uploadDefinition = new UploadDefinition();
|
| @Override
| public String getEjbql() {
| return "select uploadDefinition from UploadDefinition uploadDefinition";
| }
|
| @Override
| public Integer getMaxResults() {
| return 25;
| }
|
| public UploadDefinition getUploadDefinition() {
| return uploadDefinition;
| }
|
| @Override
| public List<String> getRestrictions() {
| return Arrays.asList(RESTRICTIONS);
| }
|
| }
The upload action:
public abstract class EntityUploadAction {
| @Logger
| Log log;
|
| @PersistenceContext
| protected EntityManager entityManager;
|
| @In
| protected FacesMessages facesMessages;
|
|
| <snip>
|
|
| protected UploadDefinition selectedUploadDefinition;
|
|
| <snip>
|
| public UploadDefinition getSelectedUploadDefinition() {
| return selectedUploadDefinition;
| }
|
| public void setSelectedUploadDefinition(UploadDefinition selectedUploadDefinition) {
| this.selectedUploadDefinition = selectedUploadDefinition;
| }
|
| <snip>
| }
The upload action is used more than once, so this is extended in other actions.
And finally, the .xhtml
<s:decorate id="selectedUploadDefinitionnDecoration" template="layout/edit.xhtml">
| <ui:define name="label">Upload Definition</ui:define>
| <h:selectOneMenu value="#{studentUploadService.selectedUploadDefinition}" required="true"
| id="selectedUploadDefinition">
| <s:selectItems value="#{uploadDefinitionList}" var="ud" label="#{ud.name}"
| noSelectionLabel="Please Select..."/>
| <s:convertEntity/>
| </h:selectOneMenu>
| </s:decorate>
It all works, and I am happy - just posting this for anyone who might be interested.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4106598#4106598
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4106598
More information about the jboss-user
mailing list