Getting the current row in a datatable

Hi,
I am using datatable. How do I get the current row in the datatable
and use it for my processing in the JSP page
or I want to just output that value with out using any jsf tags.
Examples
<h:dataTable styleClass="dataTable" id="table1" border="0"                    value="#{myTrainingHandler.myMediaTraining}" var="dataIt">
<h:column id="column1">
<f:facet name="header">
<h:outputText styleClass="outputText" value="Course Name"id="text1"></h:outputText>
</f:facet>
<!---------------------------------------------- how do I get the value of #{dataIt.name} and use it in the JSP way
Reason: I just want to output the value. If I am using h:outputText then it inserts <span>... </span>
or, I want to transfer that value to another another attribute in the session or something like that.
---------------------!>
<h:outputText styleClass="outputText" id="text2" value="#{dataIt.name}"></h:outputText>
</h:column>
</h:dataTable>
-Aswath

It looks like good idea!Unfortunately this is just workaround. Indeed your
suggestion is real JSF-feeling solution but due to the
bug (or rather pure design of RI implementation???) it
is dangerous.
I had some doubt about is it bug or my incompetence.
Unfortunately this seems is really bug.
Hope this problem will be solved in the next releases.from blueprints catalog:
Component bindings (e.g. <h:inputText binding="#{MyBean.lastNameComponent}" />) should always be stored in request scope since their value is no longer valid after a request has been processed anyway. The component tree is reconstituted during each incoming request, changing the physical instances these component bindings will point to.
as you see there is really problem in using session backing bean with component binding
so that means idea with parameter looks better now because we don't need to use table binding.
Or probably we can define some kind of pattern like couple of beans with request scope and session scope.
for example:
Catalog - session scope
CatalogView - request scope
Catalog will keep session data and CatalogView will provide some presentation logic (including some stricly visual oriented data) and access to business methods of Catalog class.
I will send you example by e-mail (on friday) if you not mind.
>
Thank you for your suggestion!
Probably I will use your idea in my application.
By the way I'm from Kiev also.Hello from Kiev :-)
I have one suggestion.
I'm working on JSF form that suppose to add, editand
delete records from table.
Also I wanna to use scrolling by page and sorting.
I'm trying to make this form somehow clean and
universal as much as possible.Seems I have same tasks for now.Great! I will send some code soon.
And maybe we can discuss every aspect how to do good JSF based application including config oriented information and utilities classes.
-how do you work with tables without primary keyI dont' have tables without primary key :)
-how do you make pagination by universal wayWe need just make good component for that.
We already started in this direction.

