How to programatically select a row in TableBean and update its column?

Hi,
Can anyone help me on How to programmatically select a row in a TableBean and update its column?
Thanks,
Jon

Hi,
My requirement is I need to update a column in a particular row of the table using fire action...
I have a datefield bean serve as birhdate and base on this I need to update the age column depending on the given dates..
Here's my code under the Process form request for your reference...
if (actionInMainPersonScreen.equals("changeDate"))
String checkId = pageContext.getParameter("paramDatePersonId");
OAFormValueBean depPerId = (OAFormValueBean)depTable.findIndexedChildRecursive("ChildPersonID");
OAMessageTextInputBean depFName = (OAMessageTextInputBean)depTable.findIndexedChildRecursive("FirstName");
OAMessageDateFieldBean dateBirth = (OAMessageDateFieldBean)depTable.findIndexedChildRecursive("BDay");
OAMessageStyledTextBean age = (OAMessageStyledTextBean)depTable.findIndexedChildRecursive("Age");
Date changeBDate = new java.util.Date();
Date dateToday = new java.util.Date();
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);
changeBDate = (Date)dateBirth.getValue(pageContext);
Calendar cal = Calendar.getInstance();
ResultSet empAge = null;
String newAge = null;
OADBTransaction trans = personam.getOADBTransaction();
System.out.println("BirthDate: " + changeBDate + " Date Today: " + sdf.format(dateToday));
String expQuery = "SELECT Trunc((sysdate - To_Date('" + pageContext.getParameter("paramDateBirth") + "'))/365) compAge, Sysdate from dual";
System.out.println("SQL: " + expQuery);
PreparedStatement expPreparedStatement = trans.createPreparedStatement(expQuery ,1);
try
empAge = expPreparedStatement.executeQuery();
} catch (SQLException e) {}
try
while (empAge.next())
newAge = empAge.getString("compAge");
age.setText(pageContext, newAge);
empAge.close();
} catch (SQLException e) {}
regards,
Jon

