aspose file tools*
The moose likes Struts and the fly likes  How to use html:link and javascript:window.open Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark " How to use html:link and javascript:window.open " Watch " How to use html:link and javascript:window.open " New topic
Author

How to use html:link and javascript:window.open

Sandeep Ghosh
Ranch Hand

Joined: Jan 23, 2002
Posts: 145
Hi Friends,
I am trying to open a link on a pop up window and content will be fetched from database. For this I am writing
<html:link href="javascript:window.open('/man/imagedisplay.do','','toolbar=no, width=350,height=250,resizable=1, scrollbars=1'); void('');" paramId="postid" paramName="postdetail" paramProperty="postID" >See original image</html:link>
It is giving scripting error.
When I am trying open link in just differnt window by this code it working fine
<html:link page="/man/imagedisplay.do" paramId="postid" paramName="postdetail" paramProperty="postID" target="_blank" >See original image.</html:link></td></tr>
Could anybody tell me where I am going wrong.
Thanks in adv.
Sonu
Sandeep Ghosh
Ranch Hand

Joined: Jan 23, 2002
Posts: 145
Ok I managed to do this much. When I am putting hard code value of primary key like this
<html:link href="javascript:window.open('/MyWeb/man/imagedisplay.do?postid=167','Original Image','toolbar=no, width=450,height=350,resizable=1, scrollbars=1');void('');">See original image</html:link>
it is working fine.
but I want my pk to be place dynamically. So I am trying this one
<html:link href="javascript:window.open('/MyWeb/man/imagedisplay.do?postid=<bean:write name="postdetail" property="postID" />','Original Image','toolbar=no, width=450,height=350,resizable=1, scrollbars=1');void('');">See original image</html:link>
Now JSP is giving this exception
[ServletException in:/tiles/postdetail.jsp] /tiles/postdetail.jsp(43,111) jsp.error.attribute.noequal' org.apache.jasper.JasperException: /tiles/postdetail.jsp(43,111) jsp.error.attribute.noequal at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:94) at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:417) at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:126) at
...
...
...
I am also running into problem when I am trying html:rewrite the url.
Could anybody please help me with correct solution
Sonu
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4419
    
    5

You can't nest tags like that. A couple of ways you can make it work. First, I would refactor a bit and make a JavaScript function to encapsulate the popup window creation:

1. In a scriptlet, put together the desired javascript expression string then use a JSP expression to plug it into the html:link

or
2. Use plain HTML link markup and insert the bean:write in the appropriate place.

[ August 31, 2003: Message edited by: Junilu Lacar ]

Junilu - [How to Ask Questions] [How to Answer Questions]
Sandeep Ghosh
Ranch Hand

Joined: Jan 23, 2002
Posts: 145
Hi Junilu,
Thanks a lot .It is working.
Another problem how could I encode my URL in javascript .I am trying this
function openWindowTest(param) {
var url = <%=response.encodeURL("/man/imagedisplay.do?postid=")%>+param;
window.open(url,'Original Image','toolbar=no, width=450,height=350,resizable=1, scrollbars=1');
}
but is giving javascripting error.
Sonu
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4419
    
    5

I think you left out some quotes:
function openWindowTest(param) {
var url = "<%=response.encodeURL("/man/imagedisplay.do?postid=")%>" + param;
window.open(url,'Original Image','toolbar=no, width=450,height=350,resizable=1, scrollbars=1');
Miguel Flecha
Ranch Hand

Joined: Jun 23, 2004
Posts: 85
Hi.
I'm trying to do the same but is giving me the following error:

The requested resource (/defaultroot/javascript opup(codigo)) is not available.

What have I done wrong?
Regards
Vidhi Goel
Greenhorn

Joined: Feb 23, 2010
Posts: 2
Hi ,

I am also facing the same problem as mentioned. I want to open a new window by appending a paramID to the URL.
From the given code snippet, I did not understand what should I put in place of bean name in the following snippet:
<bean:write name="bean name " property="postID">

Please help.
Prasanthi SreeramJammisetty
Greenhorn

Joined: Mar 19, 2010
Posts: 1
Hi Friends,
I also faced the same problem. I have a dimple solution for this.

1<display:column media="html">
2 <c:set var="link">'<html:rewrite action="/WsMasterUseCase/SearchGroupAndMapBeneficiaryMapBeneficiary"/>?groupSystemId=${row.groupSystemId}'</c:set><nobr>
3 <html:link href="javascript:window.open(${link},'','width=1000,height=550,scrollbars=yes');void('');" styleClass="buttonLink"><bean:message key="map.unmap.beneficiary"/>
4 </html:link></nobr>
5 </display:column>

Here line #2 is using for setting the url, with dynamic Id.
Please try this


SHANTHI
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to use html:link and javascript:window.open
 
Similar Threads
How to handle a action on a link?
problem passing parameter in html:link
html:link
html:Link not able to retrieve ActionForward
Achor tag in Struts