Similar Messages

  • Getting the selected row from a datatable -- URGENT

    Hi,
    I am facing the following problem with a datatable. The datatable does not have any Input components like CommandLink, Buttons, Radio Buttons and Checkbox. Even I cannot use the hidden Command Link.
    One solution is to use a input hidden variable which can hold the curent row Id. But in this case too, how to get the control in a backing bean method is not clear to me.
    Please guide me how to get the data of the selected row in the backing bean.
    Thanks in advance......
    VJain.

    I again explain my problem:
    I need to get the Current Selected Row onclick of any row in a Datatable. But the datatable is restricted not to have any CommandLink or Input component so that I can generate the action to go to any method on a backing bean as shown below.
    <h:dataTable id="dTable" value="#{Bean.myList}" var="currentRow" >
    <h:column id="row1">
    <h:outputText value="# currentRow.productNumber}"></h:outputText>
    </h:column>
    <h:column id="row2">
    <h:outputText value="# currentRow.productName}"></h:outputText>
    </h:column>
    </h:dataTable>
    As shown above I cannot use any commandButton or CommandLink to submit the page. All I can do is to generate any onclick function on Table and do something with it. But not sure how to do it.
    Now I want the productNumber of the selected row in any method say getCurrentRowId of the Bean.
    I hope the problem must be clear now....
    Thanks for your quick reply..
    VJ

  • Getting the current row as the DataGrid is created.

    I want to trap the first row of my DataGrid how can I do
    this?

    Amit, shame you didn't include a code example. The first blog does work...though probably not the most effecient mechanism. The 2nd Blog seems to be missing something as referencing e.site isn't enough. I've included a code sample of what it should be. Please include the routine DeleteNil as you can't assign a value to a null node. If theres a more effecient way..by all means post a blog. Cheers
    public void Items_UnitGross_Changed(object sender, XmlEventArgs e)
    // Check if value has changed and not a table insertion
    if (e.Operation == XmlOperation.ValueChange)
    // Get Current Row
    XPathNavigator xNavigator = e.Site;
    bool bParent = xNavigator.MoveToParent();
    // Get Reference to the Gross Value
    XPathNavigator xField = xNavigator.SelectSingleNode("boc:UnitGross", this.NamespaceManager);
    DeleteNil(xField);
    double dGross = Convert.ToDouble(xField.Value);
    // Get Reference and set the Net Value
    xField = xNavigator.SelectSingleNode("boc:UnitNet", this.NamespaceManager);
    DeleteNil(xField);
    xField.SetValue(getNet(dGross).ToString());
    public void DeleteNil(XPathNavigator node)
    if (node.MoveToAttribute("nil", "http://www.w3.org/2001/XMLSchema-instance"))
    node.DeleteSelf();
    private double getNet(double Gross)
    // Calculates the Net Value (without Tax) from the Gross value
    double dNet = Gross / C_VATRATE_DIV;
    return dNet;

  • I want to get the current Cursor row number

    Hello!
    Is it possible to get the current row number of a cursor in a cursor loop?
    for c_1 in cursor_1
    loop
    dbms_output.put_line(c_1. ???) --> this should show: 1 in the first loop ,2,3,...
    endloop
    best regards,
    wolf

    SQL> declare
      2  cursor c is
      3  select * from emp;
      4  begin
      5  for r in c loop
      6    dbms_output.put_line(c%rowcount);
      7  end loop;
      8  end;
      9  /
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    PL/SQL procedure successfully completed.Max
    [My Italian Oracle blog|http://oracleitalia.wordpress.com/2010/02/07/aggiornare-una-tabella-con-listruzione-merge/]

  • Select the current row in read only querry VO

    Hi.,
    I am using jdev 11.1.1.5
    I had created a Finyear EO with corresponding VO
    I had also created a read only querry VO [PostdGLhdlnVO]
    I had created a viewlink between FinyearVO and PostdGlhdlnVO with following conditions
    FinyearVO.bu = PostdGLhdlnVO.bu
    FinyearVO.year = PostdGLhdlnVO.year
    I need to select the current row and print that row using println statement. as i am using readonly querry while i drag and drop the PostdGLhdlnVO i cant able to select the current line (i.e., when user clicks the current row)
    My scenario:
    I need to create a non database checkbox for every row in that table [PostdGLhdlnVO] which will get the current row
    can anyone help me to create a nondatabase checkbox for that table

    Try,
    This may help:
    Re: ADF Table Multiple row selection by Managed Bean-Prasad

  • How to handle the current row with radio button selection???

    Hi Everyone,
    I have one ADF page with one table and one "Find" button.
    I have created one new attribute with VARCHAR2(1) in the VO and dragged that attribute as first column in the table. And changed that first column to Radio Button to select only one row at a time.
    Upon clicking on the "Find" button i need to get the values of current selected row.
    How can i get the values of selected row?
    What code should i write to get the values of selected row in Method Binding of "Find" button?
    Any suggestions will be really useful.
    Thanks.

    Hello Kumar,
    I have some comments on your case.
    >
    I have created one new attribute with VARCHAR2(1) in the VO
    >
    1- You should create this attribute in the Entity object and then add it to the view object.
    2- Do you need that only one radio button is set at a time for all rows ? If yes then you need to handle the case when the user set more than one row and clear the value of the attribute for all other rows.
    >
    How can i get all the values of current row in backing bean method(method binding of Find method)?
    can u plz provide me the code for that?
    >
    If you mean by the current row is that the row with its value of the selected attribute is set (the radio button is set for that row), then you can write a method in the viewObjectImpl class and expose it to client interface and call it from your bean.
    here is an example based in Department table in HR schema.
    //This method is written in DepartmentsViewImpl   
    public Row getSelectedRadioRow(){
                //create a second row set to not impact the row set used in ADF
                RowSet duplicateRowSet = this.createRowSet("duplicateRowSet");
                //get the current row of the table to set it back after re-executing the VO
                DepartmentsViewRowImpl currentRow = (DepartmentsViewRowImpl)this.getCurrentRow();
                Row[] filteredRows = duplicateRowSet.getFilteredRows("IsSelected", "1");
                DepartmentsViewRowImpl row=null;
                if(filteredRows.length>0){
                    row = (DepartmentsViewRowImpl)filteredRows[0];
                    System.out.println("Department Name " + row.getDepartmentName());              
                this.setCurrentRow(currentRow);
                duplicateRowSet.closeRowSet();
                return row;           
            }

  • Updating the current row in vo which is bind to af:table.

    Dear all.
    I have created af table by dragging datacontrol on page.. i also have a form and onclick of button i want to update the current selected row in table..
    I am getting the current row properly but when i am trying to update the row.. it gives me following exception.
    <Utils> <buildFacesMessage> ADF: Adding the following JSF error message: Failed to lock the record, another user holds the lock.
    oracle.jbo.AlreadyLockedException: JBO-26030: Failed to lock the record, another user holds the lock.
    Following is my update code.
    public void update(){
    //BindingContext.getCurrent().getCurrentBindingsEntry().getOperationBinding("Create").execute();
    BindingContext bc = BindingContext.getCurrent();
    JUApplication japp =
    (JUApplication)bc.getCurrentBindingsEntry().get("Entries_AMDataControl");
    Entries_AMImpl ampl = (Entries_AMImpl)japp.getApplicationModule();
    ViewObjectImpl vo=ampl.getEntries_VO1();
    Entries_VORowImpl row=(Entries_VORowImpl)vo.getCurrentRow();
    row.setSubject(subject);
    ClobDomain c=new ClobDomain(toXML().toString());
    row.setXmlcontent(c);
    row.setDescription("");
    //vo.setCurrentRow(row);
    //vo.executeQuery();
    //BindingContext.getCurrent().getCurrentBindingsEntry().getOperationBinding("Execute").execute();
    BindingContext.getCurrent().getCurrentBindingsEntry().getOperationBinding("Commit").execute();
    So please can anyone there tell me how can solve this problem.
    Thanks,
    Regards
    jdev version 11.1.1.4.0

    Hi Frank
    in your AM configuration, set the locking behavior to optimisticIts already optimistic.
    is bad coding practice. You should perform updates through teh ADF binding layer and not directlxy against the Application Module Impl class. You can get the >current row from the iterator the table is bound to and set the attributes on itI changed my code to following
    RowKeySet rs = getCalcTable().getSelectedRowKeys();
    Iterator it = rs.iterator();
    DCBindingContainer bindings =
    (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
    DCIteratorBinding empIter =
    bindings.findIteratorBinding("Entries_VO1Iterator");
    StringBuilder sb = new StringBuilder();
    RowSetIterator empRSIter = empIter.getRowSetIterator();
    Row currentRow = null;
    while (it.hasNext()) {
    Key key = (Key)((List)it.next()).get(0);
    currentRow = empRSIter.getRow(key);
    break;
    Entries_VORowImpl row=(Entries_VORowImpl)currentRow;
    row.setSubject(subject);
    ClobDomain c=new ClobDomain(toXML().toString());
    row.setXmlcontent(c);
    row.setDescription("");
    BindingContext.getCurrent().getCurrentBindingsEntry().getOperationBinding("Commit").execute();
    But it still gives me same error.
    <Utils> <buildFacesMessage> ADF: Adding the following JSF error message: Failed to lock the record, another user holds the lock.
    oracle.jbo.AlreadyLockedException: JBO-26030: Failed to lock the record, another user holds the lock.
    Any suggestion appreciated..
    Thanks
    Regards.

  • How the get the current dataTable row

    I have a dataTable with the value from List in the BackingBean.
    The script is printing the list elements, and I want to get the number of each row. I don't have any enumaration in for the records. Can it be done simply?
    Thanks for answer.

    You can use HtmlDataTable#getRowData() to retrieve the current row object in the iteration.
    But you just want to retrieve row numbers? Then rather use HtmlDataTable#getRowIndex().
    Also see http://balusc.xs4all.nl/srv/dev-jep-dat.html for several datatable use examples.

  • Re: Getting the current selected Row & column in adf table

    Hi,
    Our requirement is we have to retrieve both the current row and column in adf table.
    We can retrieve the current row in the backing bean like
    ViewObject view = getViewObject();
    view.getCurrentRow();
    Is it possible to retrieve selected column id or column header text as we are getting for row?
    please give some sample.
    Thanks,
    Vijay.
    Edited by: Vijayakumar Palanisamy on Jun 23, 2011 2:23 AM

    Hi John
    My exact requirement,
    1.     We have collection of records in adf table
    2.     Each cell in the row has commandImageLink (Like adding approver, edit approver, delete etc)
    Currently it’s working fine for me in the commandImageLink listener, but the problem is table is refreshed 2 time,
    while selecting a record and commandImageLink is clicked, I have to avoid 2 times refreshing,
    If it’s possible to identify a particular cell in the row selection, I can avoid the image link listener.
    we are using Jdeveloper11.1.1.4.0
    Please suggest.
    Thanks,
    Vijay

  • Getting the selected row (selected using radio button in dataTable)

    I have problem getting the selected row.
    If not mistaken, the way used in BalusC's website sets the value to the backing bean using the valueChangeListener.
    Can I set the value to the DTO instead?
    using something like
    private boolean selected;
    public void setSelectedItem(ValueChangeEvent e){
    this.selected = true;
    }  If i use this way it throws NoSuchMethodException. I have no idea why. I did this for the checkbox and it works fine. I don't know why it doesn't work for radio buttons.

    The DataTable is below :
    <h:panelGrid columns="1" columnClasses="table_align">
              <t:dataTable id="table1" value="#{sysMgrBean.locationList}"
                   var="location" rows="5" styleClass="table" headerClass="tableHeader"
                   rowClasses="tableRowOdd, tableRowEven" width="500">
                   <t:column>
                        <f:facet name="header">
                             <h:outputText styleClass="lbl" value="#{lbl['no']}" />
                        </f:facet>
                        <h:outputText value="#{location.id}" />
                   </t:column>
                   <t:column>
                        <f:facet name="header">
                             <h:outputText styleClass="lbl" value="#{lbl['slct']}" />
                        </f:facet>
                        <h:selectOneRadio  value="#{location.selected}"
                             onfocus="dataTableSelectOneRadio(this);"
                             onclick="enableInput(this.form,this)" valueChangeListener="#{location.setSelectedItem}">
                             <f:selectItem itemValue="" value="true" />
                        </h:selectOneRadio>
                   </t:column>
                   <t:column>
                        <f:facet name="header">
                             <h:outputText styleClass="lbl" value="#{lbl['cd']}" />
                        </f:facet>
                        <h:outputText value="#{location.loccd}" />
                   </t:column>
                   <t:column>
                        <f:facet name="header">
                             <h:outputText styleClass="lbl" value="#{lbl['desc']}" />
                        </f:facet>
                        <h:inputText id="Description" value="#{location.descr}" disabled="#{location.disabled}" />
                   </t:column>
              </t:dataTable>In the DTO :
    private boolean selected;
    public void setSelectedItem(ValueChangeEvent e){
    this.selected = true;
    }

  • How to get the current selected column and row

    Hi,
    A difficult one, how do i know which column (and row would also be nice) of a JTable is selected?
    e.g.
    I have a JButton which is called "Edit" when i select a cell in the JTable and click the button "Edit" a new window must be visible as a form where the user can edit the a part of a row.
    Then the column which was selected in the JTable must be given (so i need to know current column) and then i want the TextField (the one needed to be edited) be active with requestFocus(). So it would be
    pricetextfield.requestFocus();
    Problem now is that i have to click every time in the window the JTextField which was selected in the JTable. I have chosen for this way of editing because my application is multi-user and it would be too difficult for me when everybody did editing directly (catch signals, reload data, etc.).
    My question is how do I know the current column and the current row in a JTable?

    I'm not sure what your mean by the "current" row or column, but the following utility methods return
    which row and column have focus within the JTable.
    public static int getFocusRow(JTable table) {
        return table.getSelectionModel().getLeadSelectionIndex();
    public static int getFocusColumn(JTable table) {
        return table.getColumnModel().getSelectionModel().getLeadSelectionIndex();
    }

  • Get the icon for the current row selected

    Hi !!
    I am using jdeveloper 11.1.1.5
    I had dragged and dropped my ApplBusFunVO as a af:tree
    My Output will look like this
    Supplier Balance
    Supplier Document Details
    Purchase order
    Purchase ReceiptsMy af:tree doesnt contains the Parent
    My Scenario:
    When my user clicks the current node of the tree!! an icon should appear before the current node is selected
    For Eg: If my user clicks the Purchase Order then my output should like this
    Supplier Balance
    Supplier Document Details
    ==>Purchase order
    Purchase ReceiptsThe Symbol ==> Represent the icon! that appears before the purchase order!!

    Hi
    <af:tree value="#{bindings.SalesPeople.treeModel}" var="node"
              selectionListener="#{bindings.SalesPeople.treeModel.makeCurrent}"
              rowSelection="single" id="t4" fetchSize="35">
              <f:facet name="nodeStamp">
                 <af:group>
                      <af:image id="cl3" source="#{reference_to_image_url}"
                      rendered="#{check_if_current_row}"/>
                      <af:outputText id="ot2" value="#{node}"/>
                 </af:group>
       </f:facet>http://docs.oracle.com/cd/E23943_01/apirefs.1111/e12419/tagdoc/af_image.html
    As mentioned in a previous answer to this very same question, the tree is a stamped component which means that you need to partially refresh the tree component to show the icon. You can us the selectionListener (override the current setting to use a managed bean setting the current row - calling the same EL) to determine the new selected row key and then use the rendered option to determine (using a managed bean reference) if the current rendered node (#{node} is accessible from a managed bean at render time) is the selected node.
    The side effect is that upon tree node selection the tree will "flicker"
    Frank

  • Check box als column in a standard table, how to get the selected row

    Dear experts,
    I habe standard tablt with check box as column. Now I want to get the current selected row structure and do some changes. How could I solve this problem? till now I just know to get the structure via lead selection.
    lo_node->get_element().
    lo_element = lo_node->get_static_attributes ( static_attributes = ls_row).
    How could I get the element through check-box in stead of lead selection. Many thanks!

    check this code
    To get the selected row number
    data: lr_element type ref to if_wd_context_element,
              lv_index type i.
      lr_element = wdevent->get_context_element( name = 'CONTEXT_ELEMENT'  ).
      lv_index = lr_element->get_index( ).
    Thanks
    Bala Duvvuri

  • How to get the current JSF phase in backing bean?

    How to get the current JSF phase in backing bean?
    Edited by: jimmy6 on Nov 27, 2007 7:27 AM

    I am using phasetracker to trace it also.I want to know whether it is it render response phase. I know FacesContext.getCurrentInstance().getRenderResponse() work for normal jsf component but it will not work for qiupukit datatable. FacesContext.getCurrentInstance().getRenderResponse() will not return true in the following phase. Why?
    [ INFO] 27-11-07 16:20:21 : BEFORE RENDER_RESPONSE(6) (http-80-Processor23)
    I want the 'get' method of datatable being called in response phase to reduce the number of calling because i put the query in 'get' method there. Actually i still straggling with the best practice to code the datatable...

  • Change the current row in an iterator and reflect the change on page

    Hi there,
    I have a jspx with a creation form created as usual draging and droping the data control. In same page, I inserted a commandButton which ActionListener executes a method in a managed bean called validate(). Through such a method what Im trying to do is to fill the form with data from specified entry of the database if certain condition is true. I know it is kinda twisted but unfortunately is the requirement for the page.
    So basically in "validate" method, if the condition I mentioned is reached, I do the following:
    // execute a Rollback (included in Page Definition) in order to cancel the previous auto-invoked "Create".
    FacesContext context = FacesContext.getCurrentInstance();
    Application app = context.getApplication();
    BindingContainer bindings =(BindingContainer)app.getVariableResolver().resolveVariable(context,"bindings");
    OperationBinding opBinding = bindings.getOperationBinding("Rollback");
    opBinding .execute();
    //get the iterator and asociated VO from the binding container
    ValueBinding vb = app.createValueBinding("#{bindings.AccountsVOIterator}");
    DCIteratorBinding dciter = (DCIteratorBinding) vb.getValue(FacesContext.getCurrentInstance());
    ViewObject view = dciter.getViewObject();
    //and set the current row with the specified entry I have mentioned above.
    Object keyValues[] = new Object[2];
    keyValues[0] = "1"; keyValues[1] = "98543";
    Row[] row = view.findByKey(new Key(keyValues),1);
    AccountsVpnVORowImpl client = (AccountsVpnVORowImpl)row[0];
    view.setCurrentRow(client);
    view.executeQuery();
    dciter.setCurrentRowWithKey(client.getKey().toStringFormat(true));
    dciter.executeQuery();
    opBinding = bindings.getOperationBinding("Execute");
    opBinding.execute();
    All this works perfectly when I debbug it but I cannot see the changes in the page(even refreshing browser). I need that when such a condition is met, the creation form turns into a modify-specific entry form, filling all fields with the specific data in order user can modify it, and all in the same page.
    Any clue?
    Thanks so much in advance for your time.

    Hi,
    I could see the problem with call to executeQuery and execute methods at the end of your method which re-sets the current row.
    Once you set the current row you should not call execute or executequery methods. Try removing those calls and also make sure that you have added partialTriggers property on the table is set to commandbutton id and partialSubmit property is set to true on commandButton to refresh the table partially on click of a button
    Sireesha

Maybe you are looking for