• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

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

 
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 17665
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Sandeep Ghosh
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 17665
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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');
 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
There’s no place like 127.0.0.1. But I'll always remember this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic