I have the following xhtml:
<s:fragment
rendered="#{selectCat.categoryTypes.contains('unclickable')}">
<h:outputText value="DONT CLICK #{selectCat.webName}" />
</s:fragment>
<s:fragment rendered="#{selectCat.categoryTypes eq null}">
<a href="/category/#{_category.fullName}"> #{selectCat.webName}</a>
</s:fragment>
And I am trying to read whether the type is unclickable..
The backend bean reads:
@ManyToMany(fetch = FetchType.LAZY, targetEntity = C_Type.class)
@JoinTable(name = "Category_Type", joinColumns = @JoinColumn(name = "CategoryId"), inverseJoinColumns = @JoinColumn(name = "TypeId"))
@XmlTransient
public Set<C_Type> getCategoryTypes() {
for (C_Type cc : categoryTypes) {
System.out.println("=============="+cc.getC_type()+"==============");
}
return categoryTypes;
}
What am I doing wrong, or what do I need to do to show a link as unclickable? IN the front-end? Thanks
This statement directly won't work in EL
for JSF 1.x
#{selectCat.categoryTypes.contains('unclickable')}
Now for the solution try a custom taglib
function using below pointers...
Register taglib in web.xml
<context-param>
<param-name>facelets.LIBRARIES</param-name>
<param-value>
PATH_TO_CUSTOM_TAGLIB;/WEB-INF/tomahawk.taglib.xml;
</param-value>
</context-param>
Define method in the taglib as:
<facelet-taglib>
<namespace>
http://www.client.com/product
</namespace>
...
<function>
<function-name>contains</function-name>
<function-class>com.XXX.XXX.XXX.JavaClass</function-class>
<function-signature>java.lang.Boolean contains(java.util.Set, java.lang.String)</function-signature>
</function>
...
</facelet-taglib>
Define java method in com.XXX.XXX.XXX.JavaClass
as
public static Boolean contains(Set setOfObjects, String value){
//... Assuming you are checking where value, a string, is available in Set or not
}
Declare the namespace in XHTML
xmlns:g="http://www.client.com/product"
And finally call it in xhtml
<s:fragment
rendered="#{g:contains(selectCat.categoryTypes,'unclickable')}">
Hope it helps!!!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.