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

Similar Messages

  • How to change the text for the tabs of a tabstrip control dynamically

    Hi Guys,
        I am having two screens in a transaction.
    1. 1st screen has material number as an input and submit push button
    2. 2nd screen has two tabs in a tabstrip control.
        I want to display material description and plant number as heading for the two tabs based on the material number entered by the user in the 1st screen. Means i want to change the text dynamically. Is there any possible way? If it is there please help me. Very urgent...
    Thanks in advance
    James.

    Hi,
    If you set the "Output field" attribute for a pushbutton/tab, you can also set its text dynamically in the ABAP program. To do this, you must create a field in the ABAP program with the same name as the pushbutton/tab. You must then assign the required text to the field before the screen is displayed.
    For example define a global field in your program called MATNUM(20) and use this as the name for the material number tab on the tabstrip. Then you can assign a text MATNUM = 'Material Number' and this will appear as the tab title. Don;t forget to set the "Output field" attribute on the tab.
    Hope it helps

  • How do I add text and edit my PDF file?

    how do i add text and edit my pdf file

    Hi pilothorse,
    To edit a PDF file you need to use Acrobat. If you don't have Acrobat, you can try it for free for 30 days. See www.adobe.com/products/acrobat.html for more information.

  • How to write Select statement for this codition

    I need to check whether SGTXT contains BELNR value.
    SGTXT is a text field and It should be matched with BELNR
    How to write select statement for this.
    Select AUGBL AUGDT into t_BSAD
    from BSAD
    where SGTXT should have the given BELNR Value.
    Plz note : Here I cannot give as SGTXT = BELNR as coz BELNR have only 10 digits.

    Hi,
    data temp(12).
    concatenate '%' belnr '%' into temp.
    Select AUGBL AUGDT into t_BSAD
    from BSAD
    where SGTXT like temp.
    If belnr is having multiple values,just create a internal table as follows.
    types : begin of ty,
            belnr....
            temp(12),
            end of ty.
    data itab_ type standard table of ty.
    data wa type ty.
    loop at itab into wa.
    concatenate '%' wa-belnr '%' into wa-temp.
    modify itab from wa index sy-tabix transporting temp.
    endloop.
    Change your select statement accordingly.
    Kindly reward poits if it helps.

  • How to create Selection texts in a generated program

    Hi there,
    Can anybody give me any hint of how can we create selection texts for any selection screen element where the selection screen itself will be generated via some other program?
    Thanks in advance.
    Best Regards,
    Deb.

    Hi debkumar,
    1. The Important thing is
    NAME of the screen element.
    eg. name is XYZ.
    then we can access it in program like this :
    %_XYZ_%_app_%-text = 'Hello Sir'.
    (Please note the FORMAT - Its important)
    3. try this code (just copy paste in new program)
    IT WILL CHANGE TEXT OF RADIO BUTTONS
    WHEN PUSHBUTTON IS CLICKED.
    REPORT abc.
    PARAMETERS : abc RADIOBUTTON GROUP g1,
    xyz RADIOBUTTON GROUP g1.
    SELECTION-SCREEN : PUSHBUTTON /15(25) pb USER-COMMAND pp .
    ABC, XYZ
    AT SELECTION-SCREEN .
    IF sy-ucomm = 'PP'.
    %_abc_%_app_%-text = 'Hello Sir'.
    %_xyz_%_app_%-text = 'How are u ?'.
    ENDIF.
    regards,
    amit m.

  • How to define the texts for UI element Dropdownlistbykey?

    Hi everyone,
      I don't know how to define the texts for Dropdownlistbykey. It seems that Dropdownlistbykey has an attribute "selected key", but where can I bind the texts I want to display when user clicks the downwards
    arrow?
    Thanks in advance.

    hi,
    you can use this code :
    method WDDOINIT .
      DATA : node_info TYPE REF TO if_wd_context_node_info,
             value1 TYPE wdy_key_value,
             set TYPE wdy_key_value_table,
             k1 type string value 'M',
             v1 type string value 'MAGO',
             k2 type string value 'S',
             v2 type string value 'Saurav'.
      value1-key = k1.
      value1-value = v1.
      APPEND value1 to set.
      value1-key = k2.
      value1-value = v2.
       APPEND value1 to set.
    node_info = wd_context->get_node_info( ).
    node_info = node_info->get_child_node('FOR_DROP').
    node_info->set_attribute_value_set( name = 'DROP_KEY'   value_set = set ).
    I hope it helps.
    Thanx.

  • How to invoke alt-text for images in a PDF file by Automation

    Hi,
    Can any one help me?
    How to invoke Alt-text for Images in a PDF file using script?
    Thanks for looking into this.
    Regards,
    Sudhakar

    What do you mean "invoke" alt-text?  If Alt-text is there, then it will be presented to a screen reader.

  • HOw to  find the text for PERSK field in infotype 0001

    hi all
    HOw to  find the text for PERSK field in infotype 0001

    Hi
    T503T : contained the similar informative text for PERSK . read this for T503T-PTEXT.
    ..lakhan

  • How to Lock a Transaction for Editing AND VERY minor tab cont. help

    Just two things I need to ask about
    <b>1. How to Lock a Transaction for Editing</b>
    I am currently using the fcode ENQUEUE_E_TABLE. The function works as once the transaction in opened, another cannot access it.
    However, I have two modes in my transction (Display and Edit). <u> What I need to do is If another user has already opened the transaction, the other user can still access the transaction but cannot access the edit mode.</u>
    <b> 2. VERY minor tab cont. help </b>
    I noticed in a table control is being used in a transction you can resize a colunm. <u> How do you disable this </b>?
    and <u> how do you resize the horizontal scroll bar </u> so that you can limit scrolling upto the point where there are field columns?
    Thanks for you help ppl and take care

    Hi chad,
    This link will help u know abty different types of locks that are available:
    http://help.sap.com/saphelp_erp2005/helpdata/en/7b/f9813712f7434be10000009b38f8cf/frameset.htm
    For resizing all u can go to the table settings and u can do it.
    Hope tis helps u,
    Regards,
    Nagarajan.

  • Hi..how we enter standard text for smartform using include text

    hi
    guru
    ..how we enter standard text for smartform using include text..
    i know only using so10 we write text..
    in smartform it asking text-object
                                     text-id,
    so what values we should give to get text

    Hi,
       Do u want to print Standard Text or the Texts that are maintained at the Transaction level.
    If it is standard text , then u use text id as ST or if it is Texts that are maintained at the Transaction level then u have to go to that specific transaction and check for that text , then go to text editor ,in the goto menu u have header data where u get the Text id , text name.... , use them in ur smartform in the INCLUDE text.
    Further u have the option of text modules in smartforms which act as standard texts, so if u r going for creation of standard texts then its better to use text modules.
    Regards,
    Shafivullah Mohammad

  • 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:

  • I have enhanced standard master datasource , How to load the Text for it?

    Hi Experts,
    I had enhanced 0MATERIAL_ATTR with ZTGRM field.User exit is written and the data is populated and checked in RSA3.
    Replicated,loaded in BW side.Activated the master data.It shows only the attribute not the text.
    Tried loading 0material_text and loaded successfully, activated but while maintaining the master data , i can able to see only the attribute values not the text.
    Can any one help how to load the text for the enhanced attribute?
    Thanks in advance
    Ganesh Kumar

    Hi Tony,
    Loaded the 0MATERIAL_TEXT ,also sucessful.
    After loading activated the 0material but i could only see values for 0material_attr not for the 0material_text.
    Can you tell me how to load the text data to the newly enhanced attribute???

  • How do I select texte discontinuouly : one word here and another there

    How do I select texte discontinuouly : one word here and another there, etc.

    Use Pages '09.
    Feature has been removed from Pages 5, along with 100+ others.
    Peter

  • How to change the stsndard selection text for a LDB..

    Hi All,
        I am using a LDB selection screen. I want to change the selection text of the standard selecetion field.
    For ex, for LDB- PNP, i want to change the 'Personnel number' text to 'Employee ID'...
    Please let me know how to do this.
    Regards
    Nanda

    Hi Nanda,
    Here is the code which is exactly suitable for this req.
    TABLES: pernr.
    data: i_tab type standard table of RSSELTEXTS with header line.
    initialization.
    i_tab-name = 'PNPPERNR'.
    i_tab-kind = 'S'.
    i_tab-text = 'Employee ID'.
    append i_tab.
    CALL FUNCTION 'SELECTION_TEXTS_MODIFY'
      EXPORTING
        program                           = 'ZESO_TEST'
      tables
        seltexts                          = i_tab
    EXCEPTIONS
      PROGRAM_NOT_FOUND                 = 1
      PROGRAM_CANNOT_BE_GENERATED       = 2
      OTHERS                            = 3
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    Thanks
    Eswar

  • How to mofidy the selection text for a report

    Dears,
    Do you know how to modify a selection text in the selection screen of a standard report, such as changing "Storage Location" in the selection screen of report MB5B to "storage Loc"?
    one of a way to realize it is to modify the text of relevant data element.
    except modifying the data element directly, It seems that use SE63 could do it, but I forgot how to use it.
    Thanks all for your reply.
    Zhongkai

    Hi Liu,
    Check this link for translations thru SE63:
    http://help.sap.com/saphelp_sm310/helpdata/en/b4/54601d77f38e429ffad9e3e11c1b25/content.htm
    Hope this helps you.
    Regards,
    Chandra Sekhar

Maybe you are looking for

  • Why do BT keep slowing down my broadband?

    I am currently getting 232kbps download speed! For £15.99 a month! The engineer who came the last time this happened said that the exchange monitor and alter your profile constantly. Well they've done it again. This is really taking the micky. I had

  • NW 7.20 upgrade using SUM error with SQL

    Hi All, I am in the process of upgrading a client from NW 7.20 to 7.40. I have successfully done so with the DEV environment, but i seem to be having issues with the QA server. SQL 2008 R2 is a distributed installation and resides on a different serv

  • 3D graphs

    Hello, I would like to know whether it is possible to plot more than one plot in a 3D waveform graph. If so, kindly include a sample code. Thank you

  • How to read document with Adobe

    I Have a MacBook Air. Operating system is 7.01, I think. I need to read document I'D f.  Ihave adobe loaded, but Cannot read the document.  Help?

  • COD (call of duty 4) freezes on new mac mini - Lion

    I hope someone can provide me some guidance.. I just got my brand new mac mini with the following specs: 2.5 ghz (i5) 8GB RAM DDR3 AMD Radeon HD 6630M 256MB OSX Lion 10.7 When i play COD online in multiplayer mode (and only then) after about 2 minute