Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Variables lost after submit

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Variables lost after submit

    I have a grid. In the OnSearchPartFilterCompute server side event I am setting a variable using the e.rtc pointer.
    I am accessing the e.rtc pointer variable in the OnSummarySectionRender server side event of the grid.
    When the grid is first initialized and the search data entered and search button is pressed the grid displays the proper records.
    I can edit the records as desired.
    When I submit or cancel changes to the grid I get an error message e.rtc.endDate not found.


    I have tried using the e._state pointer as well, however, after the submit it is gone.


    Basically I am taking an ending date and using it in the OnSummarySectionRender as a mySql query filter argument.
    Also this grid is called from a UX with a link on account no.
    It all works OK in working preview.

    Can anyone shed light on this. I feel like this should be very basic and should work as I have it coded.
    Last edited by frankbicknell; 12-28-2017, 10:19 PM.
    Win 10 64 Development, Win 7 64 WAS 11-1, 2, Win 10 64 AA-1,2, MySql, dbForge Studio The Best MySQL GUI Tool IMHO. http://www.devart.com/dbforge/mysql/studio/

    #2
    Re: Variables lost after submit

    1) For the e.rtc variables in a Grid, I just re-init them in the onGridExecute server side event. That event is supposed to run all the time before any other server event runs. The e.rtc variables do not stick around between callbacks, so they have to be constantly initialized. In Working Preview they might stick around because AA handles global memory quite a bit differently in WP mode then when in server mode. If the e.rtc variable is something simple that does not involve the DB lookups, I just initialize it every time "onGridExecute" runs. If the variable(s) involve looking stuff up in the DB then I conditionally initialize them based on need. It was rather tedious figuring out the code to conditionally initialize them. You would need to see what works for you. I have taken my code from a working Grid and cleaned it up a little and provided it below, as an example. Sorry, if I introduced any errors into the code, but I think you will get the idea of it.

    2) My sample below also includes the server side stuff needed if you want to use "state" variables in a Grid.

    Code:
    function OnGridExecute as v (e as p)
    '-- Setting up e.rtc vars in a Grid.   e.rtc vars do not stick around between callbacks.  
    '-- So, they need to be initialized every time they will be used in a subsequent server-side event durring the current initialization or callback.
    
    e.rtc.currJDate = jDate( date() ) '-- Simple var, always initialized
    
    '-- Sometimes when AA calls this function, 'onGridExecute', it might not be planning on calling any of your Server-Side events that need your e.rtc vars.
    '-- The "e.rv.__FormAction" variable can be used to identify why AA called this function.
    '-- It is a matter of trial and error while running under server mode (not w/p mode) of when it is safe to not bother initializing the e.rtc vars.
    '-- But, you have to run under W/P mode to figure out what the possible values of "e.rv.__FormAction". Unless, you perhaps send back Javascript
    '-- to "alert" the values discovered in the "e.rv.__FormAction" field.
    
    '-- You have to check what values of the following variable Alpha sends into this procedure.  
    '-- I have only listed the values that I discovered AA used for my Grid AND where it was NOT necessary to init my e.rtc vars.
    '-- Your grid will likely have more values than mine, as my Grid does not have all possible Grid features turned on. 
    '-- It could be that you need to initialize your e.rtc vars during some of these events.
    
    if variable_exists("e.rv.__FormAction")
    	dim act as c = new ""
    	act = e.rv.__FormAction
    	select 
    		'-- These are the events where it was not neccessary for me to init e.rtc vars because no subsequent server event needed them.
    		case act = "PageNavigate"
    			end
    		case act = "SetRowsPerPage"
    			end
    		case act = "refreshRow"
    			end
    		case act = "saveGridData"
    			end
    		case act = "submit"
    			end
    		case act = "GenericAjaxCallback"
    			end
    	end select			
    end if
    
    if .not. variable_exists("e.rtc")
    	dim e.rtc as P '-- Sanity check
    end if
    
    '-- If you want to preserve the e.rtc variables between callbacks, you can do it by storing them in 'state' variables.
    '-- But it gets tricky and you have to be careful about refering to the state variables.  
    '-- If the state variables exist in a subsequent callback, you will find them inside "e.rv.__si2".
    '-- If they don't exist yet, then you have to compute them and put them into "e._state".
    '-- If you intend to use the state variables client-side then you have to code your Javascript to safely bailout 
    '-- when the state vars do not exist yet.  Unless the problem has been fixed, AA does not give enough priority to 
    '-- initializing state variables on the client-side. So, if you use Grid state vars client side in an event then it 
    '-- might be that those vars have not been initized yet. You don't want the JS code to stop running because of an
    '-- undefined error, so make sure you check for state var existence before using them in expressions.  There are times
    '-- where the A5 JS library will call a client-side event multiple times.  I'm not sure exactly why.  But counting on
    '-- this fact, one can assume the library will get around to calling the event a second time and the state vars'
    '-- will have been initized by that time.
    
    
    '-- Restoring a pointer variable from state to e.rtc variable...
    dim myStateExists as L
    myStateExists = .f.
    if variable_exists("e.rv")
    	if variable_exists("e.rv.__si2")
    		if variable_exists("e.rv.__si2.MyStateVarPtr")
    			myStateExists = .t.
    			delete e.rtc.MyStateVarPtr  '-- Sanity check
    			dim e.rtc.MyStateVarPtr as P
    			PROPERTY_RECURSE_ASSIGN(e.rtc.MyStateVarPtr, e.rv.__si2.MyStateVarPtr)
    		end if
    	end if
    end if	
    if myStateExists = .f.
    	' Running the component for the first time or this type of callback did not set up the state variable
    	delete e.rtc.MyStateVarPtr	! Sanity Check
    	dim e.rtc.MyStateVarPtr as P
    	Init_my_rtc_vars(e, e.rtc.MyStateVarPtr) 
    	'-- Copy e.rtc vars to state object for: 1) client-side use, and 2) won't have to recompute them on callbacks
    	if .not. variable_exists("e._state")
    		dim e._state as P '-- Create the state vars in this object, so Alpha will populate the real state var that is passed down to browser.
    	end if
    	delete e._state.MyStateVarPtr		! Sanity check
    	dim e._state.MyStateVarPtr as P
    	PROPERTY_RECURSE_ASSIGN(e._state.MyStateVarPtr, e.rtc.MyStateVarPtr)	
    end if
    
    '-- Put any follow-up code here, that you need.
    
    end function

    Comment


      #3
      Re: Variables lost after submit

      Thanks Rich. Miraculously it started working OK. I hate when that happens because I am afraid it may come back.
      Win 10 64 Development, Win 7 64 WAS 11-1, 2, Win 10 64 AA-1,2, MySql, dbForge Studio The Best MySQL GUI Tool IMHO. http://www.devart.com/dbforge/mysql/studio/

      Comment

      Working...
      X