The best place to ask programming/development questions, imo. UPDATE: stackoverflow is the *worst* place to *ask* questions (if your first question/comment doesn't get any up-rating/response, then u can't ask anymore questions--ridiculously unrealistic), but a great reference for finding answers.

My Music (Nickleus)

20130913

sahi - how to access a specific table cell using regex when the cell doesn't have an id






here's some relevant, rendered HTML from a richfaces rich:dataTable for the image above:

...
<tbody id="invFormremoveTRQPanel:removeTrqPnlTbl:tb">
    <tr class="rich-table-row rich-table-firstrow row1">
        <td id="invFormremoveTRQPanel:removeTrqPnlTbl:0:j_id159" class="rich-table-cell wsS ">
            <input type="checkbox" name="invFormremoveTRQPanel:removeTrqPnlTbl:0:j_id161"></input>
        </td>
        <td id="invFormremoveTRQPanel:removeTrqPnlTbl:0:j_id162" class="rich-table-cell wsS ">
            X_TRQ_13144907
        </td>

...


the green code represents the first row's second column. the red code is a random id string generated by richfaces because in the xhtml/jsf file, there was no id set for the cell:

...
<rich:column>
    <f:facet name="header">#{msg['label.rcvrRefId']}</f:facet>
    <h:outputText value="#{trq.getRcvrRefId()}" />
</rich:column>

...

here's one way to access the element using regexp:
_cell(/invFormremoveTRQPanel:removeTrqPnlTbl:0:*/+"[1]")

invFormremoveTRQPanel:removeTrqPnlTbl:0 == the row identifier
/.../ == regular expression code
* == match any auto-generated id string, e.g. j_id162, this will match every column in the first row
so to specify which column (0-based) we want we write [1]

No comments:

Post a Comment