开发者

Referring in EL to specific instance of h:datatable iteration variable

Okay. Complex Title for a simple(?) problem.

I have something like this going on (I made it as simple as possible here to illustrate)

<h:dataTable var="testVar" value="#{bean.VariablesArray}">
<h:inputText id="TestingID" 
             styleClass="propertyInput" 
             value="#{testVar.var1}"
         disabled="#{testVar.var2 != false }" 
             readonly="#{testVar.var2 != false }" />
<h:selectBooleanCheckbox 
             value="#{testVar.var2}">
         <a4j:support event="onclick" reRender="TestingID" />
</h:dataTable>

It doesn't work and i'm assuming because of two reasons related to the datatable:

  1. The EL "#{testVar.var2 != false }" should have a better instance indicator.

  2. The reRender="TestingID" should be reffering to the correct instance of the inputText.

So my que开发者_如何学编程stion is how do I do this correctly?

Thanks!!!


According to the doc, reRender takes the form used by UIComponent.findComponent(String) (that is, it uses the client identifier and not the component identifier).

There are a few ways to get this value (combinations of backing beans, static functions and/or component binding) but you'll end up with something like this:

<h:inputText id="TestingID" styleClass="propertyInput" 
             value="#{testVar.var1}" disabled="#{testVar.var2 != false }" 
             readonly="#{testVar.var2 != false }"

             binding="#{someReqScopeMap.TestingID}" />

<h:selectBooleanCheckbox value="#{testVar.var2}">
  <a4j:support event="onclick"
             reRender="#{myfn:cid(someReqScopeMap.TestingID)}" />

See JSF: working with component identifiers (id/clientId) for more detail and sample code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