added autoupdate for template.xhtml
refactoring autoupdate for template.xhtml