Topic
  • 10 replies
  • Latest Post - ‏2013-08-01T19:06:29Z by kevintap
Sathish_Ravula
Sathish_Ravula
14 Posts

Pinned topic How to add custom buttons and fuctionality in data page?

‏2013-07-25T14:56:49Z |

Hi

Currently i am working with web experience factory. My Requirement is  Accepting and Rejecting New Dealers Requests

For this i took one Data provider model and List View consumer model.  In consumer i got list & Details Page. In list page i got data from database table(New_dealers).. I want to add Accept & Reject Buttons to every row of  List Page .but i am unable to add these buttons. when I click on Accept button the particular record will move another table(Present_Dealers).

Any amount of help is appreciable

Thanks in Advance

Sathish

  • DunnoJack
    DunnoJack
    32 Posts

    Re: How to add custom buttons and fuctionality in data page?

    ‏2013-07-25T15:36:58Z  

    I've had similar requirements. What I typically do:

    • Add an additional column that is blank using Data Column Modifier builder.
      • Call the new column something like "zRecordActionButtons" (I prefix 'z' to find these elemnts quickly, no other meaning)
    • Use a Button builder to display your button in this new column
      • When  you choose "zRecordActionButtons" as the spot where the button exists, it will loop for every row.
    • The button will point to some sort of Action List that you put your logic into to manipulate the tables.
      • Your Action List should accept some argument so you know what row to modify.
      • So, the button you add should pass the Action List this argument.
        • Get the value from the "loopvar" variable, so it will be that particular row's data. 
    • Refresh screen after your Action List finishes
      • smart refresh, or specific spot refreshing, etc

    Good luck!

  • Sathish_Ravula
    Sathish_Ravula
    14 Posts

    Re: How to add custom buttons and fuctionality in data page?

    ‏2013-07-26T17:59:07Z  
    • DunnoJack
    • ‏2013-07-25T15:36:58Z

    I've had similar requirements. What I typically do:

    • Add an additional column that is blank using Data Column Modifier builder.
      • Call the new column something like "zRecordActionButtons" (I prefix 'z' to find these elemnts quickly, no other meaning)
    • Use a Button builder to display your button in this new column
      • When  you choose "zRecordActionButtons" as the spot where the button exists, it will loop for every row.
    • The button will point to some sort of Action List that you put your logic into to manipulate the tables.
      • Your Action List should accept some argument so you know what row to modify.
      • So, the button you add should pass the Action List this argument.
        • Get the value from the "loopvar" variable, so it will be that particular row's data. 
    • Refresh screen after your Action List finishes
      • smart refresh, or specific spot refreshing, etc

    Good luck!

    Hi Dunno,

    Thanks for your reply. Now i am able to move  that particular row into other table(Present_Dealers). Now i'm unable to  perform delete that Particular row from the table (new_dealers).

    i need to perform two operations at a time when i clicked on Accept  button( moving the record to another table(present_dealers) & delete from the table(new_dealers) )

    Please suggest me  any solution

     

    Thanks in Advance

    Satish

     

  • kevintap
    kevintap
    748 Posts

    Re: How to add custom buttons and fuctionality in data page?

    ‏2013-07-26T21:27:48Z  

    Hi Dunno,

    Thanks for your reply. Now i am able to move  that particular row into other table(Present_Dealers). Now i'm unable to  perform delete that Particular row from the table (new_dealers).

    i need to perform two operations at a time when i clicked on Accept  button( moving the record to another table(present_dealers) & delete from the table(new_dealers) )

    Please suggest me  any solution

     

    Thanks in Advance

    Satish

     

    It sounds like you need to update multiple database tables in the context of a single request.  (Adding the row to the new table and removing from the old table.)  I would recommend looking at the SQL Transaction builder, it can execute multiple SQL updates atomically in a single request and give you the ability to commit or rollback the transaction.

    http://www-10.lotus.com/ldd/pfwiki.nsf/dx/11142008041818PMWEBSYZ.htm

    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.

  • Sathish_Ravula
    Sathish_Ravula
    14 Posts

    Re: How to add custom buttons and fuctionality in data page?

    ‏2013-07-30T11:53:01Z  
    • kevintap
    • ‏2013-07-26T21:27:48Z

    It sounds like you need to update multiple database tables in the context of a single request.  (Adding the row to the new table and removing from the old table.)  I would recommend looking at the SQL Transaction builder, it can execute multiple SQL updates atomically in a single request and give you the ability to commit or rollback the transaction.

    http://www-10.lotus.com/ldd/pfwiki.nsf/dx/11142008041818PMWEBSYZ.htm

    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.

    Hi kevin,

      I am unable to use this example. in my example i am using SQL Datasource, SQL Statement, SQL Transaction.

    Here My Queries..

    1.  insert into present_dealers (dealer_name,mobile,email,showroom_name,showroom_no,address,city,state) select     dealer_name,mobile,email,Showroom_name,Showroom_no,Address,City,State from new_dealers where s_no=?

    2. delete from new_dealers where s_no=?

    this two operations are i want to perform when i click Accept button. in SQL Transaction I have given Transaction steps like first step is

    insert and second step is delete.

    Thanks,

    Sathish

     

     

  • kevintap
    kevintap
    748 Posts

    Re: How to add custom buttons and fuctionality in data page?

    ‏2013-07-30T16:40:51Z  

    Hi kevin,

      I am unable to use this example. in my example i am using SQL Datasource, SQL Statement, SQL Transaction.

    Here My Queries..

    1.  insert into present_dealers (dealer_name,mobile,email,showroom_name,showroom_no,address,city,state) select     dealer_name,mobile,email,Showroom_name,Showroom_no,Address,City,State from new_dealers where s_no=?

    2. delete from new_dealers where s_no=?

    this two operations are i want to perform when i click Accept button. in SQL Transaction I have given Transaction steps like first step is

    insert and second step is delete.

    Thanks,

    Sathish

     

     

    That sounds like the right approach, and it sounds like you have your SQL Transaction builder configured correctly.  Did you have a specific question or issue with your model?

  • Sathish_Ravula
    Sathish_Ravula
    14 Posts

    Re: How to add custom buttons and fuctionality in data page?

    ‏2013-07-31T08:28:37Z  
    • kevintap
    • ‏2013-07-30T16:40:51Z

    That sounds like the right approach, and it sounds like you have your SQL Transaction builder configured correctly.  Did you have a specific question or issue with your model?

    Hi Kevin,

    Thank you for your response. Here my problem is how to call this SQL Transaction and how to pass parameter(s_no) from consumer model ?

    Thanks,

    Satish

     

  • kevintap
    kevintap
    748 Posts

    Re: How to add custom buttons and fuctionality in data page?

    ‏2013-07-31T17:21:54Z  

    Hi Kevin,

    Thank you for your response. Here my problem is how to call this SQL Transaction and how to pass parameter(s_no) from consumer model ?

    Thanks,

    Satish

     

    To call this SQL Transaction from a consumer model, you would need to add a method or action list in your provider model to call the SQL Transaction steps.  Then in the provider model, you would add a Service Operation builder to expose that method or action list as a service operation.  If the method or action list accepts any arguments, these arguments will be represented in the input structure of the Service Operation that is created.  So, you can declare that you require a s_no argument to the method or action list and this should be available to pass the data value from the consumer model.

    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.

  • Sathish_Ravula
    Sathish_Ravula
    14 Posts

    Re: How to add custom buttons and fuctionality in data page?

    ‏2013-08-01T17:40:03Z  
    • kevintap
    • ‏2013-07-31T17:21:54Z

    To call this SQL Transaction from a consumer model, you would need to add a method or action list in your provider model to call the SQL Transaction steps.  Then in the provider model, you would add a Service Operation builder to expose that method or action list as a service operation.  If the method or action list accepts any arguments, these arguments will be represented in the input structure of the Service Operation that is created.  So, you can declare that you require a s_no argument to the method or action list and this should be available to pass the data value from the consumer model.

    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.

    Hi kevin,

    Here i am unable to execute sql statements. First i am running just  provider model.

    As per your suggestion added Action List and Service Operation.

    I think, i am unable to call proper methods in Action List builder. Here i am passing s_no as argument but i did'nt  get any error and Data Base tables are not updated.

    For your reference i attached my provider model.

    looking forward to your reply

    Thanks in advance

    satish

    Attachments

  • DunnoJack
    DunnoJack
    32 Posts

    Re: How to add custom buttons and fuctionality in data page?

    ‏2013-08-01T19:01:42Z  

    Hi kevin,

    Here i am unable to execute sql statements. First i am running just  provider model.

    As per your suggestion added Action List and Service Operation.

    I think, i am unable to call proper methods in Action List builder. Here i am passing s_no as argument but i did'nt  get any error and Data Base tables are not updated.

    For your reference i attached my provider model.

    looking forward to your reply

    Thanks in advance

    satish

    Are you trying to do everything in one model? If so, I don't think that is the proper way to set this up... Take a look at the example png I've attached.

    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM (stolen from kevintap ;) )

    Attachments

  • kevintap
    kevintap
    748 Posts

    Re: How to add custom buttons and fuctionality in data page?

    ‏2013-08-01T19:06:29Z  

    Hi kevin,

    Here i am unable to execute sql statements. First i am running just  provider model.

    As per your suggestion added Action List and Service Operation.

    I think, i am unable to call proper methods in Action List builder. Here i am passing s_no as argument but i did'nt  get any error and Data Base tables are not updated.

    For your reference i attached my provider model.

    looking forward to your reply

    Thanks in advance

    satish

    I would recommend that you review the sample model attached to the article I previously referenced.  The SQLTransactionService model in this sample contains 2 Method builders which handle executing the SQL transaction.

    In order to execute the SQL transaction, you first must call the initialize method on the SQL Transaction builder's LJO.  Then you can optionally call the execute method on the SQL Transaction builder's LJO.  Calling the execute method will execute each of the transaction steps once in the sequence that they are defined in in the SQL Transaction builder.  Alternatively, you can call the execute method and provide the name of a step in the SQL transaction.  (This would be useful if you wanted to manually control the steps involved in the transaction.)  After that, you must either call the commit or the rollback method on the LJO.

    Here is a method from the model which handles this work:

    {
        // initialize the transaction context
        webAppAccess.callMethod("transaction2.initialize");
     
        // set the input variables for the updateTravelerInfoSQL and updateTravelPrefsSQL SQL Calls
        webAppAccess.getVariables().setXml("updateTravelerInfoSQLInputs", travelerDetails);
        webAppAccess.getVariables().setXml("updateTravelPrefsSQLInputs", travelerDetails);
        try {
            // invoke all transaction steps
            webAppAccess.callMethod("transaction2.execute");
     
            // everything worked - commit the transaction
            webAppAccess.callMethod("transaction2.commit");
            return true;
        } catch (Throwable t) {
            // something failed - rollback the transaction
            webAppAccess.callMethod("transaction2.rollback");
            return false;
        }
    }

     

    Also demonstrated in the referenced model is a way to call one or more of the transaction steps in a loop.

    {
        // initialize the transaction context
        webAppAccess.callMethod("transaction.initialize");
     
        // initially set the commit flag to true
        boolean commit = true;
     
        // loop through all of the travelers passed to the service operation
        Iterator iterator = travelers.getChildren().iterator();
        while ((commit) && (iterator.hasNext())) {
            // get a single traveler from the iterator over the travelers variable
            IXml traveler = (IXml)iterator.next();
     
            // set the input variable for the updateTravelersSQL SQL Call
            webAppAccess.getVariables().setXml("updateTravelersSQLInputs", traveler);
            try {
                // invoke the transaction step
                webAppAccess.callMethod("transaction.execute", "updateTravelersSQL");
            } catch (Throwable t) {
                // something failed, set the commit flag to false
                commit = false;
            }
        }
     
        // check the commit flag to see if we should commit or rollback the transaction
        if (commit) {
            // everything worked - commit the transaction
            webAppAccess.callMethod("transaction.commit");
        } else {
            // something failed - rollback the transaction
            webAppAccess.callMethod("transaction.rollback");
        }
     
        // return the commit flag to indicate success or failure
        return commit;
    }

     

    So, you're missing 2 important pieces in your model here.  First, after you're done with the transaction, you must call either commit or rollback.  Second, you need to assign your s_no input value into the arguments of the SQL statements before calling them.  As defined in your model, the input value should be assigned to:

    ${Variables/insertXmlInputs/argInput1}

    and

    ${Variables/deleteInputs/S_NO}

     

    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.