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