Similar Messages

  • How to programatically select text for editing in an af:inputText control?

    Hello, I am new to jdeveloper 11.1.1.3.0 and have searched and searched for info. I must be using the wrong terms as I cannot find any info or example on how to programatically select text for editing in an inputText field.
    My request is to change an existing app so when the user presses a button, control should go to the inputText control (this part works, see existing backing bean code from another developer below) but automatically select the text within for editing by the user (saving the user from having to select the text first before editing).
    Backing bean code to set the focus to an inputText field:
    * sets the cursor to the given component id
    * @param  componentId of item on page
      public void setFocusOnUIComponent(String componentId) {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        ExtendedRenderKitService service =
          Service.getRenderKitService(facesContext, ExtendedRenderKitService.class);
        UIComponent uiComponent = facesContext.getViewRoot().findComponent(componentId);
        service.addScript(facesContext,
          "Component = AdfPage.PAGE.findComponentByAbsoluteId('" + componentId + "'); Component.focus();");
      } I hope this isn't a dumb question and would appreciate it if someone can steer me in the right direction.
    Thank you for any info,
    Gary

    Hi,
    not a dumb question at all. Before answering it, here some comments on the code you pasted in your question
    1. UIComponent uiComponent = facesContext.getViewRoot().findComponent(componentId);
    This code line is not used at all in your method. So it seems you can get rid of it
    2. "Component = AdfPage.PAGE.findComponentByAbsoluteId('" + componentId + "'); Component.focus();");
    I suggest to change it to
    "var component = AdfPage.PAGE.findComponentByAbsoluteId('" + componentId + "'); component.focus();");
    as it is better coding practice to have variable names starting with a lower case letter and being flagged with the "var" identifier
    For pre-selecting text in an an input component, there is no API available in ADF Faces, which means you need to reach out to the rendered HTML ouput. To access the markup for the rendered component, you can try
    var markup = AdfRichUIPeer.getDomContentElementForComponent(component)
    If this markup returns the HTML input component then you can use JavaScript you find on the Internet to select the area of it. If it does not return the input component then you may have to use
    document.getElementById(componentId+'::content')
    Note however that working directly with generated HTML output bears the risk that your code breaks when - for whatever reason - the ADF Faces component rendering changes in the future
    Frank
    Frank

  • HorizontalList - How to programatically select an item

    Hi All,
    I am new to flex and new to this forum. I am building an
    application that uses a HorizontalList and a button.
    When the button is clicked, I need to add a new item (image +
    label) on the HorizontalList, and I need to make the newly added
    item the default selection.
    I tried to set the selectedIndex property, but that does not
    work.
    Any idea how to make this work ? ie how to programatically
    select an item in the HorizontalList
    Regards
    Roni

    This code seems to do what you want:

  • TS4436 How do I select more than one picture and send them all to Facebook on my iPhone 4s with iso7?

    How do I select more than one picture and send them all to Facebook on my iPhone 4s with iso7?

    Hi, I want to thank you for all your information regarding my questions about sending more than one photo to Facebook. I did have to stop in at Verizon (where I bought my iPhone) to find out why I did not have a choice to choose Facebook with the export icon. The tech had to go into my setting and enable Facebook to recognize my iPhone. When I upgraded to iso7 somehow it could not recognize Facebook. Once he did this for me I was able to follow your advice and your answer solved my question. Thank you

  • How to write select statement before the loop and how to use read statemnt

    Hi,
    Recently our system has changed from 4.6 to ECC6.
    As its migrated its showing lots of errors like in between loop and endloop there should be no select statemnt........
    Can any one please tell how to write that coding in ECC6 , how can i change the code......
    In between loop and endloop i am having lots of select statemnts.....ple tell thye coding how can i select before the loop starts and
    how to read that internal table in loop.

    Hi Deepthi,
    You can do as per below:
    1) Select the required entries from the tables you need (VBAK, VBAP, KNA1, etc)
    SELECT VBELN ERDAT KUNNR
        into table it_vbak
        from VBAK
    where VBELN = S_VBELN. "Selection criteria
    If sy-subrc = 0.
    SELECT VBELN POSNR MATNR
        into table it_vbap
        from VBAP
    for all entries in it_vbak
    where VBELN = it_vbak-vbeln
    SELECT KUNNR NAME1
        into table it_vbak
        from VBAK
    where VBELN = it_vbak-vbeln.
    endif.
    2) Loop at the entries, and read internal table it-kna1 for customer info.
    Loop at it_vbak into wa_vbak.
    read table it_kna1 into wa_kna1 with key kunnr = wa_vbak-kunnr.
    if sy-subrc = 0.
    endif.
    loop at it_vbap into wa_vbap where vbeln = wa_vbak-vbeln.
    endloop.
    endloop.
    This is the basic idea and short example of how to extract entries and read internal table.
    Hope this helps.
    Regards,
    Patrick

  • I have an 8500a how, once I select the apps I want and add to the printer. How do i get them to wor

    I have an 8500a how, once I select the apps I want and add to the printer.  How do i get them to work? And is it always this slow....

    Hey jmknights!
    While I can't speak to how quickly the apps will work, I may be able to help you with how they work. Once you have the apps added to the printer you would select the app you want to print from on the printer's front panel. Once inside the app, select what you want to print and if all goes as it should, the printer should begin printing the requested information within a few seconds.
    Hope this helps!
    If I have solved your issue, please feel free to provide kudos and make sure you mark this thread as solution provided!
    Although I work for HP, my posts and replies are my own opinion and not those of HP.

  • How to call a idoc in abap program and updates catsdb table

    how to call a idoc in abap program and updates catsdb table
    thank you,
    Jagrut BharatKumar Shukla

    Hi Kishan,
    You can refer to following help document,
    http://help.sap.com/saphelp_nw04/helpdata/en/bf/d005244e9d1d4d92b2fe7935556b4c/content.htm
    Regards,
    Meera

  • How to use KAUF_AUFNR_CHANGE  to change Process order and Update a field

    Hello ,
    I am working on 4.6C system and I hve a requirement to change Process order and Update a field value passed from a ABAP Program. I am looking for suitable Function modules or Bapi ( available in 4.6c) .
    I have come across FM KAUF_AUFNR_CHANGE . Would appreciate any guidance on how to use the FM in my program and Update a field in the Process order.
    Many Thanks!

    All the importing parameters of this function module have a striaght structure of the transperent tables...
    i have checked the code and it has a modify statement based on the importing parameter..
    pick one record in databas and pass it to the importing parameters, with some values changed...
    i think that should work
    what values  to pass the import values of FM -KAUF_AUFNR_CHANGE.
    Edited by: ssm on Aug 4, 2011 7:19 PM

  • How can I select the row after a cfgrid refresh?

    I have a form that is bound to a cfgrid.  The grid is populated from a database.  When you navigate in the grid the data displayed in the form changes to match the selected row.  I can edit the data in the form and update the database.  After updating the data I refresh the cfgrid, which then displays the updated data.
    Unfortunately the cfgrid always highlights the first row, row 0, after a refresh.  I want to highlight the same row that was highlighted when the data was edited and saved.  Can anyone advise as to how I can do that?
    I have tried setting a listener when the grid is initiated that responds whenever the store is refreshed and triggers the function refreshSelection():
    g.getStore().on('load', refreshSelection) ;
    Before the form data is saved, the row number is stored in selectedRow[0].  When the grid is refreshed, refreshSelection is run:
    function refreshSelection() {
    if (0 >= selectedRecords.length)
         return;
    alert('Selected row is Row ' + selectedRecords[0] ) ;
    g.getSelectionModel().selectRow(selectedRecords[0]) ;
    selectedRecords[0] = 0 ;
    The alert shows the correct row number each time, but highlighting the last row viewed works intermittently, and only if the alert line is active.  If I comment out the alert, this fails every time, with row 0 being highlighted.  selectedRecords[0] is reset to 0 after the attempt to select the row so that navigation through the grid, such as choosing "Next Page," will properly highlight the first row of the page rather than the last row number that was edited.
    -Rick

    Massage?
    Why not ask the masseuse who gave you the massage?

  • How do I select a row from the middle of a recordset?

    UserID QuestionID Answered
    10 9 N
    10 8 N
    10 7 N
    10 6 N
    10 5 Y
    10 4 Y
    10 1 Y
    From the table sorted by QuestionID DESC, how do I select the first row from the bottom going up with Answered value equal to 'N'?
    Which in the example above would be:
    10 6 N
    I need to select this row and get the QuestionID value equal to 6.
    Right now I have:
    select QuestionID
    from tblMap
    where Answered = 'N'
    and ROWNUM = 1
    order by QuestionID ASC;
    This always the top most row, which would be:
    10 9 N

    Here i used DUAL to generate a list of numbers for me.
    ME_XE?select *
      2  from
      3  (
      4     select row_number() over (order by col1 desc) as rn, count(*) over() as cnt, col1
      5     from
      6     (
      7        select level as col1 from dual connect by level <= 9
      8     )
      9  )
    10  where ceil(cnt/2) = rn
    11  /
                    RN                CNT               COL1
                     5                  9                  5
    1 row selected.
    Elapsed: 00:00:00.07
    ME_XE?Edited by: Tubby on Jul 8, 2009 1:47 PM
    Seems i misread the question :)

  • How do i select a row when a table is loaded?

    Hello Guys
    could somebody help me? I'm new to ADF and I'm trying to make a SearchPage. It works but I get this behavior:
    #1: I bound the Table with the ResultSet of a EJB-SessionBean find-Method. When the SearchPage is loaded, a the SessionBean-find-Mehod is called. I want, that the Table only shows the ResultSet when the CommandButton "Search" is clicked not on PageLoad.
    #2. In the ResultSet shown in the table no row is preselected. How can i change that?
    # 3. The Table is placed in a TabbedPanel in a showDetailItem "SearchResult". After i select a row I want to show the Details of the selected row-Object in anoteher showDetailItem "Details". How could i handle that?
    Thnx a lot for your Help!

    Hello Frank,
    thank you for responding!
    #1) I tryed #1 but i got the Exception Illegal . I followed the steps you recommended as follow:
    a) On the button "Search" add an af:setPropertyListener. It looks like this:
    <af:commandButton actionListener="#{bindings.getDelegateFindAllBySearchCriteria.execute}"
    text="Suche starten"
    disabled="#{!bindings.getDelegateFindAllBySearchCriteria.enabled}"
    id="cb1" inlineStyle="margin-left:8px;">
    <af:setPropertyListener from="#{true}" to="#{viewScope.executeOK}" type="action"/>
    </af:commandButton>
    b) Have the RefreshCondition property on the iterator in the pageDef file looking for a memory flag e.g #{viewScope.executeOk==true?true:false}. In the ExpressionBuilder I get "#{adfFacesContext.viewScope}" but not #{viewScope}
    I got an error message writing this in de pageDefinition. It accepted: #{viewScope.executeOk==true}. It is right, if TRUE -> TRUE, if FALSE -> FALSE
    The compiler says: "executeOK is an unknown property"
    After that i started the Application and got an
    <14.04.2011 16:59 Uhr MESZ> <Error> <HTTP> <BEA-101020> <[ServletContext@17109869[app:EHRCPD_PISA_TT module:EHRCPD_PISA_TT-ViewController-context-root path:/EHRCPD_PISA_TT-ViewController-context-root spec-version:2.5]] Servlet failed with Exception
    java.lang.IllegalStateException
         at oracle.jbo.uicli.binding.JUSearchBindingCustomizer.getViewCriteria(JUSearchBindingCustomizer.java:2161)
    #2) I set DisplayProperty to "selected" but it did not works. I checked the rows (they are 2) but they are the same. If i debbug the application i see, that the resultSet got from the Database (JPA) is OK. The size of the resultSet is 2 and the Objects retrieved are different. What i'm doing wrong?
    #3) This worked perfectly! Thank you!
    I hope, I get this working.
    Thnx again

  • How to programatically select different JTable cells

    Dear all,
    I need to programatically select different JTable cells.
    I have to make the inverse selection. So if the user has a table of one column and 10 rows, and selects rows 3,6,8, the inverse selection should select all the other remainig cells and deselect 3,6, and 8.
    I tried using the following but it does not work ?
    for (int i = 0; i < table.getRowCount(); i++) {
    table.changeSelection(i, 0, true, false);
    Hope someone can help.
    Regards,
    Kanita

    Dear all,
    I need to programatically select different JTable cells.
    I have to make the inverse selection. So if the user has a table of one column and 10 rows, and selects rows 3,6,8, the inverse selection should select all the other remainig cells and deselect 3,6, and 8.
    I tried using the following but it does not work ?
    for (int i = 0; i < table.getRowCount(); i++) {
    table.changeSelection(i, 0, true, false);
    Hope someone can help.
    Regards,
    Kanita

  • How can i select some row from multiple row in the same group of data

    I want to select some row from multiple row in the same group of data.
    ColumnA        
    Column B
    1                  OK
    1                   NG
    2                   NG
    2                          NG
    3                          OK
    3                          OK
    I want the row of group of
    ColumnA if  ColumnB contain even 'NG'
    row , select only one row which  Column B = 'NG'
    the result i want = 
    ColumnA         Column B
    1                         NG
    2                   NG
    3                          OK
    Thank you

    That's some awful explanation, but I think this is what you were driving at:
    DECLARE @forumTable TABLE (a INT, b CHAR(2))
    INSERT INTO @forumTable (a, b)
    VALUES
    (1, 'OK'),(1, 'NG'),
    (2, 'NG'),(2, 'NG'),
    (3, 'OK'),(3, 'OK')
    SELECT f.a, MIN(COALESCE(f2.b,f.b)) AS b
    FROM @forumTable f
    LEFT OUTER JOIN @forumTable f2
    ON f.a = f2.a
    AND f.b <> f2.b
    GROUP BY f.a

  • How to set selected all rows in h:dataTable

    hello, I want to selected all rows in a dataTable.
    I use JS to got it:
    the selectBooleanCheckbox in the header of row:
    <t:selectBooleanCheckbox id="aa" value="#{list.checkbox}" />the JS code :
    <script type="text/javascript" language="JavaScript1.2">
        function selectAll(obj, first, size) {
            for (var i = 0; i < size; i++) {
                var current = eval(first - 1 + i);
                var objs = document.getElementById("form:listbody:listtable:" + current + ":aa");
                obj.checked ? objs.checked = true : objs.checked = false;
    </script>and the "selectall" code:
    <h:selectBooleanCheckbox id="selectAll"
                                  onclick="javascript:selectAll(this,#{firstRow},#{displayedRowsCount})"/>It run good in IE,but not it does not work in firefox.
    Are there some method to do?
    Or is there a method to select all rows just use JSF?
    Needs you help!

    Yes, the paging for <h:dataTable> works pretty good, it manages the task through four methods created in the java code -- DataTable1_firstPageAction(), DataTable1_previousPageAction(), DataTable1_nextPageAction(), DataTable1_lastPageAction() -- without adding any javascript in the jsp page.
    Maybe I could test if a java script similar to the <ui:table>'s one fit also the dataTable...
    thanks

  • How to efficiently select random rows from a large table ?

    Hello,
    The following code will select 5 rows out of a random set of rows from the emp (employee) table
    select *
      from (
           select ename, job
             from emp
           order by dbms_random.value()
    where rownum <= 5my concern is that the inner select will cause a table scan in order to assign a random value to each row. This code when used against a large table can be a performance problem.
    Is there an efficient way of selecting random rows from a table without having to do a table scan ? (I am new to Oracle, therefore it is possible that I am missing a very simple way to perform this task.)
    thank you for your help,
    John.
    Edited by: 440bx on Jul 10, 2010 6:18 PM

    Have a look at the SAMPLE clause of the select statement. The number in parenthesis is a percentage of the table.
    SQL> create table t as select * from dba_objects;
    Table created.
    SQL> explain plan for select * from t sample (1);
    Explained.
    SQL> @xp
    PLAN_TABLE_OUTPUT
    Plan hash value: 2767392432
    | Id  | Operation           | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT    |      |   725 | 70325 |   289   (1)| 00:00:04 |
    |   1 |  TABLE ACCESS SAMPLE| T    |   725 | 70325 |   289   (1)| 00:00:04 |
    8 rows selected.

Maybe you are looking for

  • Satellite M100 - TFncKy crashing as soon as Windows logs on

    Been having this problem with only one of the user accounts on my M100, the other account doesn't have the problem. As soon as I am logged in to Windows a message pops-up that TFncKy has unexpectedly quit (send error report, don't send error report,

  • M4E with N73 - MS Exchange server 2007

    Hi Guys, maybe I am stupid, but I can't seem to get this thing to work, I have installed mail for exchange 2.3, finally the security setting is showing, I have approved the certificate but still I am getting the very general : "Error in Exchange serv

  • Problems opening pdf's in illustrator.

    When I open a pdf in illustrator, I get many individual objects and numerous squares that contain lots of information (like they have been flattened or merged).  I would really like to get the objects that make up these flattened or merged areas.  Ha

  • Ken burns and slidshows

    hi try to build a slidshow in imovie hd6 whenever i try to apply ken burns, after the rendering, the photo turns black any suggestions? thanks, frank

  • Clicking on Finder icon in Dock no longer opens new Finder window

    This behavior just started about a week ago. When I click on the Finder icon in the Dock, nothing happens, even though a new Finder window is supposed to appear. I have gone through the usual fix-its (deleting the Finder plist file, relaunching the F