Skip to Content
author's profile photo Former Member
Former Member

Multiselect Listbox (iBrowser Applet)

Hi,

I am working with multiselect listboxes (ibrowser applets). Listbox1 and Listbox2. I need to move information to an from Listbox1. I use <remove item> and <add item> to do this without affecting the underlying database table. This works fine.

My question is this. When the user is finally done manipulating the listboxes and selects <Save Changes>, how do I update the underlying database? Should I store the original listbox info in an array and then store the final listbox entries in another array, compare and determine a <Insert> or <Delete> to the database accordingly? Should I use a XACUTE? If so, how does that work? I am new to xMII. XACUTE seems to be much for such a simple evolution. Another xMII developer within my company seems to think XACUTE. Unfortunately that person is unavailable right now.

Thank you.

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Sep 19, 2007 at 01:32 AM

    Hi Kelly,

    Where do you want this data to be updated? SAP or non-SAP database?

    If you are updating SAP, you must use Xacute query which in turn calls a business logic transaction that executes a remoted enabled function to update the database.

    If the case of non-SAP database, SQL query will do the task for you.

    In your case, since you have to make multiple updates I would reccomend you to use a stored procedure and pass the insert/update values as parameters (comma separated strings or so).

    Steps:

    1) Create the stored procedure

    2) Create a fixed query that calls the stored procedure

    3) Create an icommand applet in your web page (set size as 1) using the above fixed query and with InitialUpdate set to false,

    4) Perform the update by using executeCommand()

    Example:

    if(document.<<appletname>>.executeCommand()) {

    alert("Success"); // Display a message if required

    } else {

    alert(document.<<appletname>>.getLastError());

    }

    John

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 19, 2007 at 11:59 AM

    John,

    Good insight. Thank you.

    I am updated a non-SAP database. My update will be as follows. Determine whether the user role has been added to the listbox then perform a SQL <Insert via a SQL Query> or determine whether a user role has been deleted <Delete via a SQL Query>.

    Maybe my question is more geared towards javascript. Load the initial roles in an array. Then load the final roles in an array. Do some sort of comparison between arrays and perform the SQL function (Insert or Delete). I just wasn't sure whether I should do all this in javascript or some sort of transaction. Seems doing it in javascript may be cleaner. I'm relatively new to xMII and wasn't sure of all the tools I have available to me and what the best approach would be.

    Thank you.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Kelly,

      I understand that you have created arrays for 'delete' and 'insert' from the javascript itself by doing the comparison.

      You are still leaning towards transaction. You don' have to call a Xacute/Transaction to do this. It is like if the only tool you have is a hammer, every problem looks like a nail.

      If you want to update those changes directly to the database from the javascript using an iCommand, you will have to call the INSERT and DELETE statements multiple times (that means you have to kick-off the executeCommand() several times). Calling multiple SQL statements directly from the front end has a disadvantage because if one of these statement fails, it is cumbersome do a rollback of everything . That is why I was suggesting to handle this through the stored procedure and by making a single execution of iCommand from the JavaScript.

      Let me know if you have any questions.

      John

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.