Alpha Video Training
Results 1 to 20 of 20

Thread: State Variable Passing To An Embedded UX Component

  1. #1
    Member
    Real Name
    Steven
    Join Date
    Oct 2011
    Posts
    633

    Default State Variable Passing To An Embedded UX Component

    I have a textbox control named HoldLoginValue in my login UX and in the OnLogin Server side event I have the below code to set that value. I have the main mobile app UX embedded in my login UX. How do I get that HoldLoginValue to pass into the embedded main mobile app UX so I can filter on it? I want to have HoldLoginValue to be a state variable.

    dim CurrentUserName as c
    dim CheckUserExist as c
    dim sql as c
    dim args as sql::arguments
    Dim cn as sql::connection
    dim sqlCommand as c
    flag = cn.open("::name::connection")


    if e.username <> ""
    dim args as sql::Arguments
    args.set("EMAIL",e.username)
    HoldLoginValue = sql_lookup("::name::connection", "table", "EMAIL = :EMAIL","pvvid",args)
    end if


    'To capture Last Login date and time
    '0: Initialize connections
    dim globalcn as sql::connection
    flag = globalcn.open("::name::connection")

    '1: Log entry into system
    dim sql as c
    dim args as sql::arguments
    args.add("CurrentUserName",a5ws_getcurrentuser()) 'Gets logged in user
    flag = globalcn.execute("UPDATE table SET LAST_LOGIN = getdate() where email = :CurrentUserName",args)
    flag = globalcn.Execute(sql, args)

    'x: Clean u
    globalcn.FreeResult()
    globalcn.Close()
    delete globalcn

  2. #2
    "Certified" Alphaholic
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    7,551

    Default Re: State Variable Passing To An Embedded UX Component

    Try this...

    e._state.HoldLoginValue = HoldLoginValue

    These comments are at the end of the text in the onLogin event...

    'You can set 'state' variables in this event. The value of any state variables will be available in all subsequent ajax callbacks.
    'To set a state variable:
    'e._state.myvar1 = "value1"
    'e._state.myvar2 = "value2"

  3. #3
    Member
    Real Name
    Steven
    Join Date
    Oct 2011
    Posts
    633

    Default Re: State Variable Passing To An Embedded UX Component

    Ok, does e._state.HoldLoginValue pass into the Embedded UX Component? If so, in a List Component do I filter based on e._state.HoldLoginValue or do I need to set up and agrument in the list and set that Run-Time argument equal to e._state.HoldLoginValue?

  4. #4
    "Certified" Alphaholic
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    7,551

    Default Re: State Variable Passing To An Embedded UX Component

    I believe client-side state variables belong to the {dialog.Object}. You'd have to do something like this in the child component...

    Code:
    var pObj = {dialog.Object}.getParentObject();
    var HoldLoginValue = pObj.stateInfo['HoldLoginValue'];
    {dialog.Object}.setValue('HoldLoginValue',HoldLoginValue,false);
    and then base your filter argument on that HoldLoginValue control. I don't think you can set up an argument based on a state varaible.

  5. #5
    Member
    Real Name
    Steven
    Join Date
    Oct 2011
    Posts
    633

    Default Re: State Variable Passing To An Embedded UX Component

    You mean this code has to run in the On-Load Complete Javascript in the embedded object, that is embedded in the login UX Component? Then the HoldLoginValue variable is available in the Main UX Component (Embedded UX) whenever I want to call it?

  6. #6
    Member
    Real Name
    Steven
    Join Date
    Oct 2011
    Posts
    633

    Default Re: State Variable Passing To An Embedded UX Component

    Do I place this in the on-load complete javascript in the embedded UX Component?

  7. #7
    "Certified" Alphaholic
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    7,551

    Default Re: State Variable Passing To An Embedded UX Component

    I'd put it into the Client-side onRenderComplete event of the Child UX.

  8. #8
    Member
    Real Name
    Steven
    Join Date
    Oct 2011
    Posts
    633

    Default Re: State Variable Passing To An Embedded UX Component

    I added that to the onRenderComplete event in the embedded UX control. In the List Control I have this filter statement ID = :HoldLoginValue. The error saids argument values were referenced in the sql query but were not found in the argument list. Seems it doesnt recognize that argument value in the filter, how do I call HoldLoginValue in the Filter Statement in the List Control?

  9. #9
    "Certified" Alphaholic
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    7,551

    Default Re: State Variable Passing To An Embedded UX Component

    You need to create an Argument in the same UX where you List resides. You can do this in a couple of place.
    In the List Control, Data Source tab, the very first property is Arguments. Open that and create a new argument. I tend to name things so I know what I'm dealing with, so I'd create an argument with the name argHoldLoginValue, data type Character, Get argument value from is set to Set value at Run-time, and then for the Value you will select the UX Control that holds the HoldLoginValue.

    The same Arguments dialog can be accessed from the UX Properties and from the UX Controls section... from the Menu dropdown (beside the Mobile checkbox).

    Remember that all this stuff... the onRenderComplete, the drawing the of List... it's all happening fast and all over the place. It may be that you need to set your List to "Delay render till explicit refresh" and then in OnRenderComplete perform a .refreshListData() on the List. This would allow the UX to settle down and ensure the argument value is in place before the List tries to use it.

  10. #10
    Member
    Real Name
    Steven
    Join Date
    Oct 2011
    Posts
    633

    Default Re: State Variable Passing To An Embedded UX Component

    In the drop down for Value (under Set Value at RunTime) it doesnt show the UX Control for HoldLoginValue. That UX Control is in my Login UX, whereas the List Control is in my App UX that is embedded in the Login UX. Should it show up in the drop down list, or do I just type in HoldLoginValue?

  11. #11
    "Certified" Alphaholic
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    7,551

    Default Re: State Variable Passing To An Embedded UX Component

    You have... or should have... this code in your embedded UX...

    Code:
    var pObj = {dialog.Object}.getParentObject();
    var HoldLoginValue = pObj.stateInfo['HoldLoginValue'];
    {dialog.Object}.setValue('HoldLoginValue',HoldLoginValue,false);
    This code reaches into the parent UX, gets the value sitting in the parent state var "HoldLoginValue", and sets that value into the embedded UX control "HoldLoginValue".

    The argument can then get that value from that control.

    If you don't have a control named "HoldLoginValue" in your embedded UX... then create one. You can always set it's client-side show/hide expression to 1=2 to hide it after you have things working.

  12. #12
    Member
    Real Name
    Steven
    Join Date
    Oct 2011
    Posts
    633

    Default Re: State Variable Passing To An Embedded UX Component

    I have that code in the onRenderComplete event on client side in the embedded UX, and I have a HoldLoginValue text box in the embedded UX. However, the list control isnt filtering. In getParentObject(); do I have to put the name of the parent UX within the () ?

  13. #13
    Member
    Real Name
    Steven
    Join Date
    Oct 2011
    Posts
    633

    Default Re: State Variable Passing To An Embedded UX Component

    It appears that the HoldLoginValue has the correct value but the List Control isnt filtering on that value for some reason.

  14. #14
    "Certified" Alphaholic
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    7,551

    Default Re: State Variable Passing To An Embedded UX Component

    Add a refreshListData to your onRenderComplete event. Your List is rendering before the HoldLoginValue has been set.

    Code:
    var pObj = {dialog.Object}.getParentObject();
    var HoldLoginValue = pObj.stateInfo['HoldLoginValue'];
    {dialog.Object}.setValue('HoldLoginValue',HoldLoginValue,false);
    {dialog.object}.refreshListData('YourListNameGoesHere');

  15. #15
    Member
    Real Name
    Steven
    Join Date
    Oct 2011
    Posts
    633

    Default Re: State Variable Passing To An Embedded UX Component

    I inserted that but it still isnt filtering the list. Like I said, it shows that HoldLoginValue is the correct value. In arguments in the list control, I have an argument called argHoldLoginValue that is numeric data type then set at runtime. In filter on the list control I have ID = :argHoldLoginValue

  16. #16
    "Certified" Alphaholic
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    7,551

    Default Re: State Variable Passing To An Embedded UX Component

    What is an example of a value for HoldLoginValue?

    What's being rendered for your List? Nothing... or everything?

    I think you need to post your parent and child UX... something's off.

  17. #17
    Member
    Real Name
    Steven
    Join Date
    Oct 2011
    Posts
    633

    Default Re: State Variable Passing To An Embedded UX Component

    Example value is 1. Nothing in the List is being rendered

  18. #18
    "Certified" Alphaholic
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    7,551

    Default Re: State Variable Passing To An Embedded UX Component

    Sorry... it seems that something is going on with how Alpha "sees" data. Remove the false argument from the .setValue() method. Although the value is there, the UX is not registering it as available. Strange behaviour. I'm not crazy about setting a UX dirty, just to get an argument... as I'm sure there will be consequences. Nevertheless... see how it works out.

    Code:
    var pObj = {dialog.Object}.getParentObject();
    var HoldLoginValue = pObj.stateInfo['HoldLoginValue'];
    {dialog.Object}.setValue('HoldLoginValue',HoldLoginValue);
    {dialog.object}.refreshListData('YourListNameGoesHere');
    Last edited by Davidk; 11-30-2017 at 11:26 AM.

  19. #19
    Member
    Real Name
    Steven
    Join Date
    Oct 2011
    Posts
    633

    Default Re: State Variable Passing To An Embedded UX Component

    That seemed to work. Guess if it causes problems in the future then it will show up somewhere

  20. #20
    "Certified" Alphaholic
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    7,551

    Default Re: State Variable Passing To An Embedded UX Component

    Another way to go about this is from the Parent UX side... using the Embedded Object "Argument bindings" property.
    In this case you would still set up the argument in the child UX, but do not fill in the Argument Binding Value... leave it empty. The filter is still in place in the List Control.

    Then, back in the Parent UX, open the Argument bindings dialog - the property of the Embedded UX Control - and you should see a section named "Set Argument Values" with your Argument displayed. Double-click on the Argument and click Insert Field Placeholder. I believe you said you have a TextBox Control in the Parent UX named HoldLoginValue... so you'd select that.

    Doing it this way, you do not need any code in the Child UX onRenderComplete event. The argument value is passed through to the Child UX and used in the List. In a sense, this is a bit cleaner... but, I believe, a bit more limiting. It really depends on your needs.

Similar Threads

  1. State variable syntax question
    By doula in forum Mobile & Browser Applications
    Replies: 3
    Last Post: 08-31-2017, 03:04 PM
  2. How to use a state variable in a a5w page
    By ids-dave in forum Mobile & Browser Applications
    Replies: 2
    Last Post: 05-02-2017, 12:40 PM
  3. Passing a Pointer Dot Variable to another variable
    By preston2 in forum Alpha Five Version 11 - Desktop Applications
    Replies: 7
    Last Post: 07-25-2016, 10:48 PM
  4. syntax for getting value of a state variable in a viewbox in javascript
    By cptutrecht in forum Mobile & Browser Applications
    Replies: 6
    Last Post: 05-06-2016, 04:18 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •