4 Replies Latest reply on Jun 19, 2007 6:53 PM by dinaddan

    using EL for variable ID's within columns

    koenhandekyn

      i'm trying to use the EL to generate unique element id's for elements within a datatable. however, for some reason it doesn't seem to work.

      what is the appropriate way to generate unique id's for elements within a datatable iteration?

      by the way : the goal of the below snipet is to open a model panel to allow a user to enter or edit row data.

      thanx for your reaction

      <rich:column>

      <rich:modalPanel id="modelPanelID#{task.id}"
      minHeight="200" minWidth="450" height="200"
      width="500" zindex="2000">
      <f:facet name="header">
      <h:outputText value="Approve Invoice"/>
      </f:facet>
      <f:facet name="controls">
      <h:graphicImage
      value="/images/modal/close.png"
      style="cursor:pointer"
      onclick="Richfaces.hideModalPanel('mp')"/>
      </f:facet>

      <h:inputText
      value="#{task.variables['invoice'].approvedBy}"
      style="width: 100px">
      </h:inputText>

      <s:button action="#{invoiceApproval.approve}"
      taskInstance="#{task}" value="Approve"/>

      </rich:modalPanel> <a href="javascript:Richfaces.showModalPanel('modelPanelID#{task.id}',{width:450, top:200})">
      approve

      </rich:column>

        • 1. Re: using EL for variable ID's within columns
          gavin.king

          huh? JSF already generates unique element ids, like modelPanelID:0, modelPanelID:1, etc.

          • 2. Re: using EL for variable ID's within columns
            koenhandekyn

            sorry, it seems that that solves my question at the generation side.

            but what is the best way to "regenerate" that ID within the loop to be able to point to it from within javascript as below?

            <a href="javascript:Richfaces.showModalPanel('modelPanelID:????',{width:450, top:200})">


            i checked and it seems indeed that JSF is creating something like a fully qualified ID when i look in the generated HTML:

            new ModalPanel('InvoiceApproveTaskInstanceListForm:_id59:1:modelPanelID' ...

            but this doesn't help me very much is it seems now even more complex to regenate the full id ?

            probably i'm missing something simple here ;)

            • 3. Re: using EL for variable ID's within columns
              dustismo

              What you want to do is not possible in jsf, sorry..

              • 4. Re: using EL for variable ID's within columns

                It is possible now with RichFaces 3.0.1 (just downloaded it and seems to work)

                You need to use rich:dataTable instead of h:dataTable (may require some CSS tuning, because rich:dataTable forces inheritance of rich-table style sheets) and specify rowKeyVar attribute to get variable holding current row number.

                For example if you use:

                <h:form id="myForm">
                 <rich:dataTable id="myTable" rowVarKey="rowIdx">
                 ...
                 <rich:modalPanel id="myPanel">
                 </rich:modalPanel>
                 ...
                 </rich:dataTable>
                </h:form>
                


                Then you can reference your panel ID in each row as:
                Richfaces.showModalPanel('myForm:myTable:#{rowIdx}:myPanel')
                


                Note that those panels don't require #{task.id} anymore. Their Id will be generated in the context of their container.