---------- Forwarded message ----------
From: Mark Wardle <[email protected]>
Date: 30 January 2012 19:38
Subject: Re: D2W, EditingContext, WORequest
To: Markus Ruggiero <[email protected]>


Ok, I also use the willUpdate() notification to maintain internal
consistency. I'd be a bit worried about doing lots of weird stuff in there,
but perhaps you could have a flag that says that the PDF needs to be
regenerated. Have a separate thread that runs and generates PDFs

I tend to generate PDF on-the-fly when requested rather than storing. On
the occasions that I do store PDFs, it is because of medico-legal reasons
and any subsequent changes are tracked and recorded, so there is a PDF
trail. Plus, even for stored PDFs, I output them via a direct action so
that I can emblazon "DRAFT" or "DELETED" on them depending on status in the
audit trail.

Mark



On 30 January 2012 17:42, Markus Ruggiero <[email protected]> wrote:

> Thanks Mark for your example. It is (almost) exactly what I have done.
> However now there is a twist - and that is the actual problem. Maybe I was
> not really clear in what I need to do.
>
> This is a simplified model: TextblockGroup -one2many- Textblock -one2many-
> TextblockParam.
>
> Suppose it makes no sense for the user to work in a pageConfiguration
> "EditTextblockParam" because a textblock param only makes sense in the
> context of a textblock. Likewise editing a textblock only makes sense in
> the context of a textblock group. The only thing the user ever sees is
> EditTextblockGroup-pageConfiguration. The list of textblocks and their
> parameters is handled with a custom property level component. Now when the
> user edits a textblock param only that textblock param will be changed and
> stored to the database. Your (and mine) nextPageDelegate cannot figure this
> out because the top level object TextblockGroup has not been changed and
> thus not been saved. However the textblock param might have been referenced
> in some PDFs thus this/these particular PDFs have to be recreated. If I
> recreate all the PDF that *might* hang off the top level object I may as
> well recreate thousands of PDFs. And this is certainly not what I want. And
> all the PDFs are tracked with a revision which would create a new revision
> of all the unchanged PDFs.
>
> So while your idea is great unless I miss something I think it does not
> help in this particular case. What else can I do?
>
> ---markus---
>
> On 30.01.2012, at 17:13, Mark Wardle wrote:
>
> 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
>
>
>


-- 
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




-- 
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]

Reply via email to