【问题标题】:Set p:selectBooleanCheckbox value to bean with ajax使用 ajax 将 p:selectBooleanCheckbox 值设置为 bean
【发布时间】:2013-09-09 07:59:32
【问题描述】:

您好,我有一个带有动态列的 primefaces 数据表

<h:form>
    <p:dataTable id="cars" var="car" value="#{formBean.carsSmall}" 
        filteredValue="#{formBean.filteredCars}">
        <p:columns value="#{formBean.columns}" var="column" 
            columnIndexVar="colIndex"sortBy="#{column.property}" 
                filterBy="#{column.property}">
            <f:facet name="header">
                #{column.header}
            </f:facet>
            <p:outputPanel 
                rendered="#{(column.header eq 'CHECKVALUE1') or (column.header eq 'CHECKVALUE2')}" >
                <p:selectBooleanCheckbox value="#{car.checkValue}"  id="checkboxId">
                </p:selectBooleanCheckbox>
            </p:outputPanel>
            <p:outputPanel 
                rendered="#{(column.header ne 'CHECKVALUE1') and (column.header ne 'CHECKVALUE2')}" >
                #{car[column.property]}
            </p:outputPanel>
        </p:columns>
    </p:dataTable>
</h:form>

我想用 ajax 将复选框值提交给 bean,我该怎么做? 我试着写这样的东西:

<p:selectBooleanCheckbox value="#{car.checkValue}"  id="checkboxId">
    <p:ajax update="@form"/>
</p:selectBooleanCheckbox>

但值没有设置为 bean..

【问题讨论】:

  • 您是否尝试过指定您需要的事件? event="click"
  • @Xtreme:如果是复选框/单选按钮,默认情况下已经点击。

标签: ajax jsf primefaces datatable


【解决方案1】:
<p:selectBooleanCheckbox value="#{car.checkValue}"  id="checkboxId">
        <p:ajax update=":form" listener="#{car.addMessage}"/>  
</p:selectBooleanCheckbox>  

Java Bean 类 -

public void addMessage()
{
    //Your Java Code goes here.
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-06-09
    • 2012-07-03
    • 2012-09-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-07
    • 2017-09-21
    相关资源
    最近更新 更多