• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Clarification on AjaxObserveField and AjaxUpdateContainer Interaction
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Clarification on AjaxObserveField and AjaxUpdateContainer Interaction


  • Subject: Re: Clarification on AjaxObserveField and AjaxUpdateContainer Interaction
  • From: Roger Perryman <email@hidden>
  • Date: Tue, 10 May 2011 14:02:04 -0400

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.

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">&nbsp; &nbsp;</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 = "">    // no-op that gives the server a chance to update 
  fullSubmit = false;
}

labTestLabel: WOGenericContainer
{
  elementName = "label";
  for = "">
}

labTestName: WOString { value = patientLabTestDisplayName; }

addLabTestPopup: AjaxModalDialog
{
  autoFocusing = false;
  centerVertically = true;
  locked = true;
  transitions = false;
  action = "">
  >
//  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._javascript_Response( "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> &nbsp;
      <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 = "">
  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 = "">
  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 = "">
  ;
  disabled = isAddButtonDisabled;
}

closeDialogButton: YUIButton
{
  value = "Cancel";
  useAjax = true;
   ;
}

=========================

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


Message: 1
Date: Mon, 09 May 2011 12:31:07 -0400
From: Roger Perryman <email@hidden>
Subject: Clarification on AjaxObserveField and
AjaxUpdateContainer
    Interaction

Hi,

I placed a WOConditional inside an update container so I
could use it 
as a hook to execute some code whenever the container was
updated. 
Specifically, I needed to update some objects after an
AjaxModalDialog 
was closed with the results from AjaxAutoComplete (and
other inputs).

The entire page is regenerated even though only a portion
of the page 
is actually updated in the browser. Everything outside of
the update 
container appears to be discarded.

This is counter-intuitive. I was under the impression that
WO 
determined which container (if any) needed updating and
regenerated 
the content for that container only and sent that to the
browser.

Because AjaxAutoComplete sends requests as you are typing,
the 
conditional is getting called excessively even though it
was not 
associated with (or inside) the update container in the
parent page. 
For complex pages this can be very costly.

Am I violating some sort of Ajax Commandment? What is the
best way to 
get around this situation? Since the popup shouldn't know
anything 
about the caller (except what is passed as arguments), I
may use 
notifications on the add button so that anyone interested
can respond. 
This wont solve the performance issues due to constant
updates to the 
page.

I am using WO 5.4. Thanks for any suggestions.

Roger





 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Clarification on AjaxObserveField and AjaxUpdateContainer Interaction
      • From: Chuck Hill <email@hidden>
References: 
 >Re: Webobjects-dev Digest, Vol 8, Issue 277 (From: Theodore Petrosky <email@hidden>)

  • Prev by Date: Re: Project Wonder Licensing
  • Next by Date: Re: Clarification on AjaxObserveField and AjaxUpdateContainer Interaction
  • Previous by thread: Re: Webobjects-dev Digest, Vol 8, Issue 277
  • Next by thread: Re: Clarification on AjaxObserveField and AjaxUpdateContainer Interaction
  • Index(es):
    • Date
    • Thread