• Get value form Dialog Box

    By David Montandon 1 decade ago

    Hello

    In my Xpage I have 2 combobox that are depend of each other...

    When changing value in Combo1 it will reload choice in Combo2.

     

    To help use to found information quickly I created a search custom control and added it in a Dialog Box that can be open from the page.

    I would like to set the combos depend of that the user selected in the dialog box. But how do you I can refresh combo value from the source page ?

    XPagesExt sample DB show only how to refresh a default text value.

    Here is a copy of the page screen, of course I know the ID of selected item in combobox and can easly found parent level.

    • Sure

      By Philippe Riand 1 decade ago

      You should display the dialog using a server side action, so the values from the main page are sent to the server. Then, the dialog can either find the component using getComponent("xxx").getValue(), or access the data model the component is bind to.

      Ok, la prochaine fois je reponds en Francais!

      • What code on OK button ?

        By David Montandon 1 decade ago

        (Look like my previous post get lost)

         

        Thank you Philippe

        I am already loading my combo from a Server Side script, using a VIEW FT Search with this code.

        var criteria = sessionScope.compToSearch;
        var searchKey = "([Type] CONTAINS TECHNO AND [French] CONTAINS *"+criteria+"*)";
        var currDoc:NotesDocument;
        var myOpt=new Array();


        if (null != criteria && criteria != "")
            {
            var currDb:NotesDatabase = session.getCurrentDatabase();
            var currView:NotesView = currDb.getView("(keyWords)");
            var viewElem = currView.FTSearch(searchKey);
            if (viewElem >=1)
                {
                   
                var loop = 0 ;
                var categoryName = "" ;
                   
                for (i=1;i<=viewElem;i++)
                    {    
                    currDoc = currView.getNthDocument(i);
                    if (null != currDoc)
                        {
                       //Si catégorie, charger les enfants
                        if( currDoc.getItemValueString("Type") == "TECHNO-CATEGORY")
                            {
                            var arr = @DbLookup(@DbName(), "(keyWords)", "TECHNO-" + currDoc.getItemValueString("code") , 3)     ;  
                            var len = arr.length;
                            for(var x=0 ; x<len ; x++)
                                {
                                myOpt[loop] = currDoc.getItemValueString("French") + "// " + arr[x] ;
                                loop += 1 ;
                                }
                            }
                        else
                            {                    
                                                   
                            categoryName = @DbLookup("", "(keyWordsView)", "TECHNO-CATEGORY~" + currDoc.getItemValueString("parent"), 2) ;
                           
                           
                            myOpt[loop] = categoryName + "// " + currDoc.getItemValueString("French") + "|" + currDoc.getItemValueString("Code")  ;   
                            loop += 1 ;        
                                                               
                               
                            }
                        }                
                    }
                myOpt.sort();
                }
            else
                {
                myOpt = "";
                }
            }

         

         

        But I dont know what code to put on my OK button.

        But I think it is just a classic mistake, as you suggest me to use getComponent.

        <xp:button value="OK" id="buttonOK"
            onclick="var comboSearch:javax.faces.component.UIComponent = getComponent('cbCompSearch');
            var selection = comboSearch.getValue();
            var comboProduct:javax.faces.component.UIComponent = getComponent('cbName');
            if(selection != null)
                {
                comboProduct.setValue(selection) ;
                }
            XSP.closeDialog('#{id:dialogSearch}')"
            style="width:28px">
        </xp:button>

        But I got the folling error

        <span style="color:#f00;">missing ; before statement</span></div>
        
        <span style="color:#f00;"><img class="errorBreak a11yFocus " role="checkbox" src="chrome://firebug/content/blank.gif" title="Stopper sur une erreur"/></span><a class="errorSource a11yFocus " title="&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot; &quot;http://www.w3.org/TR/html4/loose.dtd&quot;&gt;">var comboSearch:javax.faces.component....2:OneUIMainAreaCallback:dialogSearch&#39;)</a></div>
        

         

        Thank you for any help or sample code.

        • This is obvious...

          By Philippe Riand 1 decade ago

          ... with just this sample. Please attach an actual NSF showing the issue, else it is too hard for me to try to reproduce it. Be sure the NSF is not encrypted and the ACL properly cleared out.