------------------------------
> 
> 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">&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 = 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>
> &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 = 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/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to