Scott

You are 100% right.  My problem before was that request.getAttribute() for
the two variables (partyId and billingAccountId) were null.  I tried
request.getParameter() and that yielded the contents of the previous screen
which is exactly what I wanted.

So I now have a bash script that looks like this:

billingAccountId = parameters.get("billingAccountId");

if(billingAccountId == null || billingAccountId.length() < 1)
        billingAccountId = request.getAttribute("billingAccountId");

and a dispatcher that looks like this:
      <request-map uri="findTransactions">
          <security https="true" auth="true"/>
     <!--     <event type="service" invoke="getBillingAccountCount"/> -->
          <event type="java"
path="org.ofbiz.accounting.ar.BillingAccountWorker"
invoke="getBillingAccountCount"/>
          <response name="fail" type="view" value="findTransactions"/>
          <response name="success" type="view" value="showTransactions"/>
      </request-map>

That works a charm.  I can now call it either way.  The service based one
does not work in case anyone is interested.

Thanks for the help.

Skip

-----Original Message-----
From: Scott Gray [mailto:[EMAIL PROTECTED]
Sent: Friday, November 16, 2007 10:12 PM
To: [email protected]
Subject: Re: Difficult Question


request.setAttribute works I just tried it.

Regards
Scott

On 17/11/2007, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Thanks to all who replied on this, but I guess I didn't explain it
> well.  I
> have no problem dispatching to one URL or the other, I can return any
> response I want.  The problem is this:
>
>      <request-map uri="findTransactions">
>          <security https="true" auth="true"/>
>     <!--     <event type="service" invoke="getBillingAccountCount"/> -->
>          <event type="java"
> path="org.ofbiz.accounting.ar.BillingAccountWorker"
> invoke="getBillingAccountCount"/>
>          <response name="fail" type="view" value="findTransactions"/>
>          <response name="success" type="view" value="showTransactions"/>
>      </request-map>
>
> On pass one through this findTransactions, fail is returned because there
> are no entries (no customer or billing account entered) and
> findTransactions
> gets called.  This is correct.  On pass two, the user has entered either a
> customerId or a billingAccountId.  If there is only one,
> getBillingAccountCount returns success and showTransactions gets called.
> This is correct.  The problem is that the billingAccountId I stuffed in
> getBillingAccountCount is not available to the bash script associated with
> showTransactions.  And yes, this is all based on plainolde widgets.   I
> tried the following:
>
>            request.setAttribute("billingAccountId", billingAccountId);
>
> and for the service
>
>            context.put("billingAccountId", billingAccountId);
>
>
>
> Neither results in the bash script loaded by showTransactions having the
> billingAccountId available.
>
> To answer Scott, yes, I could take this cheating way out because I do have
> the customerId, but this was an excercise as well as the solution to a
> single problem.  I have other needs for a technique like this.  For
> example,
> the customer could enter a partial customer name or billingAccountId and I
> could still show the screen if only one result matched.
>
> The question is, how to get the data I find in getBillingAccountCount into
> the bash script in showTransactions.  I hate to stuff it in the session
> when
> it really belongs in the request.  I don't want to clutter up the session
> object like that.
>
> However, I read this in the Javadocs "Attributes are reset between
> requests".  So I guess that going from getBillingAccountCount to
> showTransactions means that it is a new request even though nothing has
> been
> emitted back to the browser?
>
>
> Skip
>
>
>
> -----Original Message-----
> From: BJ Freeman [mailto:[EMAIL PROTECTED]
> Sent: Friday, November 16, 2007 7:44 PM
> To: [email protected]
> Subject: Re: Difficult Question
>
>
> are you using the controller and widgets.
> you can call bsh files from the action and make this one operation.
>
> have you looked at
>     <request-map uri="orderentry">
>         <security https="true" auth="true"/>
>         <event type="java"
> path="org.ofbiz.order.shoppingcart.ShoppingCartEvents"
> invoke="routeOrderEntry"/>
>         <response name="init" type="view" value="checkinits"/>
>         <response name="agreements" type="view" value="orderagreements"/>
>         <response name="cart" type="view" value="showcart"/>
>         <response name="error" type="view" value="checkinits"/>
>     </request-map>
>
>
>
>
>
> [EMAIL PROTECTED] sent the following on 11/16/2007 7:06 PM:
> > I have fooled with this all day now and I bet there is someone out there
> who
> > knows exactly how to do this.
> >
> > I have a URL, showTransactions that is normally called like this:
> >
> > .../showTransactions?billingAccountId=xyz
> >
> > I have another url;
> >
> > .../findTransactions
> >
> > The user gets dispatched to .../findTransactions and enters a partyId is
> > present with a list of billingAccounts for a customer and they click on
> the
> > billing account and off they go they go to
> > .../showTransactions?billingAccountId=xyz
> >
> > What I want to do is if there is only one billing account, I don't want
> them
> > to have to click the link.  I want to take them right there.  So, I
> tried
> > writing both a service and a servlet like this:
> >
> >     public static Map getBillingAccountCount(DispatchContext dctx, Map
> > context) {
> >
> > and
> >
> >     public static String getBillingAccountCount(HttpServletRequest
> request,
> > HttpServletResponse response) {
> >
> > In the first, I stuffed the billingAccountId in the context.  In the
> second,
> > I stuffed it in an attribute (there is, unfortunately, no setParameter
> which
> > is exactly what I wanted).
> >
> > Here is a sample of the dispatcher:
> >
> >     <request-map uri="findTransactions">
> >         <security https="true" auth="true"/>
> >    <!--     <event type="service" invoke="getBillingAccountCount"/> -->
> >         <event type="java"
> > path="org.ofbiz.accounting.ar.BillingAccountWorker"
> > invoke="getBillingAccountCount"/>
> >         <response name="fail" type="view" value="findTransactions"/>
> >         <response name="success" type="view" value="showTransactions"/>
> >     </request-map>
> >
> > When the bash script gets called for showTransactions using either
> method,
> > billingAccountId is not there.
> >
> > Anyone have any ideas on how to do this redirection and add parameters
> to
> > the request or context?  I can do this with a servlet and filters, but I
> > don't understand how Ofbiz handles all that.
> >
> > Skip
> >
> >
> >
> >
>
>

Reply via email to