How to create a session and start a page based on URL

1
A webservice request creates the entity module.procesInfo and an association to administration.account. The request returns an URL to the App with a generated ID: http://application/requesthandler/ID Now, we need a function that creates a session when a user opens the URL and starts the page with the module.procesInfo. I understand that a requesthandler can catch this request and I know how to create a session. However, I don't know how to retrieve the module.procesInfo based on the ID in the URL, how to retrieve the associated administration.account and how to show the right page. So to sum up: the function should do the following: retrieve module.procesInfo by using the ID from the URL retrieve the associated administration.account create session when account found show page for module.procesInfo show loginpage when nothing found Does anyone have any experience with this? I have tried the deeplink module but I does not create the session.
asked
2 answers
3

You should take a look at the java code provided with the oAuth Module in the Mendix appstore. There is something done like you described.

answered
1

Thijs,

Below is an example on how to retrieve the account based on an ID in your example. I'm assuming that the ID returned in the URL is an attribute of the procesInfo entity.

import java.util.List;
import com.mendix.core.Core;
import com.mendix.systemwideinterfaces.core.UserAction;
import com.mendix.systemwideinterfaces.core.IMendixObject;
import myfirstmodule.proxies.*;

// BEGIN USER CODE
        String xpathQuery = "//MyFirstModule.procesInfo["+procesInfo.MemberNames.IDAttribute.toString()+"='"+inputID+"']";
        List<IMendixObject> entityList =Core.retrieveXPathQuery(getContext(), xpathQuery);
        if(entityList.get(0)!= null){
            IMendixObject procesInfoObj =entityList.get(0);
            List<IMendixObject> accList = Core.retrieveByPath(getContext(), procesInfoObj, "MyFirstModule."+procesInfo.MemberNames.procesInfo_Account.name());
            if(accList.get(0) != null){
                return accList.get(0);
            }
            else return null;
        }
        return null;
        // END USER CODE

First an xpath query string is created allowing you to retrieve a list of procesInfo objects. The list will consist of 1 record as the ID will be unique. The from the list the first entry is retrieved. Then with the retrieveByPath method the account list is retrieved. This again is just 1 account so the index 0 is returned in this example.

Hope this helps in building your custom request handler.

answered