Unfortunately, I replied only to Chuck so I am including that response in here
as well for completeness. I got it working but there were a few things that
tripped me up. Some were "operator" errors, while others were a little more
devious.
On Jul 25, 2012, at 10:04 PM, Chuck Hill wrote:
> Hi Roger,
>
> Wonder strips out nested form tags. You should be getting this warning in
> your log:
>
> if (context.isInForm()) {
> logger.warn("The AjaxModalDialog should not be used
> inside of a WOForm (" + ERXWOForm.formName(context, "- not specified -") +
> ") if it contains any form inputs or
> buttons. Remove this AMD from this form, add a form of its own. Replace it
> with " +
> "an AjaxModalDialogOpener with a
> dialogID that matches the ID of this dialog.");
> logger.warn(" page: " +
> context.page());
> logger.warn(" component: " +
> context.component());
> }
>
> You will need to fix your layout as described above.
> So the form that the external content used is the problem? I am not getting
> any error messages from my app in the console. When I run the AjaxDemo app
> and try the (incorrectly) nested example, I do get that message.
>
> I thought I had tried it with an AMDOpener but I will try again and verify
> the dialogID matches the ID.
>
> Thanks Chuck!
I did not get any warning messages. I believe this is because my log level was
for Errors. I didn't revert to the original code and test it but I did throw a
dummy AMD with a nested form and I did NOT get any log output until I changed
the logging level to WARN. I need to change my default for dev mode.
I changed the code to use an AMDOpener (see changes below). I misunderstood how
AMDOpener works. The examples could be clearer here instead of throwing
everything in one example. I thought AMDOpener was a replacement for AMD so it
didn't work initially. Once I used both the AMDOpener and the AMD, things
improved greatly. That did allow the action to fire ... sort of.
If I comment out the action binding on the AMD (as the example shows) and leave
it on the AMDO then the dialog renders with the correct label for the current
apptItem but the apptItem in editAppointment() is null for the action binding.
As it turns out, "action" is probably not a good choice of binding names (hook
might be a better name) for the AMDO. It is NOT the usual action we're all
familiar with. Instead of a WOActionResults, it is a void! (Yes, reading the
docs closer revealed that.) The action on AMD is called when the dialog opens
AND closes (I wasn't expecting that).
The onClose binding proved to be very useful for updating content since there
is no updateContainerID binding. In some ways, that is good because it is
easier to target multiple containers than using AjaxUpdateTrigger.
To actually close the dialog, I called AjaxModalDialog.update() and
AjaxModalDialog.close() from the AjaxSubmitButton action on the form embedded
in the dialog. I'm not sure update() was needed since I am closing it but I
figured it couldn't hurt.
> Chuck
>
>
> On 2012-07-26, at 7:14 AM, Roger Perryman wrote:
>
>>
>> I have a page that uses an AjaxModalDialog control to popup an external
>> form. The submit button does not work although an AjaxHyperlink does. When I
>> view the (generated) source, I noticed that the form tag has been removed.
>> The example from AjaxExample works so it must be something I am doing wrong.
>> I've included a trimmed down version of my code. Note that I added the
>> Yes/No links (from AjaxExample) to the popup for testing. NO doesn't do
>> anything. YES fires the action but does not close the dialog. It also wont
>> submit the form values since it is just a hyperlink.
>>
>> Thanks!
>>
>> Roger
>>
>>
>> parent page: (full page)
>>
>> <webobject name="apptForm">
>> <webobject name="apptList">
>> <span>
>> <webobject name="patientName"/>
Moved these outside the form (Tim: there was a typo on the name. I manually
added it for clarity but I generally only leave the name on for larger sections
of code)
>> <webobject name="editApptLink">
>> <webobject name="editAppt"/>
>> </webobject name="editApptLink">
Added a AMDOpener in their place
<webobject name="editAppt"/>
>> </span>
>> <br/>
>> </webobject name="apptList">
>> </webobject name="apptForm">
Placed the AMD outside of the form and repetition. While not apparent from this
listing, each item in the repetition has form controls (a Time/Date picker)
<webobject name="editApptLink">
<webobject name="editAppt"/>
</webobject name="editApptLink">
>>
>> apptForm: WOForm { id = "apptForm"; multipleSubmit = true; }
>>
>> apptList: WORepetition
>> {
>> id = "apptListID";
>> list = apptList;
>> item = apptItem;
>> index = apptIndex;
>> }
>>
>> patientName: WOString { value = apptItem.toPatient.fullName; }
>>
>> saveUpdates: WOSubmitButton
>> {
>> id = "saveUpdates";
>> value = "Save Updates";
>> action = saveUpdates;
>> }
>>
Nobody commented on this. I'm not sure what value to use for templateName. The
example had "link" but I didn't see how it was used. I thought it was an
enhanced WOComponentContent that supported more than one occurrence. Do I
really need this?? It seems to work as is. What is a reasonable value?
>> declineApptLink: ERXWOTemplate
>> {
>> templateName = "whatGoesHere?";
>> }
>>
I modified the AMD as follows:
>> editAppt: AjaxModalDialog
>> {
id = "editApptID";
>> action = editAppointment;
>> width = "900";
>> height = "600";
>> centerVertically = true;
>> transitions = false;
>> locked = false;
>> closeValue = "x"; //Value required here. Default is × Safari
>> fails in xhtml mode.
>> autoFocusing = false;
showOpener = false;
// udpateContainerId = apptListItemID; // This didn't work.
Used onClose instead
onClose = uppdateApptListItem; // Update the list item
>> }
I added the AMDOpener
editApptOpener: AjaxModalDialogOpener
{
dialogId = "editApptID";
label = apptItem.toPatient.fullName; // "Edit Appointment";
title = editApptPatient;
action = apptToEdit; // NOT a WOActionResult!
}
And added the following method for the title:
public String editApptPatient()
{
StringBuilder sb = new StringBuilder();
if ( _apptItem != null )
{
sb.append( "Edit " + _apptItem.toPatient().firstName() );
}
else
sb.append( "UNKNOWN" );
return sb.toString();
}
I also had to create a separate variable and method for the ID for the update
container. Since the AMD is outside the repetition, I couldn't use apptItem.
Instead, when AMDO's "action" is called, I saved the current apptItem and
apptIndex. Then I reference those to generate the correct updateContainerID and
get the correct appt.
>>
>> public WOActionResults editAppointment()
>> {
>> // Prep the objects as needed
>>
>> // Return an Edit Appt page for the popup.
>> EditApptPopup apptPopup = pageWithName( EditApptPopup.class );
>> apptPopup.setApptRequest( _apptItem );
>> return apptPopup;
>> }
>>
>>
>> And in the popup component: (partial page, no head or body tags)
>>
>>
>> <h3>Please update your information</h3>
>>
>> <webobject name="editForm">
>> First Name: <webobject name="firstName" /><br/>
>> <br/>
>> <br/>
>> <webobject name="yes">Yes</webobject>
>>
>> <webobject name="no">No</webobject>
>> <br/>
>> <br/>
>> <webobject name="updateResults" /><br/>
>> </webobject name="editForm">
>>
>>
>>
>> patientName: WOTextField
>> {
>> value = apptRequest.toPatient.fullName;
>> }
>>
>> /* Tried WOForm and ERXWOForm. Tried id and name */
>> editForm: ERXWOForm
>> {
>> id = "editForm";
>> multipleSubmit = true;
>> }
>>
>> /* A regular WOSubmitButton also doesn't work since the form is removed */
>> updateResults: AjaxSubmitButton
>> {
>> id = "updateResults";
>> value = "Save";
>> action = updateResults;
>> evalScripts = true;
>> formName = "editForm";
>> onClick = "ModalBox.hide();";
>> // onClickBefore = onClickDoneButton;
>> }
>>
>> no: WOHyperlink
>> {
>> href = "javascript: void(0);";
>> onClick = "ModalBox.hide();";
>> id = "noClicked";
>> }
>>
>> yes: AjaxHyperlink
>> {
>> action = updateResults;
>> evalScripts = true;
>> }
>>
>>
>> public WOActionResults updateResults()
>> {
>> // Push changes to parent.
>>
>> AjaxModalDialog.update( context(), null );
>> return null;
>> }
>>
>> public String onClickDoneButton()
>> {
>> return "function(){ return true; }()";
>> }
>>
>>
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Webobjects-dev mailing list ([email protected])
>> Help/Unsubscribe/Update your Subscription:
>> https://lists.apple.com/mailman/options/webobjects-dev/chill%40global-village.net
>>
>> This email sent to [email protected]
>
> --
> Chuck Hill Senior Consultant / VP Development
>
> Practical WebObjects - for developers who want to increase their overall
> knowledge of WebObjects or who are trying to solve specific problems.
> http://www.global-village.net/gvc/practical_webobjects
>
>
>
>
>
>
>
>
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com
This email sent to [email protected]