SetFocus

How to set focus in inputText in table?
I have need solution for through servercode not javascript

First of all setFocus is the client side behaviour and there is no such property "focus" on RichInpuText component
there is a clientListener "focus" but its useless , because you need to have a focus to start with.
so, you have to use javascript, you can call your javascript from the jspx or you can call it from your backing bean [server-side]
if you want do setFocus from your backing bean ,
                StringBuilder script = new StringBuilder();
                RichInputText myInputText = getInputText();
                String inputTextClientId =  myInputText.getClientId();
                ExtendedRenderKitService service =
                    (ExtendedRenderKitService)Service.getRenderKitService(FacesContext.getCurrentInstance(),
                                                                          ExtendedRenderKitService.class);
                script.append("var inputText= document.getElementById('" + inputTextClientId+ "');");
                script.append("inputText.focus();");
                service.addScript(FacesContext.getCurrentInstance(),
                                  script.toString());you can have onload clientListener on document and you can focus your inputText at that time
<af:document binding="#{backingBeanScope.backing_KeyDown.document1}"
                 id="document1">
                 <af:clientListener method="onLoad" type="load"/>
<af:form binding="#{backingBeanScope.focusBean.form1}" id="form1">
        <af:inputText label="Label 1" clientComponent="true"
                      binding="#{backingBeanScope.focusBean.inputText1}"
                      id="inputText1"/>javascript
function onLoad(event) {
                document.getElementById("inputText1::content").focus();
                }regards,

