我正在尝试在我的 Web 应用程序中使用 JSF 复合组件,但我运行该页面并单击导航栏我有这个错误更新
我更改<m:link outcome="#{cc.attrs.caption}" value="#{cc.attrs.jsf}" />
为 <m:link outcome="#{cc.attrs.caption}" value="#{cc.attrs.jsf}" />
我在链接上收到此消息
V:此链接被禁用,因为导航案例无法匹配
XHTML
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:mnu="http://xmlns.jcp.org/jsf/composite/mnu">
<h:head>
<title>First Mobile JSF page</title>
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; minimum-scale=1.0; user-scalable=no; target-densityDpi=device-dpi"/>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css" />
<script src="http://code.jquery.com/jquery-1.9.0.min.js"></script>
<script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>
<style>
#box1 {
margin-left: 25%;
margin-top: 55%;
width: 50%;
border-style: solid;
}
</style>
</h:head>
<h:body>
<h:form>
<div data-role="page" home="home">
<div data-role="header">
<h1>Add Product</h1>
</div>
<div data-role="content">
<p>Dummy page add Product</p>
</div>
<div data-role="footer" data-postion="fixed">
<div data-role="navbar">
<ul>
<!-- <li><a href="/Info5059Case1/C1Control?jsf=V" data-ajax="false">Add Vendor</a> </li>
<li><a href="/Info5059Case1/C1Control?jsf=P" data-ajax="false">Add Product</a> </li>
<li><a href="/Info5059Case1/C1Control?jsf=O" data-ajax="false">Generator PO</a> </li>-->
<mnu:MenuItem caption="Add Vendor" jsf="V"/>
<mnu:MenuItem caption="Add Product" jsf="P"/>
<mnu:MenuItem caption="Add Product" jsf="O"/>
</ul>
</div>
</div>
</div>
</h:form>
</h:body>
</html>
复合组件
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:cc="http://xmlns.jcp.org/jsf/composite"
xmlns:m="http://xmlns.jcp.org/jsf/html">
<!-- INTERFACE -->
<cc:interface>
<cc:attribute name="caption" required="true"/>
<cc:attribute name="jsf" required="true"/>
</cc:interface>
<!-- IMPLEMENTATION -->
<cc:implementation>
<m:commandLink action="#{cc.attrs.jsf}" value="#{cc.attrs.caption}" />
</cc:implementation>
</html>
An Error Occurred:
javax.el.ELException: java.lang.IllegalArgumentException: Cannot convert V of type class java.lang.String to class javax.el.MethodExpression
- Stack Trace
javax.faces.el.EvaluationException: javax.el.ELException: java.lang.IllegalArgumentException: Cannot convert V of type class java.lang.String to class javax.el.MethodExpression
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:101)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
at java.lang.Thread.run(Thread.java:724)
Caused by: javax.el.ELException: java.lang.IllegalArgumentException: Cannot convert V of type class java.lang.String to class javax.el.MethodExpression
at com.sun.el.ExpressionFactoryImpl.coerceToType(ExpressionFactoryImpl.java:79)
at javax.el.ELContext.convertToType(ELContext.java:473)
at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:229)
at org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:50)
at com.sun.faces.facelets.el.ContextualCompositeValueExpression.getValue(ContextualCompositeValueExpression.java:158)
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
at com.sun.faces.facelets.tag.TagAttributeImpl$AttributeLookupMethodExpression.invoke(TagAttributeImpl.java:465)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)
... 35 more
Caused by: java.lang.IllegalArgumentException: Cannot convert V of type class java.lang.String to class javax.el.MethodExpression
at com.sun.el.lang.ELSupport.coerceToType(ELSupport.java:417)
at com.sun.el.ExpressionFactoryImpl.coerceToType(ExpressionFactoryImpl.java:77)
... 42 more
- Component Tree
<UIViewRoot id="j_id1" inView="true" locale="en_US" renderKitId="HTML_BASIC" rendered="true" transient="false" viewId="/AddProduct.xhtml"><html xmlns="http://www.w3.org/1999/xhtml"><UIOutput id="j_idt2" inView="true" rendered="true" transient="false"><title>First Mobile JSF page</title> <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; minimum-scale=1.0; user-scalable=no; target-densityDpi=device-dpi"/> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css"/> <script src="http://code.jquery.com/jquery-1.9.0.min.js"/> <script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"/> <style> #box1 { margin-left: 25%; margin-top: 55%; width: 50%; border-style: solid; } </style></UIOutput><UIOutput id="j_idt4" inView="true" rendered="true" transient="false"><HtmlForm enctype="application/x-www-form-urlencoded" id="j_idt5" inView="true" prependId="true" rendered="true" submitted="true" transient="false"><div data-role="page" home="home"> <div data-role="header"> <h1>Add Product</h1> </div> <div data-role="content"> <p>Dummy page add Product</p> <!--name<h:inputText id="userName" value="#{sampleViewModel.name}" size="5"/> <h:commandButton id="something" value="doSomething" action="#{sampleViewModel.doSomething}"/>--> <div id="box1"><HtmlOutputText escape="false" id="j_idt7" inView="true" rendered="true" transient="false"/></div> </div> <div data-role="footer" data-postion="fixed"> <div data-role="navbar"> <ul> <!-- <li><a href="/Info5059Case1/C1Control?jsf=V" data-ajax="false">Add Vendor</a> </li> <li><a href="/Info5059Case1/C1Control?jsf=P" data-ajax="false">Add Product</a> </li> <li><a href="/Info5059Case1/C1Control?jsf=O" data-ajax="false">Generator PO</a> </li>--><UINamingContainer id="j_idt12" inView="true" rendered="true" transient="false">javax.faces.component.COMPOSITE_FACET_NAME<UIPanel id="j_id6" inView="true" rendered="true" transient="false"><html xmlns="http://www.w3.org/1999/xhtml"> <!-- INTERFACE --><!-- IMPLEMENTATION --><HtmlCommandLink action="#{cc.attrs.jsf}" actionExpression="#{cc.attrs.jsf}" disabled="false" id="j_idt13" immediate="false" inView="true" rendered="true" transient="false"/></html></UIPanel></UINamingContainer><UINamingContainer id="j_idt14" inView="true" rendered="true" transient="false">javax.faces.component.COMPOSITE_FACET_NAME<UIPanel id="j_id6" inView="true" rendered="true" transient="false"><html xmlns="http://www.w3.org/1999/xhtml"> <!-- INTERFACE --><!-- IMPLEMENTATION --><HtmlCommandLink action="#{cc.attrs.jsf}" actionExpression="#{cc.attrs.jsf}" disabled="false" id="j_idt13" immediate="false" inView="true" rendered="true" transient="false"/></html></UIPanel></UINamingContainer><UINamingContainer id="j_idt15" inView="true" rendered="true" transient="false">javax.faces.component.COMPOSITE_FACET_NAME<UIPanel id="j_id6" inView="true" rendered="true" transient="false"><html xmlns="http://www.w3.org/1999/xhtml"> <!-- INTERFACE --><!-- IMPLEMENTATION --><HtmlCommandLink action="#{cc.attrs.jsf}" actionExpression="#{cc.attrs.jsf}" disabled="false" id="j_idt13" immediate="false" inView="true" rendered="true" transient="false"/></html></UIPanel></UINamingContainer></ul> </div> </div> </div></HtmlForm></UIOutput></html></UIViewRoot>
- Scoped Variables
Request Parameters
Name
Value
j_idt5 j_idt5
j_idt5:j_idt12:j_idt13 j_idt5:j_idt12:j_idt13
View Attributes
Name
Value
None
Request Attributes
Name
Value
None
Flash Attributes
Name
Value
None
Session Attributes
Name
Value
None
Application Attributes
Name
Value
csfcff [ ]