The best place to *find* answers to programming/development questions, imo, however it's 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 again, a great reference for *finding* answers.

My Music (Nickleus)


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 id="invFormremoveTRQPanel:removeTrqPnlTbl:0:j_id162" class="rich-table-cell wsS ">


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:

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


here's one way to access the element using regexp:

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