• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Portlet body tag

 
sreedhar lak
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am using JSR168 struts portlet usnig RAD.
In the portlets technology we should not use body tag.
But i need the functionality like,whenever the form loads it should call one javascript function ,we have a onload attribute in body tag,but we should not use body.
So,how to do that.
Actually,wht is the replacement of body tag in portlets.
Thanks a lot
 
ruijin yang
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

According to JSR 168,"Portlets generating HTML fragments must not use the following tags: base, body,iframe, frame, frameset, head, html and title." But you can still have a body tag where you can add onload attribute in your original xxx.jsp(for instance,view.jsp).You can look the examples with the IBM portal application development redbook.

I have not experience on portal development.If I am worong,please correct me.
 
Asif Mohd
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can think of couple of ways

1. Attach an event with the body tag using javascript like this

<script language="javascript">
if(body.attachEvent){
body.attachEvent("onload", func);
}

function func(){
//do some thing
}
</script>

This works in IE. Checkout how to do with other browsers if you need to support them.

2. The other option is to hava a simple javascript function at the end of the html content generated by your portlet

<div>
:
<!--content generated by portlet-->
:
</div>
<script language="javascript" defer>
function func(){
//do some thing here
}

//put a call to the above function here
func(); //or better yet, call this using window.setTimeout(...)

</script>
[ March 07, 2006: Message edited by: Asif Mohd ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic