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.