Topic
  • 4 replies
  • Latest Post - ‏2012-05-17T17:56:19Z by aryan_raj
aryan_raj
aryan_raj
67 Posts

Pinned topic Multiple Inputs from single

‏2012-05-15T12:56:35Z |
Hi All,

I am using View and Form builder, which generates the UI, UI has some 2 to 3 fields.
All these fields are text inputs, I need to split one of the text input to two inputs, like one text input to one select box and one text input. User will put values in select box and text input, I need to send both these values as one value to the service when user submits.
Any suggestions.
Updated on 2012-05-17T17:56:19Z at 2012-05-17T17:56:19Z by aryan_raj
  • mburati
    mburati
    425 Posts

    Re: Multiple Inputs from single

    ‏2012-05-15T13:30:59Z  
    There are probably multiple ways of doing something like this, and which one is best probably depends on your use case and scenario.

    Here are a couple that come to mind:

    - If this is only for a "create" page (so you only ever combine two inputs into one and don't have to split them back the other way for edit/update pages), for instance, having a prefix of Mrs. Mr. Ms. Dr. in a dropdown before the name, then you might try using Data Column Modifier to "add" a column for the prefix and then combine them in a "Post-Save" method (as specified in Data page, View and Form or DSUI).

    - If you need this to be a separate field for create, update and details pages, then you're probably going to want a separate field defined in the schema that page automation uses to generate all those UIs and then combine/split them in the provider (with code or with a Transform builder or similar). You could either do that in the actual provider or in an intermediate provider model that is a consumer of the ultimate provider with the raw fields, and a provider to your UI consumer, and which serves to split/combine/transform between the UI schema and the backend schema.

    I hope this info helps,
    ..mb1
  • aryan_raj
    aryan_raj
    67 Posts

    Re: Multiple Inputs from single

    ‏2012-05-15T14:05:02Z  
    • mburati
    • ‏2012-05-15T13:30:59Z
    There are probably multiple ways of doing something like this, and which one is best probably depends on your use case and scenario.

    Here are a couple that come to mind:

    - If this is only for a "create" page (so you only ever combine two inputs into one and don't have to split them back the other way for edit/update pages), for instance, having a prefix of Mrs. Mr. Ms. Dr. in a dropdown before the name, then you might try using Data Column Modifier to "add" a column for the prefix and then combine them in a "Post-Save" method (as specified in Data page, View and Form or DSUI).

    - If you need this to be a separate field for create, update and details pages, then you're probably going to want a separate field defined in the schema that page automation uses to generate all those UIs and then combine/split them in the provider (with code or with a Transform builder or similar). You could either do that in the actual provider or in an intermediate provider model that is a consumer of the ultimate provider with the raw fields, and a provider to your UI consumer, and which serves to split/combine/transform between the UI schema and the backend schema.

    I hope this info helps,
    ..mb1
    Thank you for reply mb1, mine would be the first case. But how to combine them in the post save and pass it as one value for the service call.
  • mburati
    mburati
    425 Posts

    Re: Multiple Inputs from single

    ‏2012-05-15T14:56:21Z  
    • aryan_raj
    • ‏2012-05-15T14:05:02Z
    Thank you for reply mb1, mine would be the first case. But how to combine them in the post save and pass it as one value for the service call.
    If you are new to WEF, then it would be good to start by going through the Learning Roadmap on the WEF Wiki at:
    http://www-10.lotus.com/ldd/pfwiki.nsf

    and the ootb samples, tutorials and samples on the WEF Wiki.

    While automation can do a lot for you, when you need to start extending/changing what's automated, it's good to know what the builders are generating and what the APIs are that can be used to tweak what's generated.

    Take for instance, the out of the box Orders Sample.
    Looking at what it generates, it generates a variable called ordersAddOrderInputs to store the input (as XML) for the create operation, and page automation (via the DSUI builder) creates a method that populates that variable (uiCreate_SaveData - you may need to turn on show hidden objects in the Eclipse -> Window -> Preferences -> WEF Preferences to see that) when the form is submitted. A Post Save method is called after page automation has populated that variable, but before it has called the create operation.

    If you create a "Method" builder, it prepopulates it with sample code (commented out) on how to get inputs and variables and how to set variable values.

    So for the Orders sample, if I wanted to create a "PREFIX" column on the create page with a Data Column Modifier, and turn that into a Select with a Data Field Modifier (choosing between Mrs,Ms,Mr,Dr), and then combine that with the STATUS column (since there is no good name col to use in that sample model), the Method code I would write for the Method that I would use as the "Post Save" method in the DSUI or V&F builder would look like the following:

    
    
    { String prefix = webAppAccess.getRequestInputs().getInputValue(
    "PREFIX");   
    // Get the PREFIX input value 
    
    if (prefix != 
    
    null && prefix.length()>0) 
    {                                 
    // If a prefix was specified then 
    // Get the Create Op Input Variable, populated by page automation IXml createOpInputs = webAppAccess.getVariables().getXml(
    "ordersAddOrderInputs"); 
    // Set the STATUS field in that XML, to a combination of prefix plus STATUS input. createOpInputs.setText(
    "STATUS", prefix + 
    " " + webAppAccess.getRequestInputs().getInputValue(
    "STATUS")); 
    } 
    }
    


    I hope that helps, try that out in the Orders sample first and see if you can make that work.

    ..mb1
  • aryan_raj
    aryan_raj
    67 Posts

    Re: Multiple Inputs from single

    ‏2012-05-17T17:56:19Z  
    Thank you mb1, show hidden object preference really helped.