【发布时间】:2011-04-02 07:29:02
【问题描述】:
使用此代码,我可以根据下拉选择返回一张图像。关于如何返回多个图像的任何想法(我试图用图像创建一个 ArrayList 并使用 UI:Repeat 标记将其呈现回我的视图,但我没有成功。这是我现在的当前代码,它有效但仅返回一张图片。关于采取什么方法来获取多张图片的任何想法?
Java 代码:
(Person类有属性:private String theImage;)
public String getTheImage(){
if(this.theSchoolChoice.equals("University of Alabama")){
theImage = "/resources/gfx/UofALogo.png";
}
if(this.theSchoolChoice.equals("Harvard University")){
}
return theImage;
}
JSF 代码:
<h:selectOneMenu value="#{person.theSchoolChoice}" style="width : 179px; height : 21px;">
<f:selectItems value="#{person.theOptions}"/>
</h:selectOneMenu>
<h:outputLabel value=" "/>
<h:commandButton action="submit" value="Get templates" style="FONT-SIZE: medium; FONT-FAMILY: 'Rockwell';width : 128px; height : 25px;">
<f:ajax event="change" render="image" />
</h:commandButton>
<br></br>
<br></br>
<h:graphicImage id="image" value="#{person.theImage}"/>
【问题讨论】: