You can set-up workflow using D2W.
For instance, this is a sample D2W workflow that takes an appointment (one
of my EOs), sends the user to an edit page. When that is saved, it runs the
delegate below.
/**
* Edits (usually a newly created) encounter showing a D2W edit page to
complete the core details
* and then a more complex custom edit page allowing full editing.
*
* @param e
* @param returnPage
* @return
*/
public static WOActionResults editEncounterInTwoSteps(Appointment a,
WOComponent returnPage) {
EditPageInterface nextPage = (EditPageInterface)
D2W.factory().pageForConfigurationNamed("EditAppointment",
returnPage.session());
nextPage.setObject(a);
nextPage.setNextPageDelegate(new SaveOrCancelDelegate(returnPage));
return (WOActionResults) nextPage;
}
/**
* A simple NextPageDelegate that understands whether an object was saved
or not and
* chooses the appropriate next page (ie to a next page or to a cancel page)
* @author mark
*
*/
public static class SaveOrCancelDelegate implements NextPageDelegate {
private WOComponent _cancelPage;
public SaveOrCancelDelegate(WOComponent cancelPage) {
_cancelPage = cancelPage;
}
public WOComponent nextPage(WOComponent sender) {
ERDObjectSaverInterface epi = (ERDObjectSaverInterface) sender;
if (epi.objectWasSaved() == true) {
Appointment a = (Appointment) ((ERDEditPageInterface) sender).object();
if (a.isInFuture() == false) {
EditEncounter editPage =
ERXApplication.erxApplication().pageWithName(EditEncounter.class);
Encounter e =
a.createEncounterForAppointment(((User)ERCoreBusinessLogic.actor()).localInstanceIn(a.editingContext()));
a.setOutcome(Appointment.Outcome.COMPLETED);
e.editingContext().saveChanges();
editPage.setEncounter(e);
editPage.setNextPage(_cancelPage);
return editPage;
}
}
return _cancelPage;
}
}
You can see that, if the appointment is not in the future, then an
encounter EO is also created and then the editing context saved again.
Good luck,
Best wishes,
Mark
On 30 January 2012 14:59, Markus Ruggiero <[email protected]> wrote:
> Yes, Paul, I know this - and I do not want to mix. BUT: the required
> functionality is so, that when a "textblock" is edited and then stored to
> the database, all "electronic documents" that include this particular
> textblock must be recreated automatically. To be able to do this I must be
> able to find the updated textblock. This is something that the editing
> context can tell me. To generate the electronic document (resulting PDF) I
> use a standard WOComponent to generate the XML as input to Apache FOP. And
> here is my problem: When the user presses "Save" in the D2W page this can
> result in some modifications to textblocks. Textblock is not necessarily
the
> top entity in the D2W edit page. First I had my code in the
nextPageDelegate
> for the editing page. But this is only called after the save has taken
place
> and I the editing context cannot tell me what has been saved and needs
> regeneration of the relevant PDF. Can I trap saveChanges() in a
D2WEditPage
> without having to freeze the component? Or is there a way for the editing
> context to access the request/context (which should probably not be)? Or
am
> I completely off track?
>
> I hope I could make clear where my problem is. Thanks for
> input/help/whatever
> ---markus---
>
> On 30.01.2012, at 14:06, Paul D Yu wrote:
>
> Component generation, XML generation are "UI" view things, they should NOT
> be down in your EOs!!! Have you looked at the PDF generation example in
> Wonder?
>
> Basically, you should create a component like any other, except the
wrapper
> is what FOP wants.
>
> Paul
>
> Sent from my iPad
>
> On Jan 30, 2012, at 4:58 AM, Markus Ruggiero <[email protected]>
> wrote:
>
> Help, this is urgent, please could someone have a look. I am at a loss
here.
> Probably my concept is wrong but I do not see how to fix it. A nudge into
> the right direction (or a kick into the bu**) might be all I need.
>
> Thank you very much
> ---markus---
>
> On 27.01.2012, at 15:35, mailinglists wrote:
>
> Help!
>
> My ERD2W application needs to generate PDF-files for EOs. The EO has a
> method that calls a XML-Generator that generates the XML-input for
> Apache-FOP. For this I use the following code in the Document-EO (just a
> fragment)
>
> I_XMLGeneratorInterface xmlGenerator =
>
(I_XMLGeneratorInterface)WOApplication.application().pageWithName(generatorName,
> new WOContext(session.context().request()));
>
> The problem is that pageWithName needs a WOContext and this needs a
> WORequest. The WORequest comes from the session. BUT EOs are not supposed
to
> know about sessions. So I pass the session into that method when I call
the
> document to generate the PDF data. Fine, works. But now I want to automate
> the generation of PDFs when any relevant object is saved. I have thus
> created my own EOEditingContext descendant where I override saveChanges().
> Whenever I save a relevant object I check after success if that object has
> related documents and then call those to generate the PDF, passing in the
> session. My EditingContext has a session variable and in the
> session-constructor I manually create my editing context, stuff the
session
> into it and install it as defaultEditingContext. But D2W creates
> editingContexts and knows nothing about feeding with session information.
> When my code runs session variable is null and no PDFs are created.
>
> Any idea how to tackle this problem? HELP! Is my strategy ok? Can I fix
the
> missing session somehow? Or would you recommend a different way to go?
>
> Thanks a lot, this is an urgent one
> ---markus---
> _______________________________________________
> 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/mailinglists%40kataputt.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:
> https://lists.apple.com/mailman/options/webobjects-dev/pyu%40mac.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:
> https://lists.apple.com/mailman/options/webobjects-dev/mark%40wardle.org
>
> This email sent to [email protected]
>
--
Dr. Mark Wardle
Consultant Neurologist, University Hospital Wales, Cardiff, UK
Honorary Lecturer, Cardiff University, UK
Email: [email protected] or [email protected]
Telephone: 02920745274 (secretary) or facsimile: 02920744166
_______________________________________________
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]