Similar Messages

  • How can I add scroll bars to a textarea and setfocus at the end of the box.

    I didn't see a scrollbar option so I was wondering how would I add one? Also how can I setfocus to the last line in the textarea?

    You have to create a JScrollPane that will enclose the TextArea as in new JScrollPane (yourTextArea).
    You can setFocus to any Component and you can position the caret in an TextArea.
    Regards
    SH

  • Xfa.host.setfocus -- to an object e.g. picture or static text etc?

    I can get the setfocus to target another input field - but can work out how (or if it can) to get it to focus the screen to an image or static text component.
    The path selecton tool in the script panel just stays that impassive red circle
    issue arises as selections from radio group opens largish subform with focus set to it's first field - and given layout radio list is lost out the top of the screen (as it were) so we put in a "made the wrong choice? click here to go back" style of button on the top of each subform -
    as the radio button selection displays the subfields using the radiobuttons as the target does not work (get into an event loop)
    so we need something else to target off the go back - i was hoping the title graphic image or static text but cant work it out
    i though the documentation said focus could do images but i cant get it to,
    thanks for any pointers/code line

    Hi,
    I don't think you can focus on static objects (static text, static images).
    I think the down and dirty workaround is your best option. Maybe make the button very small (0.01in) and you can always place a static image (icon) over it to mask the button.
    N.

  • SetFocus in a control by default during pageload

    Hi,
    I am using flex builder 2.0. I want to setFocus on a textbox
    during pageload.
    I have tried to setocus on that control in the below two
    event's of a application object
    1. CreationComplete
    2. Activate
    But Cursor is not getting focus on that control after page
    load. When I have clicked the application
    using mouse then only that page is getting activation
    (Or)
    I have to press the tab to activate the page.
    Initially the browser controls(addressbar etc) are getting
    focus instead of webpage.
    How to overcome this issue. I want to setFocus after page
    loaded by Default on a particular control.
    Can anybody help me.
    Thanx in advance.
    With Regards,
    Mahendiran.K

    MahePya,
    First the credit goes to the gentlemen in the comments below.
    First, create a new folder in your Application called
    "actionScript". Then RIGHT CLICK the new folder you just created
    and create a NEW "ActionScript File". The FILENAME with my example
    must be "JavaScript", then click FINISH. Then COPY and PASTE the
    code below (please be sure to include the credit) and paste it into
    the JavaScript.as file you just created.
    STEP ONE: SELECT AND COPY THE CODE BELOW...
    /* JavaScript: A MXML component for embedding Javascript in
    container HTML
    * Author: Abdul Qabiz ([email protected])
    * Date: June 16, 2006
    * Version: 0.1
    * Copyright (c) 2006 Abdul Qabiz (
    http://www.abdulqabiz.com)
    * Permission is hereby granted, free of charge, to any
    person obtaining a
    * copy of this software and associated documentation files
    (the "Software"),
    * to deal in the Software without restriction, including
    without limitation
    * the rights to use, copy, modify, merge, publish,
    distribute, sublicense,
    * and/or sell copies of the Software, and to permit persons
    to whom the
    * Software is furnished to do so, subject to the following
    conditions:
    * The above copyright notice and this permission notice
    shall be included in
    * all copies or substantial portions of the Software.
    * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
    KIND, EXPRESS OR
    * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
    MERCHANTABILITY,
    * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
    NO EVENT SHALL THE
    * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
    DAMAGES OR OTHER
    * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
    OTHERWISE, ARISING
    * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
    OR OTHER
    * DEALINGS IN THE SOFTWARE.
    // This script sets the browser focus
    package actionScript
    import flash.events.Event;
    import flash.events.EventDispatcher;
    import flash.net.*;
    import mx.core.IMXMLObject;
    [DefaultProperty("source")]
    public class JavaScript extends EventDispatcher implements
    IMXMLObject
    private var _source:String;
    private var _initialized:Boolean;
    public function JavaScript()
    public function set source(value:String):void
    if (value!=null)
    _source = value;
    var u:URLRequest = new URLRequest ("javascript:eval('" +
    value + "');");
    navigateToURL(u,"_self");
    public function initialized(document:Object, id:String):void
    _initialized = true;
    STEP ONE: SELECT AND COPY END JUST ABOVE HERE!!!
    Then SELECT and COPY the following code and PASTE it into the
    opening tag of the mxml file that has the TextBox that you want to
    give focus. Fore example if the TextBox is in your main
    Application, then it should go into the opening tag of that file.
    If the TextBox is in a separate component it should go into the
    opening tag of that component. Here's the code...
    STEP TWO: SELECT AND COPY THE CODE BELOW...
    xmlns:actionScript="actionScript.*"
    creationComplete="setBrowserFocus();"
    STEP TWO: SELECT AND COPY END JUST ABOVE HERE!!!
    Next SELECT and COPY the code below and PASTE it just after
    the opening tag where your TextBox is located. Again if your
    TextBox is located in your main Application file then simply PASTE
    this code right after the the close of the Application tag. If your
    TextBox is located in a different mxml file then place the code
    after the opening tag in that file.
    STEP THREE: SELECT AND COPY THE CODE BELOW...
    <mx:Script>
    <![CDATA[
    import flash.external.ExternalInterface;
    private function setBrowserFocus():void
    ExternalInterface.call ("setBrowserFocus");
    usernameTextBox.setFocus()
    ]]>
    </mx:Script>
    <actionScript:JavaScript>
    <![CDATA[
    function setBrowserFocus()
    Main.focus();
    ]]>
    </actionScript:JavaScript>
    STEP THREE: SELECT AND COPY END JUST ABOVE HERE!!!
    The next step is to CHANGE the ID "usernameTextBox" in the
    setBrowserFocus function to YOUR TextBox ID and it should work. :)
    STEP FOUR: CHANGE usernameTextBox TO YOUR TEXTBOX ID (for
    example)
    private function setBrowserFocus():void
    ExternalInterface.call ("setBrowserFocus");
    usernameTextBox.setFocus() ***CHANGE "usernameTextBox"***
    STEP FOUR ENDS
    The final step is to CHANGE the name to the name of
    Application as shown below.
    STEP FIVE: CHANGE "Main" TO THE NAME OF YOU APPLICATION
    <actionScript:JavaScript>
    <![CDATA[
    function setBrowserFocus()
    Main.focus(); ***CHANGE "Main" to the name of you
    Application***
    ]]>
    </actionScript:JavaScript>
    STEP FIVE ENDS
    Let me know how this works for you. Be sure to click the
    "Mark as the answer!" link in my post if this is the correct
    solution. Be sure to check out the author link to see why we have
    to set the focus this way.
    John

  • Flex air datagrid setfocus cell by cell

    Hi all,
    I have a datagrid with custom itemRenderer. Now I need to setfocus int the grid cell by cell. For that I Googled & got a way i.e
    var findrowindex:int = 0;
    //nextButton Click Handler
    var focusedCell: Object = new Object();
    focusedCell. columnIndex = 3;
    focusedCell. rowIndex = findrowindex;
    dg.editedItemPosition = focusedCell;
    dg.validateNow( );
    findrowindex++;
    Using this I am able to get focus in a cell but the focus is not moving from one cell to another. Pls suggest me where I am going wrong or suggest me any ther way to achieve this.
    Thanks.

    You can call preventDefault on ITEM_EDIT_BEGINNING to cancel editing.  I
    suppose if you track the current selectedIndex on mouseDown and see if it
    changes by the time you get to ITEM_EDIT_BEGINNING you could do that.

  • SetFocus() in InteractionManager is not working?

    Hi,
    I'm trying to implement TLF in out chat application and looks like setFocus() command in InteractionManager has a bug. Here is a code demonstrating it:
    var tf:TextFlow = new TextFlow(); // define TextFlow and manager objects
    var em:EditManager = new EditManager();
    cc = new DisplayObjectContainerController(this, 290, 38);
    tf.interactionManager = em;
    // compose TextFlow to display
    tf.flowComposer.addController(cc);
    // add event handler to listen for SelectionEvent
    tf.addEventListener(SelectionEvent.SELECTION_CHANGE, selectionHandler);
    tf.addEventListener(StatusChangeEvent.INLINE_GRAPHIC_STATUS_CHANGED, graphicStatusChangeHandler);
    tf.flowComposer.updateAllContainers(); // update visual representation
    // format configuration
    var charFormat:CharacterFormat = new CharacterFormat();
    charFormat.color = me.colorsArray[me.currColor];
    charFormat.fontFamily = "Tahoma, _sans";
    charFormat.fontSize = 12;
    charFormat.lineHeight = "80%";
    tf.hostCharacterFormat = charFormat;
    tf.interactionManager.setSelection(0,0);
    var pf:ParagraphFormat = new ParagraphFormat();
    pf.direction = Direction.RTL;
    pf.marginLeft = 2;
    pf.marginRight = 3;
    pf.marginTop = 5;
    IEditManager(tf.interactionManager).applyParagraphFormat(pf);
    tf.interactionManager.setFocus();
    Actually I see a cursor appears on screen but when I enter the text I am unable to see it. When I'll click with my mouse on the text edit area I can able to enter the text. Tell me what I'm doing wrong. May be the problem is only for text area which is set to RTL user input?
    Looks like in the  online rich text editor demo you have exactly the same problem, when you switch text direction from LTR to RTL you can't enter the text until you click with your mouse on the text edit area.
    Igor Vasiliev
    www.blogtv.com

    The problem with the new one is a file size - when I'm trying to include new TLF library to my project I can't compile it in Flash CS4. Actually I had exactly the same problem with the old one too, but after a short investigation I found that the problem is a large amount of code I have in the existing project and I put several things to the external SWF file and now I'm able to compile and work with it. The new TLF library is twice big then the old one and I'm unable to compile it at all within my project. ;(
    Now, regarding the problem I posted here I think you have a runtime problem. Actually I found a solution, I just set focus with 500 milliseconds delay and now it works. Looks like when I make first call you updating something on the screen and can't set it for the first time.
    Personally I think the file size of the TLF library is the biggest problem now with Flash CS4. Looks like IDE unable to compile projects with a lot of code inside. I never saw this happens with old Flash CS3. ;(

  • Problem with setFocus function

    I create a function setFocus on a page with this code in the HTML Header area.
    <script language="JavaScript" type="text/javascript">
    <!--
    function setFocus(PageItem){
    document.getElementById(PageItem).focus();
    //-->
    On the HTML Body Attribute the code is
    onLoad="javascript:setFocus('P3_MY_ITEM');"
    When I execute the page whit this attributes it displays as blank.
    When I delete the code in the two areas, the page displays ok.
    What is possible that happend?

    Hello Ikefur,
    I suspect one problem is you are missing a closing } in your function. Another is it doesn't appear you're closing your script tag.
    Also, once you know your code is correct, be sure to set Cursor Focus for the page to "Do not focus cursor".
    Hope this helps,
    John

  • Missing method "setfocus"

    I'm getting the Error: hostPsuedoModel does not have a method 'setfocus'   do we have something installed wrong.  Designer version, 8.2.1.....

    Check the spelling in your code, setfocus should be setFocus.

  • Xfa.host.SetFocus question.

    I have a code on Exit event of the field that checks if 5 digit US ZIP code, 5 digit US ZIP code + 4, and 6 digit alphanumeric Canadian Postal Code.
    If user enters valid 5 digits code, then I set focus to specific field-FField1. Code is simple and it works. What does not work is, if I tab out , without entering anyting in the Zip code, the focus is set to some other field, not FField1. How can I force it with the code that focus is set to FField1 all the time.
    Code is simple:
    var regExpDate = /^\^\d{5}-\d{4}|\d{5}|[A-Z]\d[A-Z] \d[A-Z]\d$ $/;
    var vMatched = this.rawValue.match(regExpDate);
    if (!vMatched){
    this.rawValue=null;
    xfa.host.messageBox("Enter the following format: 99999 or 99999-9999 or A9A 9A9 );
    xfa.host.setFocus(this);
    else
    xfa.host.setFocus(form1.subform1.FField1);

    Hi again 1996,
    You can use setFocus multiple times in the exit event, and the last one that is called is where you end up. I would suggest putting the 'default' tab before all of your logic, to ensure that it's the one that gets called when the field is valid:
    i.e.:
    xfa.host.setFocus(form1.subform1.FField1);
    var regExpDate = /^\^\d{5}-\d{4}|\d{5}|[A-Z]\d[A-Z] \d[A-Z]\d$ $/;
    var vMatched = this.rawValue.match(regExpDate);
    if (!vMatched){
    this.rawValue=null;
    xfa.host.messageBox("Enter the following format: 99999 or 99999-9999 or A9A 9A9 );
    xfa.host.setFocus(this);
    This way, unless vMatched is true and the second setFocus is called to override the first, your user should always be sent to FField1.
    I know that this isn't a part of your question, but I'd like to suggest avoiding the 'thou shalt not pass until...' situations. What if your user doesn't know the postal/zip code, and wants to fill in the rest of the form before finding it? They could enter dummy data to get past your requirement, but then there's a chance that they'll forget to replace it with the real value. Altogether, I think it's better to check for invalid data in the pre-save/pre-submit events, and warn them of the required fields then.
    Also, consider only calling setFocus for when the user is tabbing away from fields. If you manually call setFocus to control the tab order from all fields (I do this for all of my forms, as I find that dynamic forms don't play nice with the tab order) then use:
    if (xfa.event.commitKey == 3) then
         xfa.host.setFocus("$.parent.NextFieldName");
    endif
    This way, if the user clicks on another field that they want to fill next, they won't be redirected to the one you chose for them.
    Sorry for the unsolicited advice... These were just some of the things that I've had to deal with in the past.
    - Scott

  • SetFocus on a textField

    Hi how do I set focus on a textfield after i validate the data. If the validation fails, I want to setFocus on the text field that failed validation. Is there a way I can do this.

    Dear nbruckelmyer
    If your get getMsgBox(); calls a frame or a non modal dialog then u will have to use
    public void getMsgBox() {
    .. display the box.
    //after ok button pressed.
    dispose();
    //then requestfocus
    lengthTextField.requestFocus();
    }Why? . Because after calling the frame/dialog, it doesn't wait for the frame/dialog to be closed so coding it after the frame/dialog is dispose should work
    But if you use JOptionPane or modal dialog
    then this should work
    getMsgBox();
    //then I requestFocus
    lengthTextField.requestFocus();But if you still have problem, u may post your code minus the contents or simplified version so that it will be easier for us to help u
    Thanks
    Joey

  • SetFocus on Exit problem

    I'm using a script on the exit event to validate a text field as a date. When testing I can press the enter button and tab off the field with bad data in it. Does anyone know why this is happening?
    Thanks,
    Ken
    Here's the script I'm using
    var re = new RegExp(); // Create a new Regular Expression Object.
    re.compile(/^\d{1,2}\/\d{1,2}\/\d{4}$/);// Set the reg exp
    if ((re != null) && (re.test(this.rawValue) == false))
    xfa.host.messageBox("Please enter a valid date (MM/DD/YYYY).","Invalid Date",0);
    xfa.host.setFocus("StatementDate[0]");

    In some cases, automatically clearing the field is a good option, but in other cases I would consider it "user abuse". If someone mistypes a credit card number, for example, they will want to go back and fix the typo rather than type in the whole thing again.
    The way LiveCycle handles validations is to bark at the user as they exit the field, but allow the user to continue filling out the form. However, LiveCycle will prevent the user from submitting the form if there are validation errors. The user can still save and can still print. Often my clients want to prevent printing and saving unless the form is valid, but there's no simple way to do that. One option is to put a conspicuous marker on the form (DRAFT or WORK IN PROGRESS watermark on the master page, for example) that indicates that the form is incomplete. You can clear the watermark when the form is valid (i.e. xfa.form.execValidate() returns true).
    Jared Langdon
    http://www.jlangdon.ca

  • Position the cursor at start of text on setFocus?

    Hi,
    I have a rich-text Text Field that contains more text than fits in the viewable area. On docReady, I want to setFocus to the text field - but I want the cursor placed at the beginning of the text in the field. The default behaviour for setFocus places the cursor at the end of the text.
    Thanks! :-)

    I think it's the same issue in this post which wasn't answered...
    http://forums.adobe.com/message/1344955

  • SetFocus dynamic with string

    Hi,
    in an adobe form the Focus can be set with xfa.host.setFocus("Formfield").  In this case 'Formfield' is a hardcoded form field.
    Is it also possible to set the focus dynamic with a string, which contains the fieldname?
    e.g.
    myField = myNode.value;
    var hochkomma = '"';
    var Formfield = hochkomma.concat(myField);
    var Formfield = Formfield.concat(hochkomma);
    xfa.host.setFocus(Formfield);
    But this code doesn't work. Where's the problem?
    Thx!

    Hi Andreas,
    try to put Formfield between "", that is :
    xfa.host.setFocus("Formfield");
    And Formfield has to be the same as the name field, be careful respecting upper/lower case.
    Regards.

  • TabIndex & setFocus issues.

    Hi all,
    I am having a real issue with getting tabIndex and setFocus
    to work with my custom TextInput component. I have tried everything
    that I can possibly think of and it just won't work. When I test
    the component and set tabIndex or setFocus nothing happens. Any
    ideas would be greatly appreciated. Below is the actionscript I
    have in my class file. (note: need it to work for fp 7+)
    class brownfreelance.components.AdvTextInput extends
    MovieClip {
    private var _mTextContainer:MovieClip;
    private var _tTextBox:TextField;
    private var _bTabChildren:Boolean;
    private var _nTabIndex:Number;
    public function setFocus():Void {
    Selection.setFocus(_mTextContainer._tTextBox);
    public function set tabIndex(nTabIndex:Number):Void {
    _mTextContainer._tTextBox.tabIndex = nTabIndex;
    public function AdvTextInput() {
    CreateTextBox();
    _mTextContainer._tTextBox.tabChildren = true;
    _mTextContainer._tTextBox.tabEnabled = true;
    _mTextContainer._tTextBox.tabIndex = _nTabIndex;
    private function CreateTextBox():Void {
    _mTextContainer.clear();
    _mTextContainer = createEmptyMovieClip("_mTextContainer",
    getNextHighestDepth());
    _mTextContainer.createTextField("_tTextBox",
    getNextHighestDepth(), 2, 2, (_nWidth-2), (_nHeight-1));
    Thank's in advance.

    On Thu, 6 Sep 2007 12:51:09 +0000 (UTC), "fourthleaf"
    <[email protected]> wrote:
    >I have been having two issues with Dreamweaver over the
    last week.
    >
    > First - it freezes after one upload, any time of file.
    One goes fine and then
    >the next time I try to upload it just gets "caught". The
    upload box comes up,
    >but never goes anywhere and it's unsuccessful. Seems like
    the only way to fix
    >it is to shut down and restart. (Which I usually have to
    do because all of
    >Dreamweaver then freezes.)
    >
    > Also, the files that I did upload are not showing live.
    They show in the
    >remote server has having been uploaded, but when I try to
    view the files
    >on-line, they do not appear. I have refreshed, cleared my
    cache, everything...
    >but the files are not updated or uploaded.
    >
    > Any ideas?
    >
    >
    I would try a different server, maybe that one is choking.

  • .setFocus() Doesn't Work

    I am calling txtUserId.setFocus(); when the application
    loads. Why is the cursor not being placed in the text box?
    If I refresh the page or change view state back to the
    original view state and I call the code it again, it works. Am I
    missing something simple, or is this a bug? Thanks!

    I am using the following code:
    creationComplete="initApp()" - inside mx:Application tag
    private function initApp():void {
    currentState = 'Login';
    txtUserId.text = '';
    txtPassword.text = '';
    txtUserId.setFocus();
    It seems levancho is correct. If I click anywhere on the
    Flash object, the focus is set to the text box. How do I overcome
    this? Could you provide sample code?
    Thanks to both of you for your replies!

  • Regarding Setfocus

    Hi,
    Can some one pls help me in below requirement
    The requirement is:  Without pressing the tab in the keyboard the cursor should automatically move into next Field after Field reaching its maximum length.
    I have set the proprty as Limitlenth to visible area and written the script as xfa.host.setFocus(Fielname) in full event but the problem is after entering the chars in the field  the last char is not showing or missing
    Thank you in advance
    Regards,
    Jay

    Check out this sample by John Brinkman.
    http://blogs.adobe.com/formfeed/2009/04/field_tab_on_full.html

Maybe you are looking for