原子datatable rowedit不更新单元格元素 [英] primefaces datatable rowedit not updating cell element

查看:423
本文介绍了原子datatable rowedit不更新单元格元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有rowedit的datatable。
我的表的一列是一个带有列表框的单元格,列表框的项目被动态检索(取决于另一个单元格中的值)
我使用rowEditInit设置selectedrow项。我想更新列表框以检索正确的值。
这不行。
当我做

 < p:ajax event =rowEditInitlistener =#{workOrderDetail.onEdit} update =orderitemstable/> 

然后当我点击铅笔图标时,我可以看到行切换到编辑模式并重新生成列表框项目。但是它直接被转回到非编辑模式。



但是当我做

 < p:ajax event =rowEditInitlistener =#{workOrderDetail.onEdit}update =rmactionenumid/> 

然后点击铅笔图标将该行置于编辑模式,但没有调用来检索列表框物品。我的目的是,它不会触发rmactionenumid的更新。



任何想法?



Roel



这是我的jsf代码



 < p:ajax event =rowEditInitlistener =#{workOrderDetail.onEdit}update =rmactionenumid/> 


< p:column>
< p:cellEditor>
< f:facet name =output>
< h:outputText id =rmactionenumidlabelvalue =#{orderItem.rimctionRepr}>
< / h:outputText>
< / f:facet>
< f:facet name =input>
< h:selectOneListbox id =rmactionenumidvalue =#{orderItem.rmActionEnumId}size =1valueChangeListener =#{workOrderDetail.setActionRepr}>
< f:selectItems value =#{workOrderDetail.actionItems}/>
< p:ajax event =changeupdate =partdiscount,labourdiscount,totalprice,:detail:wodetail:totalsexecute =@ this/>
< / h:selectOneListbox>

< / f:facet>
< / p:cellEditor>
< / p:column>
< p:column>
< p:rowEditor id =edit/>
< / p:commandLink>

< / p:column>
< / p:dataTable>

这里是我的java bean代码

  public List< SelectItem> getActionItems()抛出MWSException {
ArrayList< SelectItem> actions = new ArrayList< SelectItem>();
if(getSelectedOrderItem()!= null){

ListManager lm = new ListManager(getWA()。getMwsProxy());
MWSGenericMapList items = lm.nativeSearch(getWS()。getUser(),HdfWebConstants.NS_VEHICLEPARTACTIONS,0,0,200,
false,getSelectedOrderItem()。getVehiclePartCode()); (int i = 0; i< items.size(); i ++){
actions.add(new SelectItem(items.get(i).get(rmaction_enumid ).toString(),items.get(i).get(rmaction)
.toString()));
}

}
返回动作;
}

public void setSelectedOrderItem(IMWSOrderItem newSelectedOrderItem)throws MWSException {
this.selectedOrderItem = newSelectedOrderItem;
}

public void onEdit(RowEditEvent event)throws MWSException {

setSelectedOrderItem((IMWSOrderItem)event.getObject());

}

我正在使用PF3.5

解决方案

它失败,因为 update =rmactionenumid在这个结构中相对于表本身,而不是当前的表行。



基本上,它正在寻找一个客户端ID formId的组件:tableId:rmactionenumid 而不是eg第二行 formId:tableId:1:rmactionenumid 。技术上,< p:ajax> 应放在< p:column> 内,不要为 rowEditInit 事件工作。



您需要编写自己的根据 RowEditEvent 参数可用的 UIData 组件更新客户端ID,并添加组成客户端ID到 PartialViewContext#getRenderIds()



所以,删除< p:ajax更新> 并扩展 onUpdate()方法如下:

  public void onEdit(RowEditEvent event){
UIData table =(UIData)event.getComponent();
String updateClientId = table.getClientId()+:+ table.getRowIndex()+:rmactionenumid;
FacesContext.getCurrentInstance()。getPartialViewContext()。getRenderIds()。add(updateClientId);

// ...
}


