You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Nikita Shah <ni...@yahoo.com> on 2006/01/16 12:43:48 UTC

Getting the selected row from dataTable in popup

Hi
  
  I have a jsp page which has 3 buttons for Add/Edit/Delete .On same page  i have a tabbedPanel which has two tabs for 2 jsp pages resp. On each  of this jsp page i have a dataTable. Now after the user selects a row  on the table and clicks Edit , the respective bean details should be  see in the popup.
  How do i achieve this, am not able to set the element using javascript too.
  We dont want the links in table to access popup, but selection of row and then clicking the edit button.
  Am trying to set the hiddenfield on pmView.jsp to selected rowID of  table, but am not able to do in "js" ..? and then get that ID's resp  taskID and access in popup. Is this right approach..? Am a newbie, so  any help wud be appreciated.
  
  
  --------------------------------------------------------------------------------------------------------------
  The parent jsp page is as below :
  
  <h:form id="pop">
  <h:panelGrid id="taskbuttongrid" columns="4" width="100%"
      cellpadding="0" cellspacing="0" width="30%" style="float: right;">
      <jp:popupFrame scrolling="no" height="150px" width="350px" center="true"
                  actionOpen="#{projectLeafActions.goPopup}" 
                    actionClose="#{projectLeafActions.popupReturn}"  >
          <h:commandButton id="addtaskbutton" value="Add Task" 
                  rendered="#{projectLeafActions.isAddEnabled}" 
                  styleClass="normalbutton" 
                   onmouseover="hoverButtonClass(this)"  onmouseout="normalButtonClass(this)" />         
      </jp:popupFrame> 
          
      <jp:popupFrame scrolling="no" height="150px" width="350px" center="true"
                  actionOpen="#{projectLeafActions.goEditPopup}" 
                    actionClose="#{projectLeafActions.popupReturn}"  >
      <h:commandButton id="edittaskbutton" value="Edit"  
                  styleClass="normalbutton" 
                   onmouseover="hoverButtonClass(this)"  onmouseout="normalButtonClass(this)">                 
      </h:commandButton>
      </jp:popupFrame>
      
      <h:commandButton id="deletetaskbutton" value="Delete"  
                  styleClass="normalbutton" 
                   onmouseover="hoverButtonClass(this)"  onmouseout="normalButtonClass(this)">                 
      </h:commandButton>
      
  </h:panelGrid>
  </h:form>
  <f:verbatim><br></f:verbatim>
  <t:panelTabbedPane styleClass="tabs"
                   activeTabStyleClass="active"
                    inactiveTabStyleClass="inactive"
                   activeSubStyleClass="activeSub"
                    inactiveSubStyleClass="inactiveSub"
                    tabContentStyleClass="tabContent"
                   cellpadding="0"
                   cellspacing="0"
                   width="100%">
      
      <f:subview id="pmtabview" >
          <t:panelTab id="PMTab" label="Project Manager View" >
              <jsp:include page="pmView.jsp"/>
          </t:panelTab>
      </f:subview>    
      
      <f:subview id="potabview" >
          <t:panelTab id="POTab" label="Project Owner View" >
              <jsp:include page="poView.jsp"/>
          </t:panelTab>
      </f:subview>
      
  </t:panelTabbedPane>
  --------------------------------------------------------------------------------------------------------------
  The pmView.jsp page is as below :
  
  <t:dataTable id="taskTable" styleClass="taskTable"
      rowClasses="taskTable_Row1,taskTable_Row2" var="task"
      columnClasses="taskTable_nodeColumn,taskTable_weightColumn"
      value="#{projectLeaf.tasks}" 
      rowId="#{task.taskID}" 
      preserveDataModel="false" rowOnClick="getAlert(this);">
      
      <t:column>
      <h:form id="hiddenform">
          <h:inputHidden id="taskid" value="#{task.taskID}"/>
          <h:outputText value="#{task.taskID}" />
      </h:form>
          <f:verbatim><DIV STYLE="float: left"></f:verbatim>
          <t:graphicImage  value="../images/tick.jpg" rendered="#{task.isCompleted}"  border="0"/>
          <t:graphicImage  value="../images/block.jpg" rendered="#{!task.isCompleted}"  border="0"/>                 
          
          <h:outputText value="#{task.name}" />    
  </t:column>
  </t:dataTable>
  
  --------------------------------------------------------------------------------------------------------------
  And the addTask.jsp is which opens on popup is as below:
  
  <f:view>
    <h:form id="addtaskform" style="background-color: #F2EDB6;">
    <f:verbatim><center></f:verbatim>
      <h:panelGrid id="taskpanelgrid"  columns="1">                 
          <h:panelGroup id="taskinputgrp">
              <h:outputText value="Task Name"/>
               <h:inputText id="taskName" value="#{task.name}" required="true"  validator="#{projectLeafActions.validateTaskName}"  />            
              <f:verbatim><br></f:verbatim>    
              <h:message styleClass="weightError" for="taskName" />
           </h:panelGroup>                 
          <h:panelGroup id="taskbuttonsgrp">
               <h:commandButton id="submittask" value="Add Task"  action="#{task.addTask}" />
              <jp:closePopupFrame>
                   <h:commandButton id="canceltask" value="Cancel"  />
              </jp:closePopupFrame>
          </h:panelGroup>
      </h:panelGrid>
      <f:verbatim></center></f:verbatim>    
    </h:form>
  </f:view>
  
  I want that when the user selects a row in pmView and then clicks edit  button on its parent jsp, he should get the resp task bean set in the  popup..? How do i achieve this..?
  
  TIA
  Nikita
  
  
  

		
---------------------------------
Yahoo! Photos
 Ring in the New Year with Photo Calendars. Add photos, events, holidays, whatever.