Thursday, June 21, 2012

BUILD FAILED java.lang.NullPointerException at org.tigris.subversion.svnant.Status.execute(Unknown Source)


<property name="svnUrl" value="svn://svn.sample.com/repo/proj" />
<property name="commonSrc" location="${commonBaseDir}/src"/>

Code snippet 01: Incorrect
<svn username="${svnUser}" password="${svnPwd}">
<status path="${svnUrl}" textStatusProperty="status.text" propStatusProperty="status.prop" revisionProperty="revision"/>
</svn>

Code snippet 02: Correct
<svn username="${svnUser}" password="${svnPwd}">
<status path="${commonBaseDir}" textStatusProperty="​status.text" propStatusProperty="​status.prop" revisionProperty="revision"/>
</svn>


When I had this error, I was referring to the wrong path (svnUrl is the path where remote project source code actually lives). I was able to solved it by pointing to the base project (your check out version of the project). It is required to check out the project (will become base project) before you check the "status". "Status" command  read the status information from the local check out project not from the remote server. (One of the mistakes I did ;-)) 


Here is the correct code snippet to print the latest checked out version.

<project name="MyProject" default="init" basedir=".">
    <description>
        Print latest check out revision
    </description>
 
    <taskdef name="svn" classname="org.tigris.subversion.svnant.SvnTask">
        <classpath>
            <pathelement location="/opt/svnant/lib/svnant.jar" />
            <pathelement location="/opt/svnant/lib/svnClientAdapter.jar" />
            <pathelement location="/opt/svnant/lib/svnjavahl.jar" />
            <pathelement location="/opt/svnant/lib/svnkit-1.3.1.jar" />
        </classpath>
    </taskdef>
 
    <!-- set global properties for this build -->
<property name="svnUrl" value="svn://svn.sample.com/opt/repos/proj" />
    <property name="svnUser" value="" />
    <property name="svnPwd" value="" />
    <property name="projectDir" value="my_project" />
    <property name="javac" value="/opt/java/bin/javac" />
    <property name="tomcatShared" value="/opt/tomcat/shared/lib" />
    <property name="webapps" value="/opt/tomcat/webapps" />

  <target name="init">
    <property name="commonBaseDir" value="${projectDir}/common" />
    <property name="commonSrc" location="${commonBaseDir}/src"/>
    <property name="propTest"  location="propTest.mimeType"/>
    <property name="revision"  location="revisionrevisionrevision"/>

 <svn username="${svnUser}" password="${svnPwd}">
<checkout url="${svnUrl}/Common2/branches/SKY-301" destPath="${commonBaseDir}" />
 </svn>

    <echo message="-------------------------S T A T U S--------------------------------" />
 
<svn username="${svnUser}" password="${svnPwd}">
<status path="${commonBaseDir}" textStatusProperty="​status.text" propStatusProperty="​status.prop" revisionProperty="revision"/>
</svn>

    <echo message="${revision}" />
    <!--  Write to a text file-->
    <echo file="output.txt" append="true">Revision:${revision}</echo>
  </target>
</project>

Reference: 
    1. svn.html file in the svnant distribution
    2. http://ant.apache.org/manual/using.html
    3. http://ant.apache.org/manual/Tasks/property.html
Reference for Issues: 
    4. http://subclipse.tigris.org/ds/viewMessage.do?dsForumId=1047&dsMessageId=605389
    5. http://svn.haxx.se/subusers/archive-2005-11/0119.shtml

Labels: ,

Wednesday, June 20, 2012

Stop HTML Form Submit

if(navigator.appName == "Microsoft Internet Explorer") {
    window.document.execCommand('Stop');
}
else
{
    window.stop();
}

Labels:

Tuesday, June 19, 2012

HowTo Delete Cookie Using Javascript


function deleteCookie() {
    var d = new Date();
    document.cookie = "isXLXExportCompleted=true;expires=" + d.toGMTString() + ";" + ";";  
}

HowTo Delete Cookie Using Javascript

Labels:

SubMenu.js


