我在JSF项目中使用Passthrough元素,并且需要执行以下操作:
<h:commandLink action="#{myBean.acao()}" value="click me">
<f:setPropertyActionListener target="#{myBean.object}" value="#{localObject}"/>
</h:commandLink>
Run Code Online (Sandbox Code Playgroud)
但是使用Passthrough元素可以更好地控制前端,例如尝试以下操作:
<a href="#" jsf:action="#{myBean.acao()}">click me
<f:setPropertyActionListener target="#{myBean.object}" value="#{localObject}"/>
</a>
Run Code Online (Sandbox Code Playgroud)
但显然这不起作用,我收到以下错误消息:
<f:setPropertyActionListener> Parent is not of type ActionSource, type is: com.sun.faces.component.PassthroughElement
Run Code Online (Sandbox Code Playgroud)
有谁知道我该怎么解决?
我不明白为什么这段代码工作正常:
<h:link value="Login" rendered="#{sessionBean.userInSessionBean == null}" />
Run Code Online (Sandbox Code Playgroud)
而这段代码不起作用:
<a jsf:rendered="#{sessionBean.userInSessionBean == null}">Login</a>
Run Code Online (Sandbox Code Playgroud) 我的JSF template.xhtml文件看起来像:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:jsf="http://xmlns.jcp.org/jsf">
<h:head>
...
</h:head>
<h:body>
<header jsf:id="head">
...
</header>
<nav jsf:id="nav">
...
</nav>
<main jsf:id="main">
...
</main>
<footer jsf:id="foot">
...
</footer>
</h:body>
</html>
Run Code Online (Sandbox Code Playgroud)
Eclipse抱怨说
未知标签(主要).
我想知道我的文件是否以某种方式格式错误,或者Eclipse无法正确验证这一点.