我想在复合组件中创建一个简单的for循环。 我有一个组件应该显示一个字符 n 次。这似乎是最简单的方案。我不确定我做错了什么。
<div></div>
<div></div>
<h1>a heading</h1>
&#13;
出错了:
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:composite="http://xmlns.jcp.org/jsf/composite"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<composite:interface>
<composite:attribute name="length" required="true" shortDescription="The length of the anonymized text"/>
</composite:interface>
<composite:implementation>
<c:forEach begin="0" end="#{cc.attrs.length}">•</c:forEach>
</composite:implementation>
</ui:composition>
答案 0 :(得分:0)
我设法通过在java中创建一个util类来创建一个空数组来迭代class Example1
{
public static void main(String args[])
{
try{
int num1=30, num2=0;
int output=num1/num2;
System.out.println ("Result: "+output);
}
catch(Exception e){
//and in want to determine the type of exception ie- Arithmetic
exception on the another class IS IT POSSIBLE? AND HOW
}
}
}
查看:强>
<ui:repeat />
util class:
<ui:repeat value="#{util:createArray(cc.attrs.length)}" var="index">•</ui:repeat>
<强>标签库:强>
public final class UIHelper {
public static Object[] createArray(int size) {
return new Object[size];
}
}