Search code examples
extjssencha-architect

How to pass parameters to Extjs application during its launch?


I am creating a project in extjs using Sencha Architect. It consists of a login application (login.js) which checks for successful login and gets the user's roles and redirects to another application (main.js). I want to pass username and role information into main.js to be accessed by various components for rendering. I am not able to pass these parameters from one application to another, please suggest the right way of doing this.

Thanks


Solution

  • On successfull login and setting the session attribute with the appropriate login info,you are redirecting to some.jsp which is starting point of main.js

    In some.jsp

    <body>
    <%
        String userId = (String)session.getAttribute("userID");
     %>
     <input type="hidden" name="userId" id="userId" value="<%=userId%>"/>
    </body>
    

    So on you can get the login info on loading the viewport of main.js as :

    var username = Ext.get("userID").getValue();
    

    You can then use username throughout the application.