Pedro Rio

Technology and Me

Pedro Rio

Main menu

Skip to primary content
Skip to secondary content
  • Home
  • About me

Monthly Archives: August 2011

XEO Framework: Auto-Login JSP – Save time developing

Posted on August 10, 2011 by
Reply

I know it’s been a long time since my last post, but I’m back!

One of the things I find myself doing a lot when developing an XEO application is taking down/restarting the application server, because most of the time we’re changing the structure of Java class that’s already been loaded and the server cannot replace the class (at least it happens to me all the time using OC4J and JBoss). Not only you have to wait a while before it’s ready to roll but you have to login to the XEO application to check if what you tried worked or not.

One of the most tedious tasks in this process is manually logging in to XEO (user/pass and then profile). I usually create a small JSP file (FOR DEVELOPMENT PURPORSES ONLY) that automatically makes login, sets the appropriate profile and redirects me to the my desired viewer, usually a Main_Something.xvw viewer. I place in the JSP file in the webapps/default folder and it becomes available at http://localhost:8080/xeo/Main.jsp (or 8888, if you’re using the default OC4J installation).

Usually I place a link to this file in the browsers Bookmarks 😉

Here you can have the JSP source-code (Download at the bottom)

<%@page import="netgest.bo.runtime.EboContext"%>
<%@page import="netgest.bo.runtime.boObjectList"%>
<%@page import="netgest.bo.runtime.boObject"%>
<%@page import="netgest.bo.system.boApplication"%>
<%@page import="netgest.bo.system.boSession"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%

HttpSession session2 = request.getSession(true);
//Check if a XEO session is already in place
if (session2.getAttribute("boSession") == null)
{
        //Default SYSUSER Passwords
	String user = "SYSUSER";
	String pass = "ABC";
	String profile = "admin";
        //Check in the request for user/password combination (and profile) 
	if (request.getParameter("user") != null && request.getParameter("pass") != null){
		user = request.getParameter("user");
		pass = request.getParameter("pass");
		if (request.getParameter("profile") != null)
			profile = request.getParameter("profile");
	}
        //If everything is ok, try to login
	if (user != null && pass != null && profile != null
			&& user.length() > 0 && pass.length() > 0 && profile.length() > 0 )
	{

		boSession oXeoSession = boApplication.getApplicationFromStaticContext("XEO").boLogin(user,pass);

		EboContext loginCtx = null;
		if( boApplication.currentContext().getEboContext() == null ) {
			loginCtx = oXeoSession.createRequestContext( null, null, null );
			boApplication.currentContext().addEboContext( loginCtx );
		}
		else {
			loginCtx = boApplication.currentContext().getEboContext();
		}
                //Find the profile given its name and set it
		boObject workPlace=null;
		boObjectList proflist=boObjectList.list(loginCtx, "select uiWorkPlace where name='"+profile+"'");
		if (proflist.next())
			workPlace=proflist.getObject();

		oXeoSession.setPerformerIProfileBoui( String.valueOf(workPlace.getBoui()) );
		session2.setAttribute( "boSession", oXeoSession );

		if (loginCtx != null)
			loginCtx.close();

	}
	else{
                //Else redirect to Login
		response.sendRedirect("Login.xvw");
	}
}
//In the end, redirect to Viewer 
response.sendRedirect("Path_to_My_Viewer.xvw"); //CHANGE THIS TO YOUR VIEWER
%>

Download the AutoLoginXEO JSP

You can use this code at will, no need to credit me or anything. Although I would like to know if anyone’s using it, feel free to do so.

Stay tunned for more tips on XEO.

 

Posted in Java, Tip, XEO | Tagged Login, Productivity, Tip, XEO, XEO Tip | Leave a reply

Recent Posts

  • Ember – Conventions over Conventions
  • Conditionally import assets in ember-cli-build.js
  • Passing arguments with spaces from a bash script to another script.
  • Add New Relic in Heroku using Play 2 (Java) Application
  • Uploading to Amazon S3 – Response for preflight is invalid (redirect – 307)

Recent Comments

  • teletran on Uploading to Amazon S3 – Response for preflight is invalid (redirect – 307)
  • teletran on Uploading to Amazon S3 – Response for preflight is invalid (redirect – 307)
  • Surya on Uploading to Amazon S3 – Response for preflight is invalid (redirect – 307)
  • bprotsenko on Uploading to Amazon S3 – Response for preflight is invalid (redirect – 307)
  • Saurabh on Uploading to Amazon S3 – Response for preflight is invalid (redirect – 307)

Archives

  • November 2016
  • February 2016
  • January 2016
  • November 2015
  • August 2015
  • July 2015
  • May 2015
  • September 2014
  • January 2014
  • December 2013
  • October 2013
  • August 2013
  • July 2013
  • June 2013
  • March 2013
  • February 2013
  • January 2013
  • May 2012
  • February 2012
  • January 2012
  • December 2011
  • August 2011
  • May 2011

Categories

  • AWS
  • Blog
  • EmberJS
  • Heroku
  • Java
  • JPA
  • Linux
  • Play Framework
  • Security
  • Tip
  • Uncategorized
  • Web Development
  • XEO

Blogroll

  • DZone – Developers Links
  • My XEO Consultant – XEO Wisdom
Proudly powered by WordPress