NetTalk Central

Author Topic: Conditional redirect from one form to another.  (Read 5897 times)

CaseyR

  • Sr. Member
  • ****
  • Posts: 448
    • View Profile
    • Email
Conditional redirect from one form to another.
« on: July 31, 2019, 02:45:02 PM »
I am sure there is a simple way to do this but I just can't find it.

On the server side:

the request for Form A is being processed;
if condition 1 is true,  Form A continues to be served;
if not,  Form B is served.

p_web.redirect seems like overkill for a call in the same app/session.  Just hoping there is a simpler method.

Thanks.

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Conditional redirect from one form to another.
« Reply #1 on: July 31, 2019, 06:28:29 PM »
are we talking about popup forms here? or page forms?

Also - where are you coming _from_? (Browses for example have this ability built-in, so it's easier to do from there...)

cheers
Bruce

CaseyR

  • Sr. Member
  • ****
  • Posts: 448
    • View Profile
    • Email
Re: Conditional redirect from one form to another.
« Reply #2 on: August 01, 2019, 07:45:52 AM »
In my case, the source form A is a page, so a browse doesn't really apply.  The conditional target form is also a page.

Thanks.

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Conditional redirect from one form to another.
« Reply #3 on: August 01, 2019, 10:50:04 PM »
If the source is a Page (static page? netWebPage?) then presumably the best place to check the condition is when the page is generated.

Failing that, I'd put code into WebHandler, in _SendFile, check page name there, check condition, and if necessary change page name.

cheers
Bruce

CaseyR

  • Sr. Member
  • ****
  • Posts: 448
    • View Profile
    • Email
Re: Conditional redirect from one form to another.
« Reply #4 on: August 04, 2019, 07:55:00 PM »
Thanks, Bruce

Ultimately, I used your suggestion but it wasn't the simple solution I hoped existed.   The switch condition as well as numerous session values used by both the Source Form and the Target Form were all generated in the Source Form.  So these had to be rewritten as separate procedures that could be called from the Web handler and both forms.  Not particularly difficult, but time consuming.

I am surprised this situation hasn't come up more often.  Ie., user wants to do something normally done with procedure A, but some condition fails,  so send them to procedure B.  An internal redirect that can be called from most of an NT procedure.  If it isn't a big job, it would be a nice function.

Thanks again.


Matthew51

  • Full Member
  • ***
  • Posts: 152
    • View Profile
    • Email
Re: Conditional redirect from one form to another.
« Reply #5 on: August 06, 2019, 12:58:22 PM »
I've done something similar using a "choose page." After a user logs in they may be asked to change their password, accept some legal agreements, or just shown the default news page.

To do this I created a new web page procedure and have my login form go here on a save. On the XHtml tab I have 3 items, all Procedures:
1
Procedure Name: NewsPage
Parameters: p_web
Return Value:
Condition: p_web.gsv('ChangePassword') <> TRUE AND p_web.gsv('ShowAgreements') = 0

2
Procedure Name: ChangePassword
Parameters: p_web
Return Value:
Condition: p_web.gsv('ChangePassword') = TRUE

3
Procedure Name: LegalAgreements
Parameters: p_web
Return Value:
Condition: p_web.gsv('ShowAgreements') = 1

What I have isn't exactly this, but it's close enough to give you an idea.
Contractor with 10+ years of NetTalk experience looking for work.
www.linkedin.com/in/matthew-leavitt
BisWare.ca
Check out my free EasyTime Template