【发布时间】:2012-04-29 22:17:09
【问题描述】:
我必须编写一个显示登录表单的复合组件,并且可以与以下代码sn-p一起使用:
<login:loginForm username="#{loginBean.username}"
password="#{loginBean.password}"
action="#{loginBean.login}"/>
我的 loginBean 只是一个简单的可序列化 @ViewScoped @ManagedBean,带有 getter、setter 和 public String login() 方法。
这是我的复合组件:
<body>
<cc:interface>
<cc:attribute name="username" required="true" type="java.lang.String" />
<cc:attribute name="password" required="true" type="java.lang.String" />
<cc:attribute name="action" targets="submit" required="true" method-signature="java.lang.String f()"/>
</cc:interface>
<cc:implementation>
<h3><span xml:lang="en">Login</span> Daten </h3>
<h:form>
<div class="formblock">
<fieldset>
<div>
<h:outputLabel value="Username" for="username"/>
<h:inputText id="username" value="#{cc.attrs.username}"/>
</div>
<div>
<h:outputLabel value="Passwort" for="password"/>
<h:inputSecret id="password" value="#{cc.attrs.password}"/>
</div>
</fieldset>
</div>
<div class="buttons">
<h:commandButton id="submit" value="Anmelden" accesskey="r" />
</div>
</h:form>
</cc:implementation>
</body>
但是,当我在浏览器中打开 login.xhtml 页面(其中包含 login:loginForm-sn-p)时,我可以在码头日志中看到以下错误:
Apr 29, 2012 11:59:49 PM org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage retargetMethodExpressions
SEVERE: Inner component submit not found when retargetMethodExpress
但这意味着什么?我的代码中的错误在哪里?我已经尝试了一些其他解决方案来实现action 属性,但没有成功。
【问题讨论】:
-
刚刚看到我使用的是 myfaces 版本 2.0.4 而不是当前的 2.1.7 版本。所以,升级了,现在错误消失了。但是单击命令按钮时仍然没有执行该操作。
标签: jsf jsf-2 composite-component