Illegal Model Reference

Hi! I have this problem, I get "Illegal Model Reference in this context for expression ' #{outboundBean.dataItem.briteId}'." everytime I try to submit.

The jsf page that araises this problem has a form that is supposed to edit data stored in a database. The message above appears for all form items.

The form looks like this:

<h:form id="details">

<h:panelGrid rendered="#{outboundBean.dataItem.meldingstype == 'CertificateIssuedNotification'}" columns="2" columnClasses="header, noStyle, noStyle">

<h:outputText value="#{bundle['Date']}" styleClass="header"/>

<h:outputText rendered="#{outboundBean.dataItem.status == 'Sent'}" value="#{outboundBean.dataItem.date}"/>

<h:inputText rendered="#{outboundBean.dataItem.status != 'Sent'}" value="#{outboundBean.dataItem.date}" id="date"/>

<h:outputText value="#{bundle['Id']}" styleClass="header"/>

<h:outputText rendered="#{outboundBean.dataItem.status == 'Sent'}" value="#{outboundBean.dataItem.localId}"/>

<h:inputText rendered="#{outboundBean.dataItem.status != 'Sent'}" value="#{outboundBean.dataItem.localId}" readonly="true" id="id"/>

<h:outputText value="#{bundle['BriteId']}" styleClass="header"/>

<h:outputText rendered="#{outboundBean.dataItem.status == 'Sent'}" value=" #{outboundBean.dataItem.briteId}"/>

<h:inputText rendered="#{outboundBean.dataItem.status != 'Sent'}" value=" #{outboundBean.dataItem.briteId}" id="briteId"/>

<h:outputText value="#{bundle['CompanyType']}" styleClass="header"/>

<h:outputText rendered="#{outboundBean.dataItem.status == 'Sent'}" value=" #{outboundBean.dataItem.companyType}"/>

<h:inputText rendered="#{outboundBean.dataItem.status != 'Sent'}" value=" #{outboundBean.dataItem.companyType}" id="companyType"/>

<h:outputText value="#{bundle['CompanyREID']}" styleClass="header"/>

<h:outputText rendered="#{outboundBean.dataItem.status == 'Sent'}" value=" #{outboundBean.dataItem.companyREID}"/>

<h:inputText rendered="#{outboundBean.dataItem.status != 'Sent'}" value=" #{outboundBean.dataItem.companyREID}" id="companyREID"/>

<h:outputText value="#{bundle['CompanyName']}" styleClass="header"/>

<h:outputText rendered="#{outboundBean.dataItem.status == 'Sent'}" value=" #{outboundBean.dataItem.companyName}"/>

<h:inputText rendered="#{outboundBean.dataItem.status != 'Sent'}" value=" #{outboundBean.dataItem.companyName}" id="companyName"/>

<h:outputText value="#{bundle['NewBRId']}" styleClass="header"/>

<h:outputText rendered="#{outboundBean.dataItem.status == 'Sent'}" value=" #{outboundBean.dataItem.newBRId}"/>

<h:inputText rendered="#{outboundBean.dataItem.status != 'Sent'}" value=" #{outboundBean.dataItem.newBRId}" id="newBRId"/>

<h:outputText value="#{bundle['OldBRId']}" styleClass="header"/>

<h:outputText rendered="#{outboundBean.dataItem.status == 'Sent'}" value=" #{outboundBean.dataItem.oldBRId}"/>

<h:inputText rendered="#{outboundBean.dataItem.status != 'Sent'}" value=" #{outboundBean.dataItem.oldBRId}" id="oldBRId"/>

<h:outputText value="#{bundle['CertificateDocRef']}" styleClass="header"/>

<h:outputText rendered="#{outboundBean.dataItem.status == 'Sent'}" value=" #{outboundBean.dataItem.certificateDocRef}"/>

<h:inputText rendered="#{outboundBean.dataItem.status != 'Sent'}" value=" #{outboundBean.dataItem.certificateDocRef}" id="certificateDocRef"/>

<h:commandButton rendered="#{outboundBean.dataItem.status != 'Sent'}" action="#{outboundBean.newCertificateIssuedNotification}" value="Register"/>

</h:panelGrid>

</h:form>

OutboundBean is the managed bean, dataItem is a reference to a datastorage class, and briteId etc. reffers to the getters and setters in this class.

The form gets filled out, so the getters works. But if I try to submit, the errormessages appears.

"Illegal Model Reference in this context for expression ' #{outboundBean.dataItem.briteId}'. Illegal Model Reference in this context for expression ' #{outboundBean.dataItem.oldBRId}'. Illegal Model Reference in this context for expression ' #{outboundBean.dataItem.newBRId}'. Illegal Model Reference in this context for expression ' #{outboundBean.dataItem.companyName}'. Illegal Model Reference in this context for expression ' #{outboundBean.dataItem.companyREID}'. Illegal Model Reference in this context for expression ' #{outboundBean.dataItem.certificateDocRef}'. Illegal Model Reference in this context for expression ' #{outboundBean.dataItem.companyType}'."

For some reason, "date" and "localId" gives no errormessage. All values in this form is String.