I have a datatable with rowedit. One column of my table is a cell with a listbox in, the items of the listbox are dynamically retrieved (depending on the value in another cell) I use rowEditInit to set the selectedrow item. And I want to update the listbox to retrieve the correct values. This does not work. When I do

<p:ajax event="rowEditInit" listener="#{workOrderDetail.onEdit}" update="orderitemstable" />

Then when I click the pencil icon, the I can see the row switch to edit mode and retriving the listbox items. But it directly swithced back to non edit mode.

But when I do

<p:ajax event="rowEditInit" listener="#{workOrderDetail.onEdit}" update="rmactionenumid" />

Then clicking the pencil icon puts the row in edit mode, but no call is made to retrieve the listbox items. My gues is, it does not trigger the update on rmactionenumid.

Any ideas?

Roel

Here is my jsf code

            <p:ajax event="rowEditInit" listener="#{workOrderDetail.onEdit}" update="rmactionenumid" />


            <p:column >  
                <p:cellEditor>  
                    <f:facet name="output">  
                        <h:outputText id="rmactionenumidlabel" value="#{orderItem.rmActionRepr}" >
                        </h:outputText>
                    </f:facet>  
                    <f:facet name="input">  
                        <h:selectOneListbox id="rmactionenumid" value="#{orderItem.rmActionEnumId}" size="1" valueChangeListener="#{workOrderDetail.setActionRepr}">
                            <f:selectItems value="#{workOrderDetail.actionItems}"/> 
                            <p:ajax event="change" update="partdiscount,labourdiscount,totalprice,:detail:wodetail:totals" execute="@this"  />                                  
                        </h:selectOneListbox>   

                    </f:facet>  
                </p:cellEditor>  
            </p:column>
<p:column >
<p:rowEditor id="edit"  />                          
                </p:commandLink>

            </p:column>  
        </p:dataTable>

and here is my java bean code

public List<SelectItem> getActionItems() throws MWSException {
    ArrayList<SelectItem> actions = new ArrayList<SelectItem>();
    if (getSelectedOrderItem() != null) {

        ListManager lm = new ListManager(getWA().getMwsProxy());
        MWSGenericMapList items = lm.nativeSearch(getWS().getUser(), HdfWebConstants.NS_VEHICLEPARTACTIONS, 0, 0, 200,
                false, getSelectedOrderItem().getVehiclePartCode());

        for (int i = 0; i < items.size(); i++) {
            actions.add(new SelectItem(items.get(i).get("rmaction_enumid").toString(), items.get(i).get("rmaction")
                    .toString()));
        }

    }
    return actions;
}

public void setSelectedOrderItem(IMWSOrderItem newSelectedOrderItem) throws MWSException {
    this.selectedOrderItem = newSelectedOrderItem;
}

public void onEdit(RowEditEvent event) throws MWSException {

    setSelectedOrderItem((IMWSOrderItem) event.getObject());

}

I'm using PF3.5

解决方案

It fails because update="rmactionenumid" is in this construct relative to the table itself, not to the current table row.

Basically, it's looking for a component with client ID formId:tableId:rmactionenumid instead of e.g. the second row formId:tableId:1:rmactionenumid. Technically, the <p:ajax> should be placed inside the <p:column>, but this won't work out for rowEditInit event.

You'd need to compose your own update client ID based on the UIData component which is available as RowEditEvent argument and add the composed client ID to PartialViewContext#getRenderIds().

So, remove the <p:ajax update> and extend the onUpdate() method as follows:

public void onEdit(RowEditEvent event) {
    UIData table = (UIData) event.getComponent();
    String updateClientId = table.getClientId() + ":" + table.getRowIndex() + ":rmactionenumid";
    FacesContext.getCurrentInstance().getPartialViewContext().getRenderIds().add(updateClientId);

    // ...
}

这篇关于原子datatable rowedit不更新单元格元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