[OFBiz] Users - need help, please

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[OFBiz] Users - need help, please

Hao Jiang-4
Hello

I have a web form target to a java method, which takes
(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
as parameters, after it's done, back to the same page.

Now the java code worked OK, did what I expected. But this time I want
to have success/error message show up after this action. I have read
some source code, it seems that return  "ServiceUtil.returnSuccess()"
will do that, however, ServiceUtil.returnSuccess() is a "map" type and
the method I wrote can only return String type.

How can I do to have those return messages appear on the web page?

Thanks

Hao


 
_______________________________________________
Users mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: [OFBiz] Users - need help, please

Si Chen-2
ServiceUtil is for services.  You are writing a servlet.  Look in one of
the envsetup.bsh and it will show you how it is retrieving the error
messages.  Set them the same way.

Si

Hao Jiang wrote:

>Hello
>
>I have a web form target to a java method, which takes
>(javax.servlet.http.HttpServletRequest request,
>javax.servlet.http.HttpServletResponse response)
>as parameters, after it's done, back to the same page.
>
>Now the java code worked OK, did what I expected. But this time I want
>to have success/error message show up after this action. I have read
>some source code, it seems that return  "ServiceUtil.returnSuccess()"
>will do that, however, ServiceUtil.returnSuccess() is a "map" type and
>the method I wrote can only return String type.
>
>How can I do to have those return messages appear on the web page?
>
>Thanks
>
>Hao
>
>
>
>_______________________________________________
>Users mailing list
>[hidden email]
>http://lists.ofbiz.org/mailman/listinfo/users
>
>  
>
 
_______________________________________________
Users mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: [OFBiz] Users - need help, please

Jacopo Cappellato
In reply to this post by Hao Jiang-4
Hao,

you have probably written an event method; if so, you should return
"success" or "error" and then use them in the controller to redirect to
the proper pages (you'll see a lot of examples of this in many OFBiz
components (see for example the product/catalog application).

Jacopo

Hao Jiang wrote:

> Hello
>
> I have a web form target to a java method, which takes
> (javax.servlet.http.HttpServletRequest request,
> javax.servlet.http.HttpServletResponse response)
> as parameters, after it's done, back to the same page.
>
> Now the java code worked OK, did what I expected. But this time I want
> to have success/error message show up after this action. I have read
> some source code, it seems that return  "ServiceUtil.returnSuccess()"
> will do that, however, ServiceUtil.returnSuccess() is a "map" type and
> the method I wrote can only return String type.
>
> How can I do to have those return messages appear on the web page?
>
> Thanks
>
> Hao
>
>
>  
> _______________________________________________
> Users mailing list
> [hidden email]
> http://lists.ofbiz.org/mailman/listinfo/users
>

 
_______________________________________________
Users mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: [OFBiz] Users - need help, please

Hao Jiang-4
In reply to this post by Si Chen-2
Thanks Si and Jacopo,

If the return is "success", probably I will go to the next page, but in
case of "error", I want to stay there and show exactly what the error
message is.

Now I think I had some clues but not sure it's correct.

The form I had is inside application/ecommerce, in controller.xml I
defined the action as "java" type, and the java method is in another
module application/new, which is fine.

In application/ecommerce there is no servicedef folder, that's why I
haven't defined above action as "service" type. Now after read
controller.xml file carefully, I found that it still can use "service"
type, and apparently it can refer to an entry in service.xml inside
application/new.

Therefore I could have an entry in service.xml, type as java, this time
I can use similar java code but the method will no longer a servlet, it
will take (DispatchContext dctx, Map context) as parameters and return a
map

Is it OK to do that way?

Thanks

Hao



 
_______________________________________________
Users mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: [OFBiz] Users - need help, please

Hao Jiang-4
In reply to this post by Jacopo Cappellato
Hello

Sorry me again.

I'm trying:

1. a form set target to a servlet
2. after servlet has done, the next step is a service, sending email
3. the service back to the first page

I try to follow the procedure of  "checkExternalPayment", which in
controller.xml

<request-map uri="checkExternalPayment">
        <security https="true" direct-request="false"/>
        <event type="java"
path="org.ofbiz.order.shoppingcart.CheckOutEvents"
invoke="checkExternalPayment"/>
        <response name="none" type="request" value="emailorder"/>
        <response name="offline" type="request" value="emailorder"/>
        <response name="worldpay" type="request" value="callWorldPay"/>
        <response name="paypal" type="request" value="callPayPal"/>
        <response name="billact" type="request" value="emailorder"/>
        <response name="cod" type="request" value="emailorder"/>
        <response name="error" type="view" value="checkoutreview"/>
    </request-map>

    <request-map uri="emailorder">
        <security https="true" direct-request="false"/>
        <event type="service" path="async"
invoke="sendOrderConfirmation"/>
        <response name="success" type="view" value="ordercomplete"/>
        <response name="error" type="view" value="ordercomplete"/>
    </request-map>

in services.xml

    <service name="sendOrderConfirmation" engine="java" require-new-
transaction="true" max-retry="3"
            location="org.ofbiz.order.order.OrderServices"
invoke="sendOrderConfirmNotification">
        <description>Send a order confirmation</description>
        <implements service="orderNotificationInterface"/>
        <attribute name="sendTo" type="String" mode="IN"
optional="true"/>
        <attribute name="sendCc" type="String" mode="IN"
optional="true"/>
        <attribute name="note" type="String" mode="IN" optional="true"/>
    </service>

but I couldn't find a way to pass some parameters from servlet to
service, I noted that in "sendOrderConfirmNotification" java method
there is
String orderId = (String) context.get("orderId");

but where and when this information has been inserted?

Thanks

Hao



 
_______________________________________________
Users mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/users