3

selectOneMenu用于显示一些图片和字符串,图片仅用于显示目的(即我在提交时与它们无关)我只想在图片旁边设置字符串,我在设置上有冲突所需itemValuef:selectItems字符串,当我这样做时,图像根本不会出现,总之,我只想提交所选字符串的值selectItem而不使用转换器:

JSF 代码:

<p:selectOneMenu id="SkinChooser" value="#{personBean.ObjectDTO.personDescription.skin}"
        panelStyle="width:150px" effect="fade" var="s"
        style="width:160px" converter="#{personBean.converter}">
        <f:selectItem itemLabel="Select One" itemValue="" />
        <f:selectItems value="#{missedPersonBean.selectedSkins}"
        var="skin" itemLabel="#{skin.skinType}" itemValue="#{skin}" />
                <p:column>
                      <p:graphicImage value="/resources/images/skin/#{s.skinPhoto}"
                                width="40" height="50" />
                </p:column>
                <p:column> 
                      #{s.skinType}  
                </p:column>
</p:selectOneMenu>

皮肤.Java

public class Skin {
String skinPhoto;
String skinType;

public Skin() {
}

public Skin(String photo, String type) {
    this.skinPhoto = photo;
    this.skinType = type;
}

public String getSkinPhoto() {
    return skinPhoto;
}

public void setSkinPhoto(String skinPhoto) {
    this.skinPhoto = skinPhoto;
}

public String getSkinType() {
    return skinType;
}

public void setSkinType(String skinType) {
    this.skinType = skinType;
    }
}

personBean.Java

@ManagedBean(name = "personBean")
@SessionScoped
public class ReportPerson {
private Skin skin;
private static List<Skin> selectedSkins;


static {
System.err.println("Array is filled");
selectedSkins = new ArrayList<Skin>();
selectedSkins.add(new Skin("1", "Pale white"));
selectedSkins.add(new Skin("2", "Fair white"));
selectedSkins.add(new Skin("3", "Light brown"));
selectedSkins.add(new Skin("4", "Moderate brown"));
selectedSkins.add(new Skin("5", "Dark brown"));
selectedSkins.add(new Skin("6", "Deeply pigmented"));
System.err.println("Finished Filling");

}

public List<Skin> getSelectedSkins() {
return selectedSkins;
}

 public void setSelectedSkins(List<Skin> selectedSkins) {
 this.selectedSkins = selectedSkins;
 }

public Skin getSkin() {
return skin;
 }

 public void setSkin(Skin skin) {this.skin = skin;}

 }
4

0 回答 0