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.
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.
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.
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)
- Reports the time taken for the execution of each test method, typically the results are displayed in as shown below.
Usage
- Upon running a JUnit test class, this plug-in gets invoked automatically.
Favorable
- Great reports in development environment, no need for any extra profiling.
Unfavorable
- This plug-in doesn’t integrate with Fireworks plug-in (through which you can run a test suite)
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.
A tool for creating JUnit tests (class/ methods).
Highlights (based on release 0.303)
- Extremely easy to use, very well documented.
- You can create your own location patterns for the Test class to be created.
Usage
- On a class or method press Ctrl-T (in Ariadna) Ctrl-Shift-T (in Aurora) to go to the test class or test method
- On a test class or test method press Ctrl-T/Ctrl-Shift-T to go back to the tested class or tested method
- If the test class or test method is missing it will be automatically created.
Favorable
- Easy of use and integrates well with IntelliJ
- You have more control on the location of the created test classes.
- Very good documentation.
- Toggle between the code and test using CTRL + SHIFT + T
- This plug-in along with fireworks plug-in should be good fit.
Unfavorable
- Not an Intelligent to analysis the code and write some test cases.
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.
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.
This is a plugin meant for running all JUnits as a single test suite.
Highlights
- Runs with JUnit 3.8 and 4.
- Helps in Run all the JUnits together (as a single test suite) based on a regular expression (e.g, *test).
Usage
- Goto fireworks tab and select run (ALT + SHIFT +K).
Favorable
- Helps to run all the JUnit together and Integrates with IntelliJ
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.
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)
- Generates JUnit test classes/methods for all the public source methods .
- The generated JUnit code is not complaint with JUnit 4.
- Easy of Installation/ usage.
Usage
- Open the file for which you need to write the JUnit test class, select Alt+Insert you will see “JUnit Test” menu in the list.
Favorable
- Auto generates the skeleton code for JUnit test class.
- Integrates with IntelliJ
Unfavorable
- Only the Skeleton code is generated.
- If the JUnit already existing, For an Existing JUnit IntelliJ (6.0.5 build #6180) throws an Internal error instead of showing the differences in the current JUnit code to generated code as promised by the tool
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.
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)
- Generates Skeleton JUnit Code.
- Generates JUnit 4 test classes/methods for source methods annotated with the @Testable annotation.
Usage
- From IntelliJ IDE, Tools –> RunSynchronize JUnit Tests, this creates a @Testable annotation
- All the desired source methods needs to be Annotate with @Testable annotation.
- Run Synchronize JUnit Tests to create test methods.
- Repeat steps 2 and 3 as often as desired to create new unit tests
Favorable
- Auto generates the skeleton code for JUnit test class.
- Integrates with IntelliJ
Unfavorable
- Source code needs to have test Annotations in the source code. In other words, Source code has dependency on test code (as @Testable annotation is available in ‘test’ folder).
- Only the Skeleton code is generate
For more information about the plugin, go here
Written by Ravi Nallakukkala on April 16th, 2007 with no comments.
Read more articles on Tools.
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.
- It is not necessary to cover all the attributes in Business Objects in equals/ hashcode methods.
- Include the Technical Keys and Business keys in equals and hashcode methods.
- Equals and hashcode methods should take care of the null cases.
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.