• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: D2W, EditingContext, WORequest
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: D2W, EditingContext, WORequest


  • Subject: Re: D2W, EditingContext, WORequest
  • From: Markus Ruggiero <email@hidden>
  • Date: Mon, 30 Jan 2012 18:42:41 +0100

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@hidden> 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@hidden>
> 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@hidden)
>
> This email sent to email@hidden
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
>
> This email sent to email@hidden
>
>
>
>  _______________________________________________
> Do not post admin requests to the list. They will be ignored.
>
> This email sent to email@hidden
>



--
Dr. Mark Wardle
Consultant Neurologist, University Hospital Wales, Cardiff, UK
Honorary Lecturer, Cardiff University, UK
Email: email@hidden or email@hidden
Telephone: 02920745274 (secretary) or facsimile: 02920744166


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >D2W, EditingContext, WORequest (From: mailinglists <email@hidden>)
 >Re: D2W, EditingContext, WORequest (From: Markus Ruggiero <email@hidden>)
 >Re: D2W, EditingContext, WORequest (From: Paul D Yu <email@hidden>)
 >Re: D2W, EditingContext, WORequest (From: Markus Ruggiero <email@hidden>)
 >Re: D2W, EditingContext, WORequest (From: Mark Wardle <email@hidden>)

  • Prev by Date: Re: custom component in d2w
  • Next by Date: Re: PDFWrapper Error
  • Previous by thread: Re: D2W, EditingContext, WORequest
  • Next by thread: Fwd: D2W, EditingContext, WORequest
  • Index(es):
    • Date
    • Thread