JSF 中的 If-Else 语句
If-Else statement in with JSF
我有一个网站,上面显示了一些列表。
现在,列表显示在两列中,即使只有 2 或 3 个列表元素(看起来很愚蠢),但我只想显示在一列中。
有什么方法可以添加带有 > 和 < 运算符的 if-else 语句?
这是我所做的,但不起作用:
<ui:if value="#{graphicDynamic.elements.size < 3}" var="hotspots" >
...do the one column thing...
</ui:if>
<ui:else>
..do the other thing...
</ui:else>
找到了一个解决方案,也许它有时会帮助某些人......无论如何,这是我的解决方案:
<!-- 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>
在控制器中:
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;
}
}
下面的不是更简单吗
<!-- 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>
我有一个网站,上面显示了一些列表。 现在,列表显示在两列中,即使只有 2 或 3 个列表元素(看起来很愚蠢),但我只想显示在一列中。
有什么方法可以添加带有 > 和 < 运算符的 if-else 语句?
这是我所做的,但不起作用:
<ui:if value="#{graphicDynamic.elements.size < 3}" var="hotspots" >
...do the one column thing...
</ui:if>
<ui:else>
..do the other thing...
</ui:else>
找到了一个解决方案,也许它有时会帮助某些人......无论如何,这是我的解决方案:
<!-- 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>
在控制器中:
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;
}
}
下面的不是更简单吗
<!-- 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>