Javascript Child Window invoking a parent window

Here’s on the most simplest example of demonstrating Child window to parent window communication using javascript.

The trick is in using the javascript function “parent.opener.<js method name to invoke in parent>”

Parent window HTML code

<html>
<body>
<script>
function clickme() {
winopen(’DeleteUserConfirmation.html’,'popup575×505′,
‘WIDTH=575,HEIGHT=500,RESIZABLE=No,SCROLLBARS=YES,
TOOLBAR=NO,LEFT=200,TOP=100′);
}
function winopen(url,stuff,morestuff)
{
var popwin = window.open(url,stuff,morestuff);
if( typeof(popwin) != “undefined” && popwin ) {
popwin.focus();
}
}
function forward(){
alert(’function in parent window’);
}
</script>
<a href=”javascript:clickme()”> Click for Popup Window</a>
</body>
</html>

Child window HTML code

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”>

<html >
<head>
<title>Second Window</title>
</head>
<table cellpadding=”0″ cellspacing=”0″ border=”0″ width=”100%” >
<tr>
<td align=”center”>
<p> </p>
<p><B>What’s your choice?</B></p>
<p><a href=”javascript:parent.opener.forward();window.close();”><b>Call Parent Window</b></a> <a href=”javascript:window.close()”>Close me</a></p>
</td>
</tr>
</table>
</body>
</HTML>

Written by Ravi Nallakukkala on May 18th, 2007 with comments disabled.
Read more articles on Uncategorized.

Hiding dropdown using Javascript

I started working on a task where we need to display drop down based on the text selected in another drop down. The contents of the second drop down are retrieved though an AJAX call.

Here’s and example which does displays a drop down with three values Admin, Student and Teacher. on selection of a teacher, a grades drop down will be displayed.
<html>
<body>

<script TYPE=”text/javascript”>
function handleGrades(obj) {
if(obj.value== 2){
buildGradesDropDown();
document.getElementById(”GradesDropDown”).style.visibility = “visible”;
} else{
document.getElementById(”GradesDropDown”).style.visibility = “hidden”;
}
}

function buildGradesDropDown() {
var dropdown = ‘Grade : <select name=”selGradeId” id=”selGradeId” >’;
//Ajax call should be here, to retrieve the data for the dropdown
dropdown += getOption(’first’,1);
dropdown += getOption(’second’,2);
dropdown += getOption(’third’,3);
dropdown += ‘</select>’;
document.getElementById(”GradesDropDown”).innerHTML = dropdown;
//alert(document.getElementById(”GradesDropDown”).innerHTML);
}

function getOption(value,display) {
return ‘<Option value=’+value+’>’+display +’</option>’;
}
</script>

<form >
Select Role
<select name=”selSchoolId” id=”day” onchange=”handleGrades(this);”>
<option value=”1″>Admin</option>
<option value=”2″>Student</option>
<option value=”3″>Teacher</option>
</select>

<div id=”GradesDropDown” style=”visibility:hidden”>

</div>
</form>
</body>
</html>

Written by Ravi Nallakukkala on May 14th, 2007 with no comments.
Read more articles on Uncategorized.

java.lang.NoSuchMethodError: weblogic.servlet.jsp.StandardTagLib.fakeEmptyBodyTag( Ljavax/servlet/jsp/PageContext; Ljavax/servlet/jsp/tagext/BodyTag;IZ

I was trying to deploy my Ear containing a war file in Weblogic 8.1, got the following exception

java.lang.NoSuchMethodError: weblogic.servlet.jsp.StandardTagLib.fakeEmptyBodyTag(Ljavax/servlet/jsp/PageContext;Ljavax/servlet/jsp/tagext/BodyTag;IZ)V
	at jsp_servlet._login.__login._jspService(__login.java:1016)
	at weblogic.servlet.jsp.JspBase.service(JspBase.java:33)
	at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1053)
	at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:387)
	at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:431)
	at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:28)
	at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
	at com.pearson.ph.phcore.presentation.servlets.CheckLoginFilter.doFilter(CheckLoginFilter.java:76)
	at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
	at com.pearson.ph.phcore.presentation.servlets.CheckLoginFilter.doFilter(CheckLoginFilter.java:76)
	at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
	at com.pearson.ph.itext.presentation.servlets.SessionFilter.doFilter(SessionFilter.java:87)
	at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
	at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6297)
	at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317)
	at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:97)
	at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3575)
	at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2573)
	at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:178)
	at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:151)

Solution
Seems this is an issue with Weblogic server 8.1, when upgraded to Weblogic 8.1 sp4 the problem goes away.

Written by Ravi Nallakukkala on April 18th, 2007 with no comments.
Read more articles on Java/ J2EE and Servers.

