单击铃声项目时未设置属性

时间:2014-06-16 13:59:09

标签: jsf primefaces

我在Prime面孔3.2中有以下子页面:

<ui:composition template="index.xhtml">

    <ui:define name="centerContent">

    <h:form id="youtubeform">

        <h3 style="margin-top: 0">Music</h3>
        <p:ring id="basic" value="#{ringView.items}" var="item">
            <p:outputPanel style="text-align: center;" layout="block">
                #{item.link}
                <br />
                <p:commandButton update=":youtubeform:itemDetail" icon="ui-icon-search" 
                    title="View" oncomplete="itemDialog.show()" >
                    <f:setPropertyActionListener value="oka" target="#{ringView.str2}" />
                </p:commandButton>
            </p:outputPanel>
        </p:ring>

        <p:dialog header="YoutubeItem Info" widgetVar="itemDialog" 
            showEffect="fade" hideEffect="fade" resizable="true" width="300" >
        <h:outputText id="itemDetail" value="#{ringView.str2}" />  
        </p:dialog>   

    </h:form>

    </ui:define>

</ui:composition>

和bean:

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;


@ManagedBean
@ViewScoped
public class RingView implements Serializable {

    private List<YoutubeItem> items;
    private YoutubeItem selectedYoutubeItem;

    private String str2 = "OK1";

    public String getStr2() {
        return str2;
    }

    public void setStr2(String str2) {
        this.str2 = str2;
    }

    public YoutubeItem getSelectedYoutubeItem() {
        return selectedYoutubeItem;
    }

    public void setSelectedYoutubeItem( YoutubeItem selectedYoutubeItem) {
        //this.selectedYoutubeItem = new YoutubeItem( "selected" + i);
        this.str2 = "setSelectedYoutubeItem";
        //this.selectedYoutubeItem = selectedYoutubeItem;
    }

    @PostConstruct
    public void init() {
        items = new ArrayList<YoutubeItem>();

        items.add( new YoutubeItem( "link1"));
        items.add( new YoutubeItem( "link2"));
        items.add( new YoutubeItem( "link3"));
        //this.selectedYoutubeItem = new YoutubeItem( "selected");
    }

    public List<YoutubeItem> getItems() {
        return items;
    }

    public void setItems( List<YoutubeItem> items) {
        this.items = items;
    }
}

调用响铃项时,属性字符串str2不会更新。

0 个答案:

没有答案