I have been having trouble with the tag <f:facet>
. I am working form other examples of code which use it, but I'm not sure exactly what purpose it serves.
我在标签
I have written some code which in method is exactly the same as other code I have seen which works, except there's is wrapped in a <f:facet name=actions>
tag. When I add this around my code the drop down box I am wrapping it around disappears when I deploy. Anyone able to suggest a reason for this or give me an insight into how and when to use facet?
我已经编写了一些代码,在方法中与我看到的其他代码完全一样,除了在
Here is my code, I won't bother adding the bean code as they're just basic getters and setters and I don't think they're causing the trouble.
这是我的代码,我不会麻烦添加bean代码,因为它们只是基本的getter和setter,我不认为它们会造成麻烦。
<f:facet name="actions">
<p:selectOneMenu id="SwitchWeekDrpDwnMenu"
value="#{depotWorkloadBean.selectView}"
partialSubmit="true">
<p:ajax update="mainForm"
listener="#{depotWorkloadBean.updateView}" />
<f:selectItem itemLabel="Day view" itemValue="Day"/>
<f:selectItem itemLabel="01/01/2014" itemValue="Week"/>
</p:selectOneMenu>
</f:facet>
If I remove the facet tag the dropdown box displays, but doesn't function as it should with the beans.
如果我删除了facet标签,就显示了下拉框,但它不像bean那样起作用。
1 个解决方案
#1
13
A facet represents a named section within a container component. For example, you can create a header and a footer facet for a dataTable component. http://www.jsftoolbox.com/documentation/help/12-TagReference/core/f_facet.html
facet表示容器组件中的指定部分。例如,您可以为dataTable组件创建一个页眉和页脚facet。http://www.jsftoolbox.com/documentation/help/12-TagReference/core/f_facet.html
It's useful when you want to create component that uses some code from user (let's say wrapper).
当您想要创建使用用户代码的组件时(比如包装器),它非常有用。
ie. when you want to create component that hides long text and shows short version of it. You can use just the element body, but then you will get only one value, if you want to get from user the short AND the long version then you can not do it in one value (without using some discriminant), just use facet and say which one is the long and which is the short version.
ie。当您想要创建隐藏长文本的组件并显示它的简短版本时。您可以使用元素的身体,但你只能得到一个值,如果你想要从用户短期和长版然后你不能用一个值(不使用一些判别),只使用方面,说哪一个是长和短的版本。
<textShortener>
<f:facet name="short">
This text is short.
</f:facet>
<f:facet name="long">
This text is too <b>long</b to be showed when page loads. User have to click the button after the short text to show this.
</f:facet>
</textShortener>
Yes, this can (and should) be done with jsf templating, but I hope you got it.
是的,这可以(也应该)用jsf模板完成,但我希望您能理解。
To question: you defined facet just in the wild xml, nobody requested it so nobody processed it - that's why it did not throw error nor showed anything.
问:您在wild xml中定义了facet,没有人请求它,所以没有人处理它——这就是为什么它没有抛出错误,也没有显示任何东西。
#1
13
A facet represents a named section within a container component. For example, you can create a header and a footer facet for a dataTable component. http://www.jsftoolbox.com/documentation/help/12-TagReference/core/f_facet.html
facet表示容器组件中的指定部分。例如,您可以为dataTable组件创建一个页眉和页脚facet。http://www.jsftoolbox.com/documentation/help/12-TagReference/core/f_facet.html
It's useful when you want to create component that uses some code from user (let's say wrapper).
当您想要创建使用用户代码的组件时(比如包装器),它非常有用。
ie. when you want to create component that hides long text and shows short version of it. You can use just the element body, but then you will get only one value, if you want to get from user the short AND the long version then you can not do it in one value (without using some discriminant), just use facet and say which one is the long and which is the short version.
ie。当您想要创建隐藏长文本的组件并显示它的简短版本时。您可以使用元素的身体,但你只能得到一个值,如果你想要从用户短期和长版然后你不能用一个值(不使用一些判别),只使用方面,说哪一个是长和短的版本。
<textShortener>
<f:facet name="short">
This text is short.
</f:facet>
<f:facet name="long">
This text is too <b>long</b to be showed when page loads. User have to click the button after the short text to show this.
</f:facet>
</textShortener>
Yes, this can (and should) be done with jsf templating, but I hope you got it.
是的,这可以(也应该)用jsf模板完成,但我希望您能理解。
To question: you defined facet just in the wild xml, nobody requested it so nobody processed it - that's why it did not throw error nor showed anything.
问:您在wild xml中定义了facet,没有人请求它,所以没有人处理它——这就是为什么它没有抛出错误,也没有显示任何东西。