--- On Wed, 5/11/11, Chuck Hill <[email protected]> wrote:
> From: Chuck Hill <[email protected]> > Subject: Re: Clarification on AjaxObserveField and AjaxUpdateContainer > To: "Roger Perryman" <[email protected]> > Cc: "Theodore Petrosky" <[email protected]>, [email protected] > Date: Wednesday, May 11, 2011, 12:58 AM > One thing that looks suspicious to me > is that the AMD and the data it is updating are both in the > same form. Can you move the AMD outside of the AUC > _and_ the form and add a different form inside the AMD? > > I have not used an AAC or an AOF in an AMD before. > Gee, it is fun to talk in code! > I have and it works fine. Of course you are not supposed to put an AMD inside a form. Put the binding for the AMD outside the form and use an AjaxModalDialogOpener inside the form that refers to the AMD. <body> <webobject name="MyAMD"/> <webobject name="MyFormBegin"> <webobject name="MyAMDOpener"/> </webobject> <body> WOD MyFormBegin : WOForm { } MyAMD : AjaxModalDialog { id = "MyAMDID"; action = methodToBringInAMDContent; /*other stuff about AMD*/ } MyAMDOpener : AjaxModalDialogOpener { dialogId = "MyAMDID"; label = "label text"; } Java: public WOActionResults methodToBringInAMDContent() { SearchGrid theSearchGrid = pageWithName(SearchGrid.class); return theSearchGrid; } This assumes you have a WOComponent called SearchGrid. I also believe I read somewhere that the binding to the AMD should be at the top of the HTML to make it 'known' at the beginning of the page. Ted > > Chuck > > > On May 10, 2011, at 2:11 PM, Roger Perryman wrote: > > > Ted, > > > > I've tried that combination (and many others) before. > Some were close. Some were ... not so close. I just tried it > again and here is what I found. I reloaded the page for each > test. > > > > Assuming that I have selected an item in the AAC and > then entered data in the details text area and it still has > focus: > > > > Click on Add button - Dialog closes and screen updates > with an EMPTY container. > > Click outside the text area and then click on Add > button - Dialog closes and screen updates correctly. > > Click on Add Button (enable breakpoint in onClose) - > Dialog closes; Continue from breakpoint; screen updates > correctly. > > > > Assuming that I have selected an item in the AAC and > it still has focus: > > > > Click on Add button - Dialog closes and screen updates > correctly. > > Click outside the AAC and then click on Add button - > Dialog closes and screen updates with an EMPTY container. > > Click on Add Button (enable breakpoint in onClose) - > Dialog closes; Continue from breakpoint; screen updates > correctly. > > > > Note that the details text area has an AOF but it does > NOT specify an AUC. It does call a method that simply > returns null. If I don't call a method, then the variables > never update on the server side. > > > > I still believe it is a timing issue although it > doesn't make sense to get an empty AUC after clicking > outside the AAC field and then clicking Add. > > > > Roger > > > > > > On May 10, 2011, at 3:47 PM, Theodore Petrosky wrote: > > > >> ------------------------------ > >>> > >>> Message: 2 > >>> Date: Tue, 10 May 2011 14:02:04 -0400 > >>> From: Roger Perryman <[email protected]> > >>> Subject: Re: Clarification on AjaxObserveField > and > >>> AjaxUpdateContainer > >>> Interaction > >>> To: Theodore Petrosky <[email protected]> > >>> Cc: [email protected] > >>> Message-ID: <[email protected]> > >>> Content-Type: text/plain; charset="us-ascii" > >>> > >>> Ted, > >>> > >>> Thanks for answering! I almost missed your > reply because it > >>> was in a > >>> digest. I was watching for the subject line. > >>> > >>> I often use conditionals to execute code such > as resetting > >>> counters or > >>> prepping a loop but I think this was the first > time I had > >>> done it > >>> inside an AUC. I removed it and tinkered with > several > >>> combinations of > >>> the bindings. I couldn't find an example for > >>> closeUpdateContainerID. > >>> Is it _required_ with onClose? While using it, > it was > >>> trying to update > >>> the container before the list was rebuilt. > >> > >> closeUpdateContainerID = > "theIDForTheAUCThatYouWantTOUpdate"; > >> so if you wanted this AUC to update after closing > the AMD > >> > >> I tend to make my IDs have the name of the object > so I can remember where things point: > >> > >> labTestCB: WOCheckBox > >> { > >> id = labTestCBID; > >> checked = patientLabTestCB; > >> } > >> > >> labTestResultsUC: AjaxUpdateContainer > >> { > >> id = "labTestResultsUC"; > >> } > >> > >> MyAMD : AjaxModalDialog { > >> closeUpdateContainerID = "labTestResultsUC"; > >> onClose = methodOnServerToFireBeforeClosingAMD; > >> } > >> > >> when MyAMD closes it will fire the method on the > server then fire the AUC to update its contents. > >> > >> > >> > >>> > >>> It still doesn't work 100% but it is much > closer. Also, the > >>> question > >>> about the entire page being processed when > updating a > >>> portion of the > >>> page wasn't answered. Any thoughts or > insights? > >>> > >>> The remaining quirks: > >>> > >>> 1. The AjaxAutoComplete works > correctly > >>> the first time but if I open > >>> the AMD again, then the styling is gone -- > hard to read but > >>> it is > >>> functional. > >>> > >>> 2. Tab doesn't work from fields > within > >>> the AMD. Is this is a know bug/ > >>> feature/issue with AMD? > >>> > >>> 3. I have to click outside the > Details > >>> field (tab doesn't work) before > >>> clicking Add. If I just click on Add before > leaving the > >>> field, then > >>> addLabTestData() doesn't seem to get called. > The button is > >>> enabled > >>> when a selection is made in the AAC. I suspect > it is a > >>> timing issue > >>> between the UC updating and list being > recreated. > >>> > >>> Here is the source for the two components. > I've trimmed it > >>> down to the > >>> relevant pieces so you can see what I am > trying to > >>> accomplish (it is > >>> still about 250 lines). > >>> > >>> MPanelOrders.html ( an embedded > component which calls > >>> the AMD ) > >>> > >>> <webobject > name="ordersForm"> > >>> > >>> <!-- This UC will > get re-loaded > >>> when "Add" is clicked in the AMD > >>> --> > >>> <webobject > >>> name="labTestUC"> > >>> > >>> <!-- This > just prints a > >>> timestamp --> > >>> <webobject > >>> name="testMarker" /><br/> > >>> <p>The > following labs > >>> and tests will be automatically ordered:</ > >>> p> > >>> <br/> > >>> > >>> <ul> > >>> <!-- > current labs > >>> and tests. Will be recreated when "Add" is > >>> clicked in AMD --> > >>> > <webobject > >>> name="labTestList"> > >>> > <li> > >>> > >>> <!-- A custom checkbox and > label for > >>> each lab and test --> > >>> > >>> <span> > >>> > >>> <webobject > name="labTestCB"/> > >>> > >>> <webobject > >>> name="labTestLabel"> > >>> </webobject> > >>> > >>> <webobject > name="labTestName" /> > >>> > >>> <webobject > name="labTestCB_OF" /> > >>> > >>> </span> > >>> > </li> > >>> > </webobject> > >>> </ul> > >>> > >>> <!-- Button > to launch > >>> the AjaxModalDialog --> > >>> <div> > >>> > <webobject > >>> name="addLabTestPopup"/> <span>Order > >>> additional > >>> Labs and Tests</span> > >>> </div> > >>> </webobject > >>> name="labTestUC"> > >>> </webobject > name="ordersForm"> > >>> > >>> ==================================== > >>> > >>> MPanelOrders.wod > >>> > >>> ordersForm: WOForm > >>> { > >>> id = "ordersForm"; > >>> multipleSubmit = true; > >>> } > >>> > >>> labTestUC: AjaxUpdateContainer > >>> { > >>> elementName = "div"; > >>> id = "labTestUC"; > >>> } > >>> > >>> labTestList: WORepetition > >>> { > >>> list = patientLabTestList; > >>> item = patientLabTestItem; > >>> index = patientLabTestIndex; > >>> } > >>> > >>> labTestCB: WOCheckBox > >>> { > >>> id = patientLabTestID; > >>> checked = patientLabTestCB; > >>> } > >>> > >>> labTestCB_OF: AjaxObserveField > >>> { > >>> observeFieldID = > patientLabTestID; > >>> action = genericAjaxUpdate; > >>> // no-op that gives the server a > >>> chance to update > >>> fullSubmit = false; > >>> } > >>> > >>> labTestLabel: WOGenericContainer > >>> { > >>> elementName = "label"; > >>> for = patientLabTestID; > >>> } > >>> > >>> labTestName: WOString { value = > patientLabTestDisplayName; > >>> } > >>> > >>> addLabTestPopup: AjaxModalDialog > >>> { > >>> autoFocusing = false; > >>> centerVertically = true; > >>> locked = true; > >>> transitions = false; > >>> action = addLabTestPopup; > >>> onClose = > onCloseModalDialog; > >>> // closeUpdateContainerID = > "labTestUC"; > >>> title = "Add Another Lab or > Test"; > >>> label = "Add another Lab or > Test"; > >>> class = "addLab"; > >>> closeValue = "x"; > >>> width = 500; > >>> height = 300; > >>> } > >>> > >>> testMarker: WOString > >>> { > >>> value = testMarker; // > Current > >>> timestamp > >>> dateformatter = "%m/%d/%Y > %H:%M:%S"; > >>> } > >>> > >>> ========================= > >>> > >>> MPanelOrders.java > >>> > >>> public WOActionResults addLabTestPopup() > >>> { > >>> AddLabTestPopup popup = > pageWithName( AddLabTestPopup.class ); > >>> > >>> // Create a new > _patientLabTest object. > >>> It needs info the popup > >>> doesn't know > _patientLabTestSelected = > >>> PatientLabTest.createPatientLabTest( > editingContext(), … > >>> ); > >>> popup.setPatientLabTest( > >>> _patientLabTestSelected ); > >>> return popup; > >>> } > >>> > >>> // Taken from ModalDialogOpenerExample > >>> public void onCloseModalDialog() > >>> { > >>> // Rebuild the LabTest list > >>> if ( _patientLabTestSelected > != null ) > >>> > updatePatientLabTestList( true ); > >>> > >>> // And refresh the update > container > >>> if > >>> ( > AjaxRequestHandler.AjaxRequestHandlerKey.equals(context().request().requestHandlerKey() > ) ) > >>> > AjaxUtils.javascriptResponse("labTestUCUpdate();", > context()); > >>> } > >>> > >>> ---------------------------------------- > >>> > >>> AddLabTestPopup.html > >>> > >>> <h3>Enter the name of a > Lab or Test > >>> and select it from the list > >>> below.</h3> > >>> > >>> <webobject name = > "labTestForm"> > >>> <webobject name = > >>> "labTestsACS"/> > >>> <br/> > >>> <div > style="margin-top: > >>> 3em;"> > >>> > >>> <span>Details:</span> > >>> > >>> <webobject > name = > >>> "labTestDetails"/><webobject name = > >>> "labTestDetailsOF"/> > >>> </div> > >>> > >>> <webobject name = > "labTestResultsUC"> > >>> <webobject > name="selectionName"/> > >>> <br/> > >>> <div> > >>> > <webobject name = > "addLabTestButton"/> > >>> > <webobject name = > "closeDialogButton"/> > >>> </div> > >>> </webobject > name="labTestResultsUC"> > >>> > >>> </webobject > name="popupForm"> > >>> > >>> ========================= > >>> > >>> AddLabTestPopup.wod > >>> > >>> labTestForm: ERXWOForm > >>> { > >>> id = "labTestForm"; > >>> embedded = true; > >>> } > >>> > >>> labTestsACS: AutoCompleteSearch ( > AjaxAutoComplete with > >>> custom search > >>> logic ) > >>> { > >>> action = selectLabTest; > >>> displayStringKeyPath = > "displayName"; > >>> labelString = "Search Labs > and Tests"; > >>> limit = 10; > >>> size = 85; > >>> list = allLabsAndTests; > >>> selection = selection; > >>> updateContainerID = > "labTestResultsUC"; > >>> } > >>> > >>> labTestResultsUC: AjaxUpdateContainer > >>> { > >>> id = "labTestResultsUC"; > >>> } > >>> > >>> labTestDetails: WOText > >>> { > >>> id = "labTestDetails"; > >>> value = details; > >>> cols = 50; > >>> rows = 2; > >>> } > >>> > >>> labTestDetailsOF: AjaxObserveField > >>> { > >>> observeFieldID = > "labTestDetails"; > >>> // updateContainerID = > "labTestResultsUC"; > >>> action = genericAjaxUpdate; > >>> fullSubmit = false; > >>> } > >>> > >>> selectionName: WOString > >>> { > >>> value = > selection.briefDescription; > >>> valueWhenEmpty = "No Lab or > Test > >>> Selected"; > >>> } > >>> > >>> addLabTestButton: YUIButton > >>> { > >>> value = "Add"; > >>> useAjax = true; > >>> updateContainerID = > "labTestUC"; // > >>> Container in the caller > >>> component > >>> action = addLabTestData; > >>> onclick = "AMD.close();"; > >>> disabled = > isAddButtonDisabled; > >>> } > >>> > >>> closeDialogButton: YUIButton > >>> { > >>> value = "Cancel"; > >>> useAjax = true; > >>> onclick = "AMD.close();"; > >>> } > >>> > >>> ========================= > >>> > >>> AddLabTestPopup.java > >>> > >>> // Currently just prints out a message when an > item is > >>> selected > >>> // Without this method, server-side variable > doesn't get > >>> updated > >>> public WOActionResults selectLabTest() > >>> { > >>> System.out.println( > "_selection: " + > >>> _selection ); > >>> return null; > >>> } > >>> > >>> public WOActionResults addLabTestData() > >>> { > >>> if ( _selection == null ) > >>> ; > >>> > >>> else if ( _selection > instanceof > >>> MedicalLab ) > >>> > >>> _patientLabTest.setToMedicalLabRelationship( > >>> (MedicalLab) > >>> _selection ); > >>> > >>> else > >>> > >>> _patientLabTest.setToMedicalTestRelationship( > >>> (MedicalTest) > >>> _selection ); > >>> > >>> _patientLabTest.setDetails( > _details ); > >>> > >>> return null; > >>> } > >>> > >>> > >>> > >>> On May 9, 2011, at 4:12 PM, Theodore Petrosky > wrote: > >>> > >>>> I do this quite a bit. > >>>> > >>>> the AjaxModalDialog has both a > onClose and > >>> closeUpdateContainerID > >>>> bindings > >>>> > >>>> it sounds to me as if you do not want the > >>> WOConditional inside the > >>>> AUC., but instead use the above bindings. > >>>> > >>>> onClose --- server side > method that > >>> runs before the dialog is > >>>> closed, the return value is discarded. > This will be > >>> executed if the > >>>> page is reloaded, but not if the user > navigates > >>> elsewhere. > >>>> > >>>> closeUpdateContainerID --- the > update container > >>> to refresh when > >>>> onClose is called > >>>> > >>>> I guess it would help to see how you are > bringing in > >>> the AMD and > >>>> where the AUC is in relation. > >>>> > >>>> > >>>> Ted > >>>> > >>>> > >>> > >> _______________________________________________ > >> Do not post admin requests to the list. They will > be ignored. > >> Webobjects-dev mailing list > ([email protected]) > >> Help/Unsubscribe/Update your Subscription: > >> http://lists.apple.com/mailman/options/webobjects-dev/roger%40xeotech.com > >> > >> This email sent to [email protected] > >> > > > > _______________________________________________ > > Do not post admin requests to the list. They will be > ignored. > > Webobjects-dev mailing list ([email protected]) > > Help/Unsubscribe/Update your Subscription: > > http://lists.apple.com/mailman/options/webobjects-dev/chill%40global-village.net > > > > This email sent to [email protected] > > -- > Chuck Hill > Senior Consultant / VP Development > > Come to WOWODC this July for unparalleled WO learning > opportunities and real peer to peer problem solving! > Network, socialize, and enjoy a great cosmopolitan > city. See you there! http://www.wocommunity.org/wowodc11/ > > _______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list ([email protected]) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to [email protected]
