tag files and ajax4jsf
pappy Mar 20, 2007 1:57 PMHello,
I'm back again with this issue: in few words when I call a method with ajax4jsf from a tag file, the server logs the error "Target Unreachable, identifier 'value' resolved to null" and the browser displays "internal server error".
I tested with the following
SJSAS-9.0.1: http://java.sun.com/javaee/downloads/index.jsp
GLASSFISH-V1_UR1-P01-B02: https://glassfish.dev.java.net/downloads/v1_ur1-p01-b02.html
GLASSFISH-V1_UR1-B14: https://glassfish.dev.java.net/downloads/v1_ur1-b14.html
For each of the above I tested with the original JSF, then with JSF-RI-2.1_03 and then with JSF-RI-2.1_04 but got the same result.
I suspect is not a JSF related issue since the JSF command defined in the file tag works...
Could somebody tell me what if I'm doing wrong? Is there any AJAX alternative to the code below?
Here is what I'm doing
WEB-INF/tags/t.tag
<%@ tag display-name="t" isELIgnored="false" body-content="empty"%> <%@ attribute name="value" required="true" deferredValue="true" deferredValueType="samples.Bean"%> <%@ taglib prefix="a" uri="https://ajax4jsf.dev.java.net/ajax"%> <%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%> <%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%> <h:panelGrid id="grid" columns="8" border="1" columnClasses="display"> <h:outputText value="#{value.value}" /> <h:outputText value="#{value.editable ? 'T' : 'F'}" /> <!-- This works --> <h:commandLink value="TE" action="#{value.toggleEdit}" /> <!-- This doesn't work --> <a:commandLink value="FF" action="#{value.toggleEdit}"/> </h:panelGrid>
samples/Bean.java
package samples; import java.util.Formatter; import java.util.logging.Logger; @SuppressWarnings( "nls" ) public class Bean { private final String id = IdGen.next(); private boolean editable; private String value = "this is my value..."; public Bean() { } public Bean( String value ) { setValue( value ); } static Bean valueOf( String value ) { return new Bean( value ); } public String getId() { return id; } public boolean isEditable() { return editable; } public void setEditable( boolean editable ) { this.editable = editable; } public String getValue() { return this.value; } public void setValue( String value ) { this.value = value; } @Override public String toString() { return getId() + ": " + getValue(); } public String toggleEdit() { setEditable( !isEditable() ); return null; } }
... and here is the tag invocation
<a:form> <q:t value="#{b1}"/> <q:t value="#{b2}"/> </a:form>
The exception is
javax.el.PropertyNotFoundException: Target Unreachable, identifier 'value' resolved to null at com.sun.el.parser.AstValue.getTarget(AstValue.java:66) at com.sun.el.parser.AstValue.invoke(AstValue.java:147) at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:283) at com.sun.faces.application.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethod ExpressionAdapter.java:77) at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:96) at javax.faces.component.UICommand.broadcast(UICommand.java:383) at org.ajax4jsf.framework.ajax.AjaxActionComponent.broadcast(AjaxActionComponent.java:47) at org.ajax4jsf.framework.ajax.AjaxViewRoot.processEvents(AjaxViewRoot.java:180) at org.ajax4jsf.framework.ajax.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:158) at org.ajax4jsf.framework.ajax.AjaxViewRoot.processApplication(AjaxViewRoot.java:329) at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97) at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:244) at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:113) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244) at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.jav a:397) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.j ava:303) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:184) at org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:96) at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:220) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.j ava:216) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:184) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:276) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:536) at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:24 0) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:179) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566) at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:73) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:182) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566) at com.sun.enterprise.web.VirtualServerPipeline.invoke(VirtualServerPipeline.java:120) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:939) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:137) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:536) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:939) at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:239) at com.sun.enterprise.web.connector.grizzly.ProcessorTask.invokeAdapter(ProcessorTask.java:6 67) at com.sun.enterprise.web.connector.grizzly.ProcessorTask.processNonBlocked(ProcessorTask.ja va:574) at com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:844) at com.sun.enterprise.web.connector.grizzly.ReadTask.executeProcessorTask(ReadTask.java:287) at com.sun.enterprise.web.connector.grizzly.ReadTask.doTask(ReadTask.java:212) at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:252) at com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:75)
Doing some debugging I noticed that the parameter
varMapping
used for the MethodExpressionImpl instantiation is null when clicked on
<a:commandLink/>and not null when clicked on
<h:commandLink/>
Having varMapper null, ELcontext is not able to solve the variable...
Thank you
--
pappy