I use JSF 1.1, Servlet 2.4 and JSP 2.0, if this matters.

Somebody have an idea how I can solve this problem? I've tried google and searching this forum, without any luck.

[5070 byte] By [Helgetnthemana] at [2007-11-27 10:54:15]
# 1

Which JSF implementation and version?

What does your model bean class look like?

Your original post is practically illegible, you want to try to clean it up.

Also, you would benefit from using the displayValueOnly attribute of the Tomahawk inputText component. (It causes an input component to be rendered as an output component based on a flag.)

RaymondDeCampoa at 2007-7-29 11:49:10 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Okey, I can understand it might seem a bit illegible, I'll try to be a little more spesific. I'm new to JSF as you might understand. I can't post the whole managed bean because it's really to large. As I wrote in the last post, I'm using JavaServer Faces v. 1.1, I guess the apache implementation, though I'm running the application on a Bea Weblogic application server. I've also added the Apache myFaces - tomahawk-1.1.3 tag library to the project.

I've simplyfied the form, so it looks like this:

<h:form id="details">

<h:panelGrid rendered="#{outboundBean.dataItem.meldingstype == 'CertificateIssuedNotification'}" columns="2" columnClasses="header, noStyle, noStyle">

<h:outputText value="#{bundle['Date']}" styleClass="header"/>

<h:inputText readonly="#{outboundBean.dataItem.status == 'Sent'}" value="#{outboundBean.dataItem.date}" id="date"/>

<h:outputText value="#{bundle['Id']}" styleClass="header"/>

<h:inputText value="#{outboundBean.dataItem.localId}" readonly="true" id="id"/>

<h:outputText value="#{bundle['BriteId']}" styleClass="header"/>

<h:inputText readonly="#{outboundBean.dataItem.status == 'Sent'}" value=" #{outboundBean.dataItem.briteId}" id="briteId"/>

<h:outputText value="#{bundle['CompanyType']}" styleClass="header"/>

<h:inputText readonly="#{outboundBean.dataItem.status == 'Sent'}" value=" #{outboundBean.dataItem.companyType}" id="companyType"/>

<h:outputText value="#{bundle['CompanyREID']}" styleClass="header"/>

<h:inputText readonly="#{outboundBean.dataItem.status == 'Sent'}" value=" #{outboundBean.dataItem.companyREID}" id="companyREID"/>

<h:outputText value="#{bundle['CompanyName']}" styleClass="header"/>

<h:inputText readonly="#{outboundBean.dataItem.status == 'Sent'}" value=" #{outboundBean.dataItem.companyName}" id="companyName"/>

<h:outputText value="#{bundle['NewBRId']}" styleClass="header"/>

<h:inputText readonly="#{outboundBean.dataItem.status == 'Sent'}" value=" #{outboundBean.dataItem.newBRId}" id="newBRId"/>

<h:outputText value="#{bundle['OldBRId']}" styleClass="header"/>

<h:inputText readonly="#{outboundBean.dataItem.status == 'Sent'}" value=" #{outboundBean.dataItem.oldBRId}" id="oldBRId"/>

<h:outputText value="#{bundle['CertificateDocRef']}" styleClass="header"/>

<h:inputText readonly="#{outboundBean.dataItem.status == 'Sent'}" value=" #{outboundBean.dataItem.certificateDocRef}" id="certificateDocRef"/>

<h:commandButton rendered="#{outboundBean.dataItem.status != 'Sent'}" action="#{outboundBean.newCertificateIssuedNotification}" value="Register"/>

</h:panelGrid>

</h:form>

It might also be a useful to know that the same page has more than one form, and that all form's uses the same managed bean, "OutboundBean". It actually got three forms that usually are rendered when you enter the page. One for displaying/editing the dataItem's information, one for deleting the dataItem, and one for changing the dataItem's status field. This can only be done while the status isn't "Sent". If the status is "Sent", only one form is visible, though without the possibility to edit/submit information (only for viewing purposes).

Here is the dataItem class. The different constructors is for different message types. I only focus on one message type here.

import java.util.TimeZone;

import java.util.Calendar;