IntelliJ Plugin TddTracker

This is one of those plug-in which a developer would love to have in the development environment, the main purpose of this plug-in is report the time taken to execute a JUnit.

Highlights (release 0.4)

Usage

Favorable

Unfavorable

For more information about this tool, IntelliJ plug-in repository here and user documentation here

Written by Ravi Nallakukkala on April 16th, 2007 with no comments.
Read more articles on Tools.

UnitTest IntelliJ plugin

A tool for creating JUnit tests (class/ methods).

Highlights (based on release 0.303)

Usage

Favorable

Unfavorable

For more information on this tool here and User guide available here

Written by Ravi Nallakukkala on April 16th, 2007 with no comments.
Read more articles on Tools.

Code generation of JUnit test cases

Found a good discussion on IBM site; but remember this is a discussion in 2003 things could have changed by now

Written by Ravi Nallakukkala on April 16th, 2007 with no comments.
Read more articles on Uncategorized.

Fireworks IntelliJ plugin

This is a plugin meant for running all JUnits as a single test suite.

Highlights

Usage

Favorable

Unfavorable
NA

For more information on this tool here.

Written by Ravi Nallakukkala on April 16th, 2007 with no comments.
Read more articles on Tools.

JUnitGenerator IntelliJ plugin

Continuing the quest for a JUnit generator tool, my next stop was with JUnit Generator – IntelliJ Plugin. Lets look at features and the fitments of this tool towards my requirement (Junit Generation for a given source code).

Highlights (based on 1.1.7 release)

Usage

Favorable

Unfavorable

For more information about this tool, go from here

Written by Ravi Nallakukkala on April 16th, 2007 with no comments.
Read more articles on Tools.

JUnit 4 Synchronizer IntelliJ plugin

I started a searching for a free tool (which hopefully) will generated some JUnit test code for a given source code. In process of this search, as a first start point I started evaluating the plug-ins which are available for IntelliJ; JUnit 4 Synchronizer is my first stop in the evaluation process.

Highlights (based on release 0.1.1)

Usage

Favorable

Unfavorable

For more information about the plugin, go here

Written by Ravi Nallakukkala on April 16th, 2007 with no comments.
Read more articles on Tools.

Equals and hashcode Approach/ Implementation for Business Objects (Bo)

A common source for bugs while writing code Business Objects for relational database using Object Relation Mapping tools is the implementation of the Equals and Hashcode methods.

If you would like to know more about the Equals and Hashcode importance for an ORM Click here.

To summarize the ORM implementation, There are two types of keys: Technical Keys and Business keys.

Technical keys are the primary key on the for a table to uniquely identify a database row, these numbers are auto generated sequence number (Item Unique IDentification/ IUID).

Business keys are the Business primary (/ composite) keys which uniquely identify the business objects in the database tables.

One of the important factor while writing a equals and hashcode method is to decide on what attributes needs to go into these methods; Some guidelines for deciding the attributes for Equals and hashcode methods.

Implementation wise, Apache commons-lang has a very good implementation for hashcode and equals method. Here’s an example of equals and hashcode methods using the apache commons-lang.

@Entity
@Table(name = "APP_CONFIGURATION")
@SequenceGenerator(name = "OPS_SEQ", sequenceName = "SQ_CONFIGURATION_CNTR")
public class ConfigurationBo extends AbstractBo {

private static final long serialVersionUID = -5098377177228374794L;

@Column(name = “ITEMNAME”, length = 100)
private String name;

@Column(name = “STRINGVALUE”, length = 100)
private String stringValue;

@Column(name = “INTVALUE”)
private Integer intValue;

@Column(name = “TYPENAME”, length = 20)
private String type;

public Integer getIntValue() {
return intValue;
}

public void setIntValue(Integer intValue) {
this.intValue = intValue;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getStringValue() {
return stringValue;
}

public void setStringValue(String stringValue) {
this.stringValue = stringValue;
}

public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}

/**
* {@inheritDoc}
*/
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj.getClass() == this.getClass())) {
return false;
}
ConfigurationBo other = (ConfigurationBo) obj;

return new EqualsBuilder()
.appendSuper(super.equals(obj))
.append(this.name, other.name)
.append(this.type, other.type)
.isEquals();
}

/**
* {@inheritDoc}
*/
@Override
public int hashCode() {
return new HashCodeBuilder()
.appendSuper(super.hashCode())
.append(this.name)
.append(this.type)
.toHashCode();
}

/**
* {@inheritDoc}
*/
@Override
public String toString() {
return super.toString() + “[name=” + name + “, type=” + type + “]”;
}

}

Written by Ravi Nallakukkala on April 15th, 2007 with 4 comments.
Read more articles on Design and Hibernate.

« Older articles

Newer articles »