【发布时间】:2015-11-06 21:08:35
【问题描述】:
当我创建一个包含构面的复合组件并在该构面中放置一个命令链接时,我收到一条错误消息:This link is disabled as it is not nested within a JSF form.
commandButton 的行为方式不同,所以我倾向于这是一个错误。
index.xhtml:
<?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:h="http://xmlns.jcp.org/jsf/html"
xmlns:mycomp="http://xmlns.jcp.org/jsf/composite/mycomp"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<h:head>
</h:head>
<h:body>
<mycomp:component>
<f:facet name="someFacet">
<h:commandLink value="this link should work, but does not (within form, within facet)"/><br/>
<h:commandButton value="this button works as expected (within form, within facet)"/><br/>
</f:facet>
</mycomp:component>
</h:body>
</html>
/resources/mycomp/component.xhtml:
<?xml version='1.0' encoding='UTF-8' ?>
<ui:component
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:cc="http://xmlns.jcp.org/jsf/composite"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:a="http://xmlns.jcp.org/jsf/passthrough"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
>
<cc:interface>
<cc:facet name="someFacet" required="true"/>
</cc:interface>
<cc:implementation>
<h:commandLink value="this link should not work (not in a form)"/><br/>
<h:form>
<h:commandLink value="this link works as expected (within form, but not in facet)"/><br/>
<cc:renderFacet name="someFacet"/>
</h:form>
</cc:implementation>
</ui:component>
这就是我的浏览器所做的:
关于我可能做错了什么的任何想法,或者这确实是 Mojarra 2.2.7 中的一个错误? (与 NetBeans 8.0.2 捆绑在一起)
【问题讨论】:
-
Mojarra 2.1.6 呈现相同的输出(橙色项目符号除外)。
-
这确实是一个错误。你最好直接报告。然而,在复合材料中拥有一种形式反过来又是一种设计气味。您的复合材料不会“太多”吗?另见stackoverflow.com/questions/6822000/…
-
@DavidS 不是
h:form,而是这个组件正在接受一个名为someFacet的构面:大概是表单的更多内容。 -
是的,也许我在这里太努力了;我试图创建一个组合,它采用两组
commandLink组件来构建菜单结构。需要渲染的 html 已经定义好了,所以没有绕开这两个集合。
标签: jsf composite-component facet mojarra commandlink