首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用JSF的If-JSF语句

使用JSF的If-JSF语句
EN

Stack Overflow用户
提问于 2016-09-23 13:36:55
回答 2查看 5.4K关注 0票数 0

我有一个网站,上面显示了一些列表。现在,列表显示在两列中,即使只有2或3个列表元素(看起来很愚蠢),但我希望只在一个列中显示。

是否有任何方法来添加带>和<操作符的if- and语句?

我就是这么做的,但不管用:

代码语言:javascript
复制
<ui:if value="#{graphicDynamic.elements.size < 3}" var="hotspots" >
     ...do the one column thing...
</ui:if>
<ui:else>
    ..do the other thing...
</ui:else>
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-10-10 13:45:57

找到解决办法了,也许这能帮到别人。不管怎样,这是我的解决方案:

代码语言:javascript
复制
<!-- Has more then 3 elements - display hotspots in two columns -->   
<h:outputLabel rendered="#{SomeClass.hasMoreThanThree}" >           
     Render the site elements for this case
</h:outputLabel>            

<!-- Has less then or 3 elements - display hotspots in one column -->
<h:outputLabel rendered="#{not SomeClass.hasMoreThanThree}" >           
     Render the site elements for this case
</h:outputLabel>

在主计长中:

代码语言:javascript
复制
public class SomeClass implements Serializable {

private boolean hasMoreThanThree; 

public SomeMethod(SomeType someParameter) {
    ...some code...
    setHasMoreThanThree(someList.size());
    ...some more code..
}

public boolean getHasMoreThanThree() {  
    return hasMoreThanThree;
}

public void setHasMoreThanThree(int size) {
    if (size >= 3){
    this.hasMoreThanThree=true;
    }
}   
票数 0
EN

Stack Overflow用户

发布于 2016-10-10 13:54:03

以下不是更简单吗?

代码语言:javascript
复制
<!-- Has more then 3 elements - display hotspots in two columns -->   
<h:outputLabel rendered="#{bean.value ge 3}" >           
     Render the site elements for this case
</h:outputLabel>            

<!-- Has less then or 3 elements - display hotspots in one column -->
<h:outputLabel rendered="#{bean.value le 3}" >           
     Render the site elements for this case
</h:outputLabel>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39662211

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档