質問
IはH拡張するにfaceletコンポーネントを作成:のcommandLinkを(いくつかの機能と角丸を追加する)
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<span class="btn-left btn-corners"> </span>
<span type="submit" class="submit">
<h:commandLink id="#{id}" value="#{label}" action="#{action}" />
</span>
<span class="btn-right btn-corners"> </span> </ui:composition>
私の新しいコンポーネントは、
を使用してアクセスすることができます<my:commandLink id="continue" label="continue" action="#{applyBacking.submit}"/>
とJavaコードは
public String submit(){
...
}
しかし、それは私にエラー「ApplyBackingプロパティが提出していない」を与えます。 commandLink、それはプロパティに#{applyBacking.submit}を評価しようとします:レンダリング中に私がいるので、私は、このエラーの理由を理解しています。代わりに、私は時間レンダリング中にテンプレートに渡され、評価される呼び出された(applyBacking.submit)の方法についての情報とします。のcommandLinkを
任意の提案ですか?
解決
複合コンポーネントを作成の代わりに(チュートリアルここの)、それはあなたを可能にしますattribtuesと豆のアクションを定義します。
ここでキックオフの例があります:
/resources/components/commandLink.xhtml
<ui:component
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:cc="http://java.sun.com/jsf/composite">
<cc:interface>
<cc:attribute name="id" required="true" />
<cc:attribute name="label" required="true" />
<cc:attribute name="action" method-signature="java.lang.String action()" required="true" />
</cc:interface>
<cc:implementation>
<span class="btn-left btn-corners"> </span>
<span type="submit" class="submit">
<h:commandLink id="#{cc.attrs.id}" value="#{cc.attrs.label}" action="#{cc.attrs.action}" />
</span>
<span class="btn-right btn-corners"> </span>
</cc:implementation>
</ui:component>
/somepage.xhtml
<!DOCTYPE html>
<html lang="en"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:my="http://java.sun.com/jsf/composite/components">
<h:head>
<title>SO question 4608030</title>
</h:head>
<h:body>
<h:form>
<my:commandLink id="continue" label="continue" action="#{applyBacking.submit}"/>
</h:form>
</h:body>
</html>
ところで、私が個人的に、例えば、丸い角部に jQueryのコーナーをJS / jQueryのを使用して、希望しますのプラグイン。ちょうどあなたのcommandLinkに特定のstyleClass
を与え、JSは魔法をやらせます。
所属していません StackOverflow