Thursday, July 25, 2013

Re: How can I use Incremental Command in GWT

I'm not sure why you want to use DeferredCommand. The UI kick off an async request seems pretty standard.

I'd double check to see if you JDBC is really being fired _before_ the async request is started. That seems unlikely. Too many debugger threads running?

On Wednesday, July 24, 2013 4:30:02 PM UTC+1, Krish wrote:


I have the below code where incremental command is not working as expected. I have the below radio button once it is selected I will get the value from the txt box of product and do an RPC. Based on the output I would like to form the where clause and run the resulting query.

I have the below class variables

    private static boolean isLoaded = false;

    StringBuilder whereClause = new StringBuilder("select * from grocery_shop where ");

    StringBuilder productCode = new StringBuilder("(");

    ArrayList<String> productList = null;
   
Below code is the place where RPC is called in Incremental command

        if (Dialog.getRadioproduct().getValue()) {
            DeferredCommand.addCommand(new IncrementalCommand() {

                @Override
                public boolean execute() {
                    if (isLoaded) {
                        ProductServiceAsync Service =
                                ServiceFactory.getService(ProductReportService.class);
                        Service.getBasicProducts(Dialog.getTxtProduct().getValue(),
                            new AsyncCallback<ArrayList<String>>() {

                                @Override
                                public void onServiceFailure(Throwable ex) {
                                    showError("Error");
                                }

                                @Override
                                public void onServiceSuccess(ArrayList<String> result) {
                                    productList = result;
                                    while(productList.iterator.hasnext())
                                        whereClause.append(" AND PROD = '" + productList.iterator.next() + "'");
                                    isLoaded = true;
                                }
                            });
                        return false;
                    }
                    return true;
                }
            });
        }
       
I wanted this execute query to be executed after the above RPC is success however the below line is executed before RPC.

        ResultSet rs = stmt.executeQuery(whereClause);

Plz let me know if there is anything I have missed.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment