Sunday, October 27, 2013

Spring 3 Scheduler

Basic Schduler in spring 3

<beans
 xmlns:task="http://www.springframework.org/schema/task"
 xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/task  http://www.springframework.org/schema/task/spring-task-3.0.xsd
  ">


<task:scheduler id="Scheduler" pool-size="10" />
 <task:executor id="TaskExecutor" pool-size="10"/>
 <task:annotation-driven executor="TaskExecutor" scheduler="Scheduler"/>

 <bean id="schedulerService" class="com.operation.service.SchedulerService"
    scope="singleton"/>


/**
 * @author jjhangu
 *
 */
public class SchedulerService {
 @Scheduled(fixedDelay = 5000)
 public void doSomething() {
  final long time = System.currentTimeMillis();
  final SimpleDateFormat dayTime = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss");
  final String str = dayTime.format(new Date(time));
  System.out.println("gap is 5 second" + str);
 }
}


log gap is 5scond2013-06-28 02:06:44
log gap is 5scond2013-06-28 02:06:49

Wednesday, October 23, 2013

Let me make replaceAll in Javascript

There is no replaceAll in javascript

if you use replace

ex) var orgStr = "welcome to my blog to have a fun";
     orgStr = orgStr.replace('to', 'ha');
     console.log(orgStr);
     output = "welcome ha my blog to have a fun"

It mean only first String will be replaced but otheres not,

So this is good solution

var orgStr = "welcome to my blog to have a fun";
     orgStr = orgStr.split('to').join('ha');
     console.log(orgStr);
     output = "welcome ha my blog ha have a fun"


Thursday, October 17, 2013

Javascript get Max Width of element in childnode

this function will return that the max width of element from tag element to inner element 




var mainDiv = document.getElementById('mainDiv');
  contentWidth = document.getElementById('contentScroller').offsetWidth;
   var maxVal = getMax (mainDiv, contentWidth);


function getMax (tag, val){
  if(typeof tag.offsetWidth != "undefined"){
   if(val < tag.offsetWidth){
    val = tag.offsetWidth;
   }
  }
 
  if(tag.children.length>0){
   var i=0;
   for (i=0;i<tag.children.length;i++){
    var childVal = getMax(tag.children[i], val);
    if(val < childVal){
     val = childVal;
    } 
   }
  }
  return val;
 }

Monday, October 14, 2013

Search Tag in Iframe from out of Iframe

this is Just example


document.getElementById('main_iframe').onload = function(){

var frameHtml = document.getElementById("main_iframe").contentWindow.document.body.innerHTML;
if(frameHtml.indexOf("loginForm") != -1){
location.href = '/neo/m4/home/login.mvc';
}else{

}

};


<iframe src="" id="main_iframe" width="100%" height="100%" marginheight="0" marginwidth="0" frameborder="0" scrolling="no"></iframe>

Call to Parent Function in Iframe

There are two ways call parent function in iframe

 parent.functionName

 or

 window.top.functionName

This is only in my opinion, I would prefer to use  window.top.functionName.

because parent is not working well in sometime.

Wednesday, October 9, 2013

DOMWindow.js this is kind of popup in html

you can try example from below site http://swip.codylindley.com/DOMWindowDemo.html#inlineContentExample7