Topic
  • 15 replies
  • Latest Post - ‏2013-02-01T20:52:36Z by mburati
Codeoline
Codeoline
141 Posts

Pinned topic PrePopulate

‏2013-01-24T14:51:42Z |
I am working with 2 tables. I have to get the data from one table into the other.
Working in DSUI I created a get method to get the data from table 1.
I then created a set method to assign the data to a WEF variable I created. I then created an action list and set it to run before the create page. The action list is supposed to assign the data in the WEF variable to the variable in Table 2. I am hopeful that someone in the
forum will be able to see what I need to do to accomplish this. The first page you will see is the list page. If you select Add Registration you will see the create page. When the create page come up the city field will already be populated.

Thank you in advance
Updated on 2013-02-01T20:52:36Z at 2013-02-01T20:52:36Z by mburati
  • mburati
    mburati
    2570 Posts

    Re: PrePopulate

    ‏2013-01-24T15:57:09Z  
    I'm sorry, I don't fully understand or follow what data you're trying to get from where to where.

    In the attached models, it appears to assign the City in the inputs variable for the create operation from an empty (not set) string variable.
    What data were you trying to get and from where, where you're assigning that prior to the create page? If I type in a fake city name into your empty variable builder (eg, "There") then I see it prepopulated in your create page, but it doesn't seem like that's what you would want, and I'm not sure where you're expecting that initial city name to come from.

    ..Mike Burati
    http://www-10.lotus.com/ldd/pfwiki.nsf/
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
  • Codeoline
    Codeoline
    141 Posts

    Re: PrePopulate

    ‏2013-01-24T16:50:21Z  
    • mburati
    • ‏2013-01-24T15:57:09Z
    I'm sorry, I don't fully understand or follow what data you're trying to get from where to where.

    In the attached models, it appears to assign the City in the inputs variable for the create operation from an empty (not set) string variable.
    What data were you trying to get and from where, where you're assigning that prior to the create page? If I type in a fake city name into your empty variable builder (eg, "There") then I see it prepopulated in your create page, but it doesn't seem like that's what you would want, and I'm not sure where you're expecting that initial city name to come from.

    ..Mike Burati
    http://www-10.lotus.com/ldd/pfwiki.nsf/
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
    Ok
    I am trying to get the city name from table 1 into table 2.
    I thought by using a get and set i could "get" the city name from table 1 and "set" it into the variable (dcity) where you hard coded "there".
    I then thought i could get the city name out of dcity and assign it to the city variable in table 2.

    I need to get the city name from table 1 into the dcity variable and get it out of there and into the create page input for city.

    Sorry if i confuse you.
    Caroline
  • mburati
    mburati
    2570 Posts

    Re: PrePopulate

    ‏2013-01-24T22:36:25Z  
    • Codeoline
    • ‏2013-01-24T16:50:21Z
    Ok
    I am trying to get the city name from table 1 into table 2.
    I thought by using a get and set i could "get" the city name from table 1 and "set" it into the variable (dcity) where you hard coded "there".
    I then thought i could get the city name out of dcity and assign it to the city variable in table 2.

    I need to get the city name from table 1 into the dcity variable and get it out of there and into the create page input for city.

    Sorry if i confuse you.
    Caroline
    Sorry, I'm still not sure what you mean by "table 1" into "table 2". Are you referring to DB tables or HTML tables or something else? The sample has no DB tables and there's only one HTML table (the retrieve result rows).

    If you mean copy a piece of data from the results of one operation into the inputs of another operation, then you should be able to skip the intermediate variable and just copy straight from the results of one to the input of the other.

    It's not clear which city you intend to copy though - the results of your retrieve operation is a list of rows. While the sample happens to have all the same city value for every row, that's not likely to happen in a real world use case, so you'll need to decide whether you're just taking that result field from the first row or a specific row or...

    For a very simple example of copying the city from the first row in your result set into the city input in your create input structure, you could change the assignment in your action list from:

    Assignment!DataServices/ZipSC/createRegistration/inputs/Row/city=${Variables/dcity}
    (which was copying an empty variable value into the city inputs of the create operation)

    to

    Assignment!DataServices/ZipSC/createRegistration/inputs/Row/city=${DataServices/ZipSC/retrieveRegistrations/results/RowSet/Row/city}
    (which copies the city field from the first roow in the retrieveRegistrations output (your list page results) into the city field in your createRegistration inputs, so that the city field is prepopulated when the create page is shown).

    I hope that info helps,
    ..Mike Burati
    http://www-10.lotus.com/ldd/pfwiki.nsf/
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
  • Codeoline
    Codeoline
    141 Posts

    Re: PrePopulate

    ‏2013-01-25T14:04:19Z  
    • mburati
    • ‏2013-01-24T22:36:25Z
    Sorry, I'm still not sure what you mean by "table 1" into "table 2". Are you referring to DB tables or HTML tables or something else? The sample has no DB tables and there's only one HTML table (the retrieve result rows).

    If you mean copy a piece of data from the results of one operation into the inputs of another operation, then you should be able to skip the intermediate variable and just copy straight from the results of one to the input of the other.

    It's not clear which city you intend to copy though - the results of your retrieve operation is a list of rows. While the sample happens to have all the same city value for every row, that's not likely to happen in a real world use case, so you'll need to decide whether you're just taking that result field from the first row or a specific row or...

    For a very simple example of copying the city from the first row in your result set into the city input in your create input structure, you could change the assignment in your action list from:

    Assignment!DataServices/ZipSC/createRegistration/inputs/Row/city=${Variables/dcity}
    (which was copying an empty variable value into the city inputs of the create operation)

    to

    Assignment!DataServices/ZipSC/createRegistration/inputs/Row/city=${DataServices/ZipSC/retrieveRegistrations/results/RowSet/Row/city}
    (which copies the city field from the first roow in the retrieveRegistrations output (your list page results) into the city field in your createRegistration inputs, so that the city field is prepopulated when the create page is shown).

    I hope that info helps,
    ..Mike Burati
    http://www-10.lotus.com/ldd/pfwiki.nsf/
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
    I understand your confusion.
    I want to get the city name from the DEALER DB have it populate the city field in the WEF CREATE table which will ultimately end up in the REGISTRATION DB. I am attaching the provider so maybe that will help to clarify what i am trying to do.
  • Codeoline
    Codeoline
    141 Posts

    Re: PrePopulate

    ‏2013-01-25T14:09:03Z  
    • Codeoline
    • ‏2013-01-25T14:04:19Z
    I understand your confusion.
    I want to get the city name from the DEALER DB have it populate the city field in the WEF CREATE table which will ultimately end up in the REGISTRATION DB. I am attaching the provider so maybe that will help to clarify what i am trying to do.
    Sorry here is the file.
  • Codeoline
    Codeoline
    141 Posts

    Re: PrePopulate

    ‏2013-01-25T14:16:18Z  
    • Codeoline
    • ‏2013-01-25T14:09:03Z
    Sorry here is the file.
    One more time.
  • mburati
    mburati
    2570 Posts

    Re: PrePopulate

    ‏2013-01-25T14:50:12Z  
    • Codeoline
    • ‏2013-01-25T14:04:19Z
    I understand your confusion.
    I want to get the city name from the DEALER DB have it populate the city field in the WEF CREATE table which will ultimately end up in the REGISTRATION DB. I am attaching the provider so maybe that will help to clarify what i am trying to do.
    In that case, I believe the answer would be similar to what I described above in the alternate assignment statement, which shows how to copy the results of one field from one service operation result structure into the input field of the create operation's input structure. Look at the statement above and try adjusting it for your operation that retrieves the Dealer city, copying that result field into the create registration input structure.

    I hope that info helps,
    ..Mike Burati
    http://www-10.lotus.com/ldd/pfwiki.nsf/
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
  • Codeoline
    Codeoline
    141 Posts

    Re: PrePopulate

    ‏2013-01-25T16:38:49Z  
    • mburati
    • ‏2013-01-25T14:50:12Z
    In that case, I believe the answer would be similar to what I described above in the alternate assignment statement, which shows how to copy the results of one field from one service operation result structure into the input field of the create operation's input structure. Look at the statement above and try adjusting it for your operation that retrieves the Dealer city, copying that result field into the create registration input structure.

    I hope that info helps,
    ..Mike Burati
    http://www-10.lotus.com/ldd/pfwiki.nsf/
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
    I have tried everything i know to get that data to pre-populate the table and non of them work.
    I dont know why my file is not uploading. I am going to try and attach it one more time.
    This is the code that i am using to get the information from the DEALER table.
    Do you see anything the matter with it?

    public static void setGlobalVars (WebAppAccess webAppAccess) throws ClassNotFoundException, SQLException {
    try {

    HashMap<String, String> dealerMap = getDealerInfo(webAppAccess,"0090");
    webAppAccess.getVariables().setString("dealer_num", dealerMap.get("dealer_num"));
    webAppAccess.getVariables().setString("city", dealerMap.get("city"));

    }
    catch (ClassNotFoundException e) {
    throw e;
    }
    catch (SQLException e) {
    throw e;
    }
    return;
    }
    //
    public static HashMap<String, String> getDealerInfo (WebAppAccess webAppAccess, String dealerNo)
    throws ClassNotFoundException, SQLException {
    // IXml dealerXML = null;
    HashMap<String, String> dealerMap = new HashMap<String, String>();
    try {
    String selectSQL = "select dealerno, city from deal where dealerno = '" + dealerNo + "'";
    CallSQL callSQL = new CallSQL();
    Class.forName(callSQL.getSQLClass());
    Connection con = DriverManager.getConnection(callSQL.getSQLUrl(webAppAccess,"DEALER"));

    Statement stmt = con.createStatement();
    ResultSet rs = stmt.executeQuery(selectSQL);
    // dealerXML = XmlUtil.create("row");
    while (rs.next()) {
    dealerMap.put("dealer_num", trimSpace(rs.getString("dealerno")));
    dealerMap.put("city", trimSpace(rs.getString("city")));

    }

    }
    catch (ClassNotFoundException e) {
    throw e;
    }
    catch (SQLException e) {
    throw e;
    }
    return dealerMap;

    }
  • Codeoline
    Codeoline
    141 Posts

    Re: PrePopulate

    ‏2013-01-30T14:17:14Z  
    • mburati
    • ‏2013-01-25T14:50:12Z
    In that case, I believe the answer would be similar to what I described above in the alternate assignment statement, which shows how to copy the results of one field from one service operation result structure into the input field of the create operation's input structure. Look at the statement above and try adjusting it for your operation that retrieves the Dealer city, copying that result field into the create registration input structure.

    I hope that info helps,
    ..Mike Burati
    http://www-10.lotus.com/ldd/pfwiki.nsf/
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
    Is it possible to send you a private message?
  • Codeoline
    Codeoline
    141 Posts

    Re: PrePopulate

    ‏2013-02-01T14:21:12Z  
    • mburati
    • ‏2013-01-25T14:50:12Z
    In that case, I believe the answer would be similar to what I described above in the alternate assignment statement, which shows how to copy the results of one field from one service operation result structure into the input field of the create operation's input structure. Look at the statement above and try adjusting it for your operation that retrieves the Dealer city, copying that result field into the create registration input structure.

    I hope that info helps,
    ..Mike Burati
    http://www-10.lotus.com/ldd/pfwiki.nsf/
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
    I have a HASMAP that I am using to get “city” and “state” information from a database.
    I am then storing the information from the hashmap into variables "city" and "state" that were created with WEF variable builders. My goal is to take this information from the variables and have it pre-populate the WEF create table. To do this I assigned the variables to the create table using a WEF Action Builder. The problem is the information appears to be disappearing from the variable before the assignment is run. I am hopeful that someone will see what I have done wrong and or maybe tell me if there is a better way of doing this. I created a small model that does the same thing and am hopeful that it will upload today.
  • mburati
    mburati
    2570 Posts

    Re: PrePopulate

    ‏2013-02-01T15:40:40Z  
    • Codeoline
    • ‏2013-02-01T14:21:12Z
    I have a HASMAP that I am using to get “city” and “state” information from a database.
    I am then storing the information from the hashmap into variables "city" and "state" that were created with WEF variable builders. My goal is to take this information from the variables and have it pre-populate the WEF create table. To do this I assigned the variables to the create table using a WEF Action Builder. The problem is the information appears to be disappearing from the variable before the assignment is run. I am hopeful that someone will see what I have done wrong and or maybe tell me if there is a better way of doing this. I created a small model that does the same thing and am hopeful that it will upload today.
    I didn't have time to look through all of it, but on a brief skim it looks to me like you're setting variables in the provider model and then trying to read variables with the same name, but in the consumer model. By default, variables are scoped to the model/webapp they're in.

    Typically how you would do this is return the values from one operation and then use them in inputs to another operation, if that's what you're trying to do, rather than try to share data globally across layers like that. If you do that, you should also be able to make your provider stateless (in the provider's Service Definition builder) so the app will perform/scale better.

    I hope that info helps,
    ..Mike Burati
    http://www-10.lotus.com/ldd/pfwiki.nsf/
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
  • Codeoline
    Codeoline
    141 Posts

    Re: PrePopulate

    ‏2013-02-01T16:57:59Z  
    • mburati
    • ‏2013-02-01T15:40:40Z
    I didn't have time to look through all of it, but on a brief skim it looks to me like you're setting variables in the provider model and then trying to read variables with the same name, but in the consumer model. By default, variables are scoped to the model/webapp they're in.

    Typically how you would do this is return the values from one operation and then use them in inputs to another operation, if that's what you're trying to do, rather than try to share data globally across layers like that. If you do that, you should also be able to make your provider stateless (in the provider's Service Definition builder) so the app will perform/scale better.

    I hope that info helps,
    ..Mike Burati
    http://www-10.lotus.com/ldd/pfwiki.nsf/
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
    Well I dont think i can go stateless and the data is not being used anywhere else. Do you have any other ideas?

    Thank You
  • mburati
    mburati
    2570 Posts

    Re: PrePopulate

    ‏2013-02-01T17:58:25Z  
    • Codeoline
    • ‏2013-02-01T16:57:59Z
    Well I dont think i can go stateless and the data is not being used anywhere else. Do you have any other ideas?

    Thank You
    It looks like you're trying to pass data from the Consumer to the Provider (the city and state in the second operation's inputs) that the Provider first looks up for the Consumer, so the right way to do that would be to pass it back from the provider to the consumer in the first place, in the first operation that looks up that data (currently called setGlobals in your sample models).

    If you really want to use globals instead, then try Shared Variable, which allows you to share variables across models. I don't personally like or recommend shared variable as it can enable and encourage bad programming practices like globals, but if you really must do that, then that variable will allow you to use the same variable name in multiple models (and even multiple portlets) and share them via the session.

    I hope that info helps,
    ..Mike Burati
    http://www-10.lotus.com/ldd/pfwiki.nsf/
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
  • dmelby
    dmelby
    131 Posts

    Re: PrePopulate

    ‏2013-02-01T19:44:38Z  
    • mburati
    • ‏2013-02-01T17:58:25Z
    It looks like you're trying to pass data from the Consumer to the Provider (the city and state in the second operation's inputs) that the Provider first looks up for the Consumer, so the right way to do that would be to pass it back from the provider to the consumer in the first place, in the first operation that looks up that data (currently called setGlobals in your sample models).

    If you really want to use globals instead, then try Shared Variable, which allows you to share variables across models. I don't personally like or recommend shared variable as it can enable and encourage bad programming practices like globals, but if you really must do that, then that variable will allow you to use the same variable name in multiple models (and even multiple portlets) and share them via the session.

    I hope that info helps,
    ..Mike Burati
    http://www-10.lotus.com/ldd/pfwiki.nsf/
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
    I'm working with codeoline on this issue. The main issue that we are trying to use "global" variables for is to eliminate some additional and unnecessary trips to the database. When the user logs in, we grab their user name from the portal login information. Then we would like to go to a database to retrieve other information about that user: city, state, zip, etc. and store those values to some type of "global" variable(s) for later retrieval (for instance, a session variable, cookie, etc). Here's a web page that describes session variables for PHP: http://www.w3schools.com/php/php_sessions.asp The information stored to each users global variable is different depending on who they are. It would be nice to only do this once, preferably when they first access the portlet. When the user wants to add a record, we would pre-populate some of the fields on the screen with the data stored in the global variables. The user could go ahead and change the values on the add screen, but when they save the record it would only store it to the database and not to the global variables. At the point that the user adds another record, the values from the global variables would again pre-populate the fields.

    We are open to suggestions, and the model and methodology that we have proposed is our attempt to accomplish the task at hand. We are very new to this, so an example model or simple explanation would be very helpful.
  • mburati
    mburati
    2570 Posts

    Re: PrePopulate

    ‏2013-02-01T20:52:36Z  
    • dmelby
    • ‏2013-02-01T19:44:38Z
    I'm working with codeoline on this issue. The main issue that we are trying to use "global" variables for is to eliminate some additional and unnecessary trips to the database. When the user logs in, we grab their user name from the portal login information. Then we would like to go to a database to retrieve other information about that user: city, state, zip, etc. and store those values to some type of "global" variable(s) for later retrieval (for instance, a session variable, cookie, etc). Here's a web page that describes session variables for PHP: http://www.w3schools.com/php/php_sessions.asp The information stored to each users global variable is different depending on who they are. It would be nice to only do this once, preferably when they first access the portlet. When the user wants to add a record, we would pre-populate some of the fields on the screen with the data stored in the global variables. The user could go ahead and change the values on the add screen, but when they save the record it would only store it to the database and not to the global variables. At the point that the user adds another record, the values from the global variables would again pre-populate the fields.

    We are open to suggestions, and the model and methodology that we have proposed is our attempt to accomplish the task at hand. We are very new to this, so an example model or simple explanation would be very helpful.
    Shared Variable uses the session, and plain WEF Variables use the session too (the latter just isn't shared across models or portlets) so if that's the way you would like to do it, it should work, it's just not recommended, similar to how sharing data via globals in other high level languages wouldn't be the recommended way to pass data around. That said, you can do it if you need to get this accomplished quickly.

    When you store the city and state in a variable in the Consumer portlet, you are storing it in the session for later use as you suggested, so you only need to call the operation that retrieves it once. If you got the data to store it in those variables from the results of a one time getData operation that would be more OO/SOA/layered than calling an operation that sets them globally and then reaching out for those global vars rather than getting them from the results of that one time operation in the first place. You can use the globals approach, it's just not a best practice, whether writing something with WEF or Java or other high level language. When A calls B and wants some data that B retrieved, it's typically best to have the public method or operation of B return that data rather than have A then go reach out and find where B stuck the data in a global way (whether writing two Java classes or two WEF models). I hope that explanation clears it up a little and again, it's not a requirement just a better practice than using globals. Which way you choose to get the data back to the consumer (Shared Variable or changing your initial service operation to return that data for the consumer to cache for later use) is your choice.

    I hope that info helps,
    ..Mike Burati
    http://www-10.lotus.com/ldd/pfwiki.nsf/
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.