Reputation: 1
I have created an application which build a grid or a matrix of elements dinamycally. When I try to navigate to another page I get an error:
This is the code:
private HtmlInputText createCelda(String vValue, String vStyle,
String vTitle, String vId, boolean vscript, boolean isreadonly) {
// private Application application;
// FacesContext fc = FacesContext.getCurrentInstance();
// application = fc.getApplication();
// private HtmlInputText ccelda;
ccelda = new HtmlInputText();
ccelda = (HtmlInputText) application
.createComponent(HtmlInputText.COMPONENT_TYPE);
ValueExpression ve = application.getExpressionFactory()
.createValueExpression(fc.getELContext(), vValue, String.class);
// ValueExpression ve = application.getExpressionFactory()
// .createValueExpression(fc.getELContext(), vValue, Integer.class);
ccelda.setValueExpression("value", ve);
ccelda.setStyleClass(vStyle);
ccelda.setTitle(vTitle);
ccelda.setId(vId);
ccelda.setReadonly(isreadonly);
if (vscript != false) {
ccelda.setOnkeydown(";return checkGrid(event, this.id);");
ccelda.setOnchange(";return changeValue(this.id);");
ccelda.setOnclick("this.select()");
}
return ccelda;
}
CODE to create a row of cells with the data from the bean
public UIComponent createPanelPrincipal(int nx, int ny, UIComponent panel) {
panelCeldas = createPanel(nx, "nacionI");
for (int i = 1; i < nx + 1; i++) {
String snx = i > 9 ? String.valueOf(i) : "0" + String.valueOf(i);
ncelda = createCelda("#{myBean.totalI[" + (i - 1) + "]}",
celdaNacionIStyle, "I" + snx, "I" + snx, true, false);
panelCeldas.getChildren().add(ncelda);
}
panel.getChildren().add(panelCeldas);
return panel;
}
This code WORKS PERFECT in tomcat 6.0.18
but in Tomcat 5.0 I get the next error:
10-nov-2010 14:56:24 com.sun.faces.lifecycle.RenderResponsePhase execute
INFO: WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
sourceId=form_composition:I15[severity=(ERROR 2), summary=(form_composition:I15: An error occurred when processing your submitted information.), detail=(form_composition:I15: An error occurred when processing your submitted information.)]
The line which produce the error is:
ValueExpression ve = application.getExpressionFactory()
.createValueExpression(fc.getELContext(), vValue, String.class);
If I put just ccelda.setValue(myValue), works great, but I need to get the value from the bean, that the reason I use the ValueExpression.
I can't see a way to debug this. If anyone is interested I have a stand-alone project to see how it works.
Upvotes: 0
Views: 962
Reputation: 1
Thanks for your comment.
I have used ValueBinding and friends and the result is the same.
I don't know where exactly the error happens.
I have added a jsf lifecycle as you have in blogspot.
Every phase if fired until phase 6.
Here is it:
START PHASE RESTORE_VIEW 1
END PHASE RESTORE_VIEW 1
START PHASE APPLY_REQUEST_VALUES 2
END PHASE APPLY_REQUEST_VALUES 2
START PHASE PROCESS_VALIDATIONS 3
END PHASE PROCESS_VALIDATIONS 3
START PHASE UPDATE_MODEL_VALUES 4
END PHASE UPDATE_MODEL_VALUES 4
START PHASE RENDER_RESPONSE 6
20-nov-2010 20:00:01 com.sun.faces.lifecycle.RenderResponsePhase execute
INFO: WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
sourceId=main:I10[severity=(ERROR 2), summary=(java.lang.ClassCastException), detail=(java.lang.ClassCastException)]
END PHASE RENDER_RESPONSE 6
If you or anybody want to take a look this is the link to download: https://docs.google.com/leaf?id=0B5-kdDLa5NdMMDYxOGQ2MWMtMWMwNS00MDFlLTkxMWQtM2EzYmZkZDgyMTgy&hl=en
Take a look at Grid.java
Thanks
Updated:
Finally it works,
I have used valueBinding, curiosly I had used before, but I left the libraries for jsf1.2. Now I have eliminated this libraries from the lib's folder and it works. With the other code I had the posibility to specify the type of the value (String, Integer, etc..). Now with ValueBinding it take the value by default, in my case Integer. I don't know why. I suppose because Integer is the type of the bean.
Anyway, thanks
Upvotes: 0
Reputation: 1109865
Unified EL (ValueExpression
and consorts) was introduced in JSP 2.1 (note the "Since" note at the bottom of the introductory text in javadoc).
Tomcat 6.x is a Servlet 2.5/JSP 2.1 container, so it supports it.
Tomcat 5.0 is however a Servlet 2.3/JSP 1.2 container, so it doesn't support it. Your best bet is using the (as of JSF 1.2 deprecated) ValueBinding
and friends. Actually, for Servlet 2.3/JSP 1.2 you really have to write all your JSF code as at highest JSF version 1.1, not as 1.2.
Upvotes: 2