public class MessageData {

Calendar cal = Calendar.getInstance(TimeZone.getDefault());

String DATE_FORMAT = "dd.MM.yyyy";

java.text.SimpleDateFormat sdf =

new java.text.SimpleDateFormat(DATE_FORMAT);

//outbound messages nodes

private String date = sdf.format(cal.getTime()); // Shared

private String localId;

private String companyREID;

private String briteId;

private String companyType;

private String companyName;

private String newBRId;

private String oldBRId;

private String certificateDocRef;

private String brId;

private String oldCompanyREID;

private String oldCompanyName;

private String status;

private String meldingstype;

/**

* This is the constructor for a message in the form above

*/

public MessageData(String date, String localId, String briteId, String companyType,

String companyREID, String companyName, String newBRId,

String oldBRId, String certificateDocRef, String status, String messageType) {

setDate(date);

setLocalId(localId);

setBriteId(briteId);

setCompanyType(companyType);

setCompanyREID(companyREID);

setCompanyName(companyName);

setNewBRId(newBRId);

setOldBRId(oldBRId);

setCertificateDocRef(certificateDocRef);

setStatus(status);

setMeldingstype(messageType);

}

public MessageData(String date, String localId, String briteId, String companyType,

String oldCompanyREID, String companyREID, String companyName,

String oldBRId, String oldCompanyName, String brId, String status,

String meldingstype) {

setDate(date);

setLocalId(localId);

setBriteId(briteId);

setCompanyType(companyType);

setOldCompanyREID(oldCompanyREID);

setCompanyREID(companyREID);

setCompanyName(companyName);

setOldBRId(oldBRId);

setOldCompanyName(oldCompanyName);

setBrId(brId);

setStatus(status);

setMeldingstype(meldingstype);

}

public MessageData(String date, String localId, String briteId,

String companyREID, String companyName, String brId, String status, String messagetype) {

setDate(date);

setLocalId(localId);

setBriteId(briteId);

setCompanyREID(companyREID);

setCompanyName(companyName);

setBrId(brId);

setStatus(status);

setMeldingstype(messagetype);

}

public MessageData() {}

public String getNewBRId() {

return newBRId;

}

public String getLocalId() {

return localId;

}

public String getDate() {

return date;

}

public String getCompanyType() {

return companyType;

}

public String getCompanyREID() {

return companyREID;

}

public String getCompanyName() {

return companyName;

}

public String getCertificateDocRef() {

return certificateDocRef;

}

public String getBriteId() {

return briteId;

}

public void setBrId(String brId) {

this.brId = brId;

}

public void setNewBRId(String newBRId) {

this.newBRId = newBRId;

}

public void setLocalId(String localId) {

this.localId = localId;

}

public void setDate(String date) {

this.date = date;

}

public void setCompanyType(String companyType) {

this.companyType = companyType;

}

public void setCompanyREID(String companyREID) {

this.companyREID = companyREID;

}

public void setCompanyName(String companyName) {

this.companyName = companyName;

}

public void setCertificateDocRef(String certificateDocRef) {

this.certificateDocRef = certificateDocRef;

}

public void setBriteId(String briteId) {

this.briteId = briteId;

}

public String getBrId() {

return brId;

}

public void setOldBRId(String OldBRId) {

this.oldBRId = OldBRId;

}

public void setStatus(String status) {

this.status = status;

}

public void setMeldingstype(String meldingstype) {

this.meldingstype = meldingstype;

}

public void setOldCompanyREID(String oldCompanyREID) {

this.oldCompanyREID = oldCompanyREID;

}

public void setOldCompanyName(String oldCompanyName) {

this.oldCompanyName = oldCompanyName;

}

public String getOldBRId() {

return oldBRId;

}

public String getStatus() {

return status;

}

public String getMeldingstype() {

return meldingstype;

}

public String getOldCompanyREID() {

return oldCompanyREID;

}

public String getOldCompanyName() {

return oldCompanyName;

}

}

Data in this form comes from a List (List dataList = new ArrayList();) that is displayed in a Datatable in another page. The List contains objects of the MessageData class. When i click a "View/Edit" button on the row I want to view/edit, it puts the values of that row into the "dataItem" (MessageData dataItem) in the OutboundBean. In example, "outboundBean.dataItem.companyName" should use the get/setCompanyName in the MessageData class.

I've got a problem debugging this, because the method that should be called when I push the commandButton (outboundBean.newCertificateIssuedNotification) is never invoked. Instead I get the error message as I wrote in the last post. Exceptions is never thrown. I hope this was clearer, and that you don't need to see the whole OutboundBean class, because it is kinda large.

Helgetnthemana at 2007-7-29 11:49:10 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

First, you are using old versions of the implementation and Tomahawk, you may want to consider upgrading.

Second, are you beans configured as session or request scope? If they are request scope, try changing them to session. If that works, you will need to decide if they should be session scope or if you need to refactor them to make them work as request scoped.

RaymondDeCampoa at 2007-7-29 11:49:10 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

That might be the solution, I'll try doing it local, but I might have to wait for the IT-infrastructure department to do the upgrade in the repository.

Beans are already configured as session scope.

Helgetnthemana at 2007-7-29 11:49:10 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5

I need JEE 5 for running JSF 1.2. We use Weblogic Server 9.2 that's based on JEE 4, so I have to stick with JSF 1.1 a while longer. Any other suggestions? The whole idea is to edit data from a DataTable row. Any possibility to get a more accurate error message from the faces context? Kinda hard to debug when no exceptions are thrown.

Helgetnthemana at 2007-7-29 11:49:10 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6

I did a little Googling to discover where the error message originates from. Assuming you are using the Sun RI, this error corresponds to the constant com.sun.faces.util.Util.ILLEGAL_MODEL_REFERENCE_ID. I did not find any usages of that in the 1.2 RI, however the 1.1_02 version uses it in com.sun.faces.el.MixedELValueBinding.setValue(). In fact, that method always throws an exception with that error message.

So, I would find out exactly what version of the Sun RI you have and get the sources. Then maybe set a breakpoint at that method to try to discover what is going on.

RaymondDeCampoa at 2007-7-29 11:49:10 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...