Wanted to use Log4j without configuration file.
So here is the clean code.
//Java
FileAppender fa = new FileAppender(new SimpleLayout(),filename,true);
fa.activateOptions();
Logger logger = Logger.getLogger(filename);
logger.addAppender(fa);
logger.info(data);
logger.removeAllAppenders();
Vishwajit Girdhari : a Pune based .NET consultant and blogger. Building Rich Internet Application to cross the mile with a smile....... Designer[30%]/Developer[70%]'s Blog.
Friday, September 29, 2006
Thursday, September 28, 2006
SWFLoader : Dynamically load / unload my 'sub applications' in Flex 2.0
Dynamically load / unload my 'sub applications' in Flex 2.0 (compiled swf) but user feel should be as if only one mxml has been loaded.
One problem in flex...
You have 3 .mxmls that get compiled into .swf ( Say A , B , C . )
step1 You have to load B inside A
step2 In B there is a button on click you have to unload B from A and load C
step3 Also in C there is a button on click you have to unload C from A and load B
---
My approach
for Step1 : cool!
I am loading B in A using SWFLoader.
for step2 : stuck!
I am not able get hold of the instance A from which i can change source property of swfLoader (instance) to "C.swf"
for step : whatever works for step 2 :-(
--
Solution ;)
Two days after making this post I figured out a simple way to achieve this.
Code below demonstrates the my approach.
Thanks,
Vishwajit Girdhari
Flexblog : http://flexiness.blogspot.com
One problem in flex...
You have 3 .mxmls that get compiled into .swf ( Say A , B , C . )
step1 You have to load B inside A
step2 In B there is a button on click you have to unload B from A and load C
step3 Also in C there is a button on click you have to unload C from A and load B
---
My approach
for Step1 : cool!
I am loading B in A using SWFLoader.
for step2 : stuck!
I am not able get hold of the instance A from which i can change source property of swfLoader (instance) to "C.swf"
for step : whatever works for step 2 :-(
--
Solution ;)
Two days after making this post I figured out a simple way to achieve this.
Code below demonstrates the my approach.
Thanks,
Vishwajit Girdhari
Flexblog : http://flexiness.blogspot.com
Main.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml "
layout="absolute"
creationComplete="init(event)" >
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import flash.events.Event;
private function init(e:Event):void
{
//doing nothing
}
public function loadSWF (filename : String) : void
{
swfLoader.source=filename;
}
]]>
</mx:Script>
<mx:SWFLoader id="swfLoader" source="one.swf"
></mx:SWFLoader>
</mx:Application>
<mx:Application xmlns:mx="http://www.adobe.
layout="absolute"
creationComplete=
<mx:Script>
<![CDATA[
import mx.controls.
import flash.events.
private function init(e:Event)
{
//doing nothing
}
public function loadSWF (filename : String) : void
{
swfLoader.source=
}
]]>
</mx:Script>
<mx:SWFLoader id="swfLoader" source="one.
></mx:SWFLoader>
</mx:Application>
one.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml "
layout="absolute">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
public function handleOne ( event : Event ) :void {
mx.core.Application.application.loadSWF("two.swf");
}
]]>
</mx:Script>
<mx:Button id="btnOne" label="Button One" click="{handleOne(event)}"
y="200"></mx:Button>
</mx:Application>
<mx:Application xmlns:mx="http://www.adobe.
layout="absolute">
<mx:Script>
<![CDATA[
import mx.controls.
public function handleOne ( event : Event ) :void {
mx.core.Application
}
]]>
</mx:Script>
<mx:Button id="btnOne" label="Button One" click="{handleOne(
y="200"></mx:Button>
</mx:Application>
two.mxml
<?xml
version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml "
layout="absolute">
<mx:Script>
<![CDATA[
import flash.profiler.showRedrawRegions;
import mx.controls.Alert;
public function handleTwo ( event : Event ) :void {
mx.core.Application.application.loadSWF("one.swf");
}
]]>
</mx:Script><mx:Button id="btnTwo" label="Button Two"
click="handleTwo(event)" x="300"></mx:Button>
</mx:Application>
version="1.0" encoding="utf-
<mx:Application xmlns:mx="
layout="absolute">
<mx:Script>
<![CDATA[
import flash.profiler.
import mx.controls.
public function handleTwo ( event : Event ) :void {
mx.core.Application
}
]]>
</mx:Script><mx:Button id="btnTwo" label="Button Two"
click="handleTwo(
</mx:Application>
Friday, September 08, 2006
Printing a hash map in flex
A small piece of AS code that saves a lot of my debug time and frustrations...
Mostly use while understanding the remote object structure.
//code:
//Alerting the hashmap contents
var str = "";
for(var k:String in hashMap)
{
str += k + ":" + hashMap[k] + "\n";
}
Alert.show("Printing hash map : \n" + str);
Mostly use while understanding the remote object structure.
//code:
//Alerting the hashmap contents
var str = "";
for(var k:String in hashMap)
{
str += k + ":" + hashMap[k] + "\n";
}
Alert.show("Printing hash map : \n" + str);
Monday, March 20, 2006
Tomcat 5.5 admin package.
Tomcat 5.5 admin package.
Tomcat's administration web application is no longer installed by default. Download and install the "admin" package to use it.
http://apache.tradebit.com/pub/tomcat/tomcat-5/v5.5.16/bin/apache-tomcat-5.5.16-admin.zip
Tomcat's administration web application is no longer installed by default. Download and install the "admin" package to use it.
http://apache.tradebit.com/pub/tomcat/tomcat-5/v5.5.16/bin/apache-tomcat-5.5.16-admin.zip
Tuesday, March 14, 2006
Implementing double click in flex
Application to demonstrate a possible implementation ' double click ' in Flex v 1.5
DoubleClickDemo.mxml
DoubleClickDemo_script.as
/////////////////////////////////////////////////////////////////////////////////////////
// Application to demonstrate a possible implementation ' double click ' in Flex v 1.5
// Author : Vishwajit Girdhari
// Date : 14-Mar-2006
// Flex Blog : http://flexiness.blogspot.com
// Website : www.vishwajit.com
// email : vishwajit @ gmail.com
/////////////////////////////////////////////////////////////////////////////////////////
//Define the time duration to identify a double click.
var duration = 300;
var timer ;
//Called when the mouse button is clicked
function button_clicked()
{
// double click happened
if(timer != null)
{
// Call a specialised event for double click here.
mx.controls.Alert.show("Double click!");
//clean up
clearInterval(timer);
timer = null;
}
else
{
//start timer on first click
// setInterval obj,callback function,time interval
timer = setInterval(this,"click",duration);
}
}
// handles single clicks
function click(){
// Call a specialised event for single click here.
mx.controls.Alert.show("Single click!");
//clean up
clearInterval(timer);
timer = null;
}
DoubleClickDemo.mxml
<?xml version="1.0" encoding="utf-8"?>
<!--
/////////////////////////////////////////////////////////////////////////////////////////
// Application to demonstrate a possible implementation ' double click '
in Flex v 1.5
// Author : Vishwajit Girdhari
// Date : 14-Mar-2006
// Flex Blog : http://flexiness.blogspot.com
// Blog : http://vishwajit.blogspot.com
// Website : www.vishwajit.com
// email : vishwajit @ gmail.com
/////////////////////////////////////////////////////////////////////////////////////////
-->
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml">
<mx:Script source="DoubleClickDemo_script.as" >
</mx:Script>
<mx:Panel>
<mx:Button id ="btnTest" label="Test single /
double click" click="button_clicked()" ></mx:Button>
</mx:Panel>
</mx:Application>
<!--
/////////////////////////////////////////////////////////////////////////////////////////
// Application to demonstrate a possible implementation ' double click '
in Flex v 1.5
// Author : Vishwajit Girdhari
// Date : 14-Mar-2006
// Flex Blog : http://flexiness.blogspot.com
// Blog : http://vishwajit.blogspot.com
// Website : www.vishwajit.com
// email : vishwajit @ gmail.com
/////////////////////////////////////////////////////////////////////////////////////////
-->
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml">
<mx:Script source="DoubleClickDemo_script.as" >
</mx:Script>
<mx:Panel>
<mx:Button id ="btnTest" label="Test single /
double click" click="button_clicked()" ></mx:Button>
</mx:Panel>
</mx:Application>
DoubleClickDemo_script.as
/////////////////////////////////////////////////////////////////////////////////////////
// Application to demonstrate a possible implementation ' double click ' in Flex v 1.5
// Author : Vishwajit Girdhari
// Date : 14-Mar-2006
// Flex Blog : http://flexiness.blogspot.com
// Website : www.vishwajit.com
// email : vishwajit @ gmail.com
/////////////////////////////////////////////////////////////////////////////////////////
//Define the time duration to identify a double click.
var duration = 300;
var timer ;
//Called when the mouse button is clicked
function button_clicked()
{
// double click happened
if(timer != null)
{
// Call a specialised event for double click here.
mx.controls.Alert.show("Double click!");
//clean up
clearInterval(timer);
timer = null;
}
else
{
//start timer on first click
// setInterval obj,callback function,time interval
timer = setInterval(this,"click",duration);
}
}
// handles single clicks
function click(){
// Call a specialised event for single click here.
mx.controls.Alert.show("Single click!");
//clean up
clearInterval(timer);
timer = null;
}
Windows like behaviour for a panel in flex
I wanted to create a panel that could be be minimized, maximized, moved like a typical 'window'.This article helped me achiving this.
http://www.coenraets.com/viewarticle.jsp?articleId=89
http://www.coenraets.com/viewarticle.jsp?articleId=89
Saturday, March 11, 2006
Flexiness
Whats is flexiness ?
I don't know ............simple.
Got chance to work on Macromedia (now Adobe) Flex and that had impact on the way I have been looking at UI. ASP.NET started feeling like pain. Regular websites started looking to thin and dull. Started to feel the power of RIA and the possibilties limited only by your imagination.
I got hooked. My UI changed as well ....... got a few tshirts....... Osho chappals...... whatever appealed to designer in me. Not limited by external voices.......
still looking for more stuff ......
This my flexiness ............to be able to adapt to anything (presently ...technology) under the sun.
-Vishwajit
I don't know ............simple.
Got chance to work on Macromedia (now Adobe) Flex and that had impact on the way I have been looking at UI. ASP.NET started feeling like pain. Regular websites started looking to thin and dull. Started to feel the power of RIA and the possibilties limited only by your imagination.
I got hooked. My UI changed as well ....... got a few tshirts....... Osho chappals...... whatever appealed to designer in me. Not limited by external voices.......
still looking for more stuff ......
This my flexiness ............to be able to adapt to anything (presently ...technology) under the sun.
-Vishwajit
Subscribe to:
Posts (Atom)