//-----------------------------------------------------
// Display sub menu for the specified module
//-----------------------------------------------------
function showSubMenu(module) {
    if (document.getElementById(module + "SubMenu") != null) {
        document.getElementById(module + "SubMenu").style.top =
                top.frames["navBar"].document.getElementById(module).offsetTop + 22;
        document.getElementById(module + "SubMenu").style.display = "";
    }
    var oWindow = top.frames["apps"];
    setTimeout(function () {
        setupClickHandler(oWindow);
    }, 100);
}

//-----------------------------------------------------
// Setup handlers to hide menu on click in iframes
//-----------------------------------------------------
function setupClickHandler(oWindow) {
    if (oWindow.document.readyState != "complete") {
        setTimeout(function () {
            setupClickHandler(oWindow);
        }, 1000);
        return;
    }
    if (!oWindow.hasClickHandler && oWindow.document.body) {
        oWindow.document.body.attachEvent("onclick", top.hideSubMenu);
        oWindow.hasClickHandler = true;
    }
    var frames = oWindow.document.frames;
    for (var i = 0; frames != null && i < frames.length; i++) {
        setupClickHandler(frames[i]);
    }
}

//-----------------------------------------------------
// Handler for mouse over specified menu item
//-----------------------------------------------------
function menuItemMouseOver(obj) {
    obj.style.background = "#DBE8FC";
}

//-----------------------------------------------------
// Handler for mouse leaving specified menu item
//-----------------------------------------------------
function menuItemMouseOut(obj) {
    obj.style.background = "";
}

//-----------------------------------------------------
// Block default context menu for specified object
//-----------------------------------------------------
function blockContextMenu(obj) {
    var rightclick;
    var e = window.event;
    if (e.which) {
        rightclick = (e.which == 3);
    }
    else if (e.button) {
        rightclick = (e.button == 2);
    }
    if (rightclick) {
        obj.attachEvent ("oncontextmenu", function() {
            return false;
        });
    }
}

Labels: ,

Wednesday, June 13, 2012

Frame/iFrame Element Accessibility/Manipulation


Attach an event method to the unloaded iFrame body
var reportFrame = document.getElementById("reportFrame");
reportFrame.contentWindow.document.getElementsByTagName('body')[0].onmousedown = function () {
top.hideSubMenu("admin", "adminSubMenu");
};

Some Useful Navigation Through iFrame

top.frames[1].frames[tab].document.getElementById(subMenuDivId).style.display = "none";

window.frames[tab].frames["tabs"].showSubMenu();

parent.frames["navBar"].showNav();

document.getElementsByTagName('iframe')[1].contentWindow.frames[0].callSubMenu()

iframe.contentWindow.showSourceDataList()




Labels:

Friday, June 8, 2012

Servlet Handles the Downloading the Attachment


            File attachment = new File(getAttachmentDestDir(reviewCycle), fileName);
            if (attachment.exists()) {
                response.setContentType("application/x-download");
                response.setHeader("Content-Disposition", "attachment; filename=" + fileName);
                response.setHeader("Pragma", "public");
                response.setHeader("Cache-control", "must-revalidate");
                FileInputStream fileInputStream = new FileInputStream(attachment);
                byte[] buffer = new byte[1024];
                int byteCount = 0;
                ServletOutputStream outputStream = response.getOutputStream();
                while ((byteCount = fileInputStream.read(buffer)) >= 0) {
                    outputStream.write(buffer, 0, byteCount);
                }
                outputStream.flush();
                outputStream.close();
                fileInputStream.close();
            }

Labels:

Wednesday, June 6, 2012

Disable Contextmenu On Right Click


function disableContextmenuOnRightClick(obj) {
                var rightclick;
                var e = window.event;
                if (e.which) {
                rightclick = (e.which == 3);
                }
                else if (e.button) {
                rightclick = (e.button == 2);
                }
                // true if right mouse button is clicked.
                if (rightclick) {
                // disable contextmenu
                obj.attachEvent ("oncontextmenu", function() {
                return false;
                });
                }
            }

Labels:

Tuesday, June 5, 2012

The Z-Index CSS Property: A Comprehensive Look | Smashing Coding