-
1. Re: target _blank don't work with a4j:commandLink under seam
asookazian Jul 22, 2009 1:46 AM (in response to dmitri.ilyin)show the xhtml and backing bean in the case of JSF/RF only. I'm not sure if this is a Seam-related issue...
-
2. Re: target _blank don't work with a4j:commandLink under seam
dmitri.ilyin Jul 22, 2009 8:34 AM (in response to dmitri.ilyin)What exactly should i show?
The xhtml and the bean are the same in case of JSF/RF with or without seam.<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich"> <h:form> <h:commandLink action="#{pdfReporter.showReport}" value="h:commandLink plus action" target="_blank"> </h:commandLink> <br></br> <a4j:commandLink action="#{pdfReporter.showReport}" value="a4j:commandLink plus action" target="_blank"> </a4j:commandLink> </h:form> </ui:composition>
That's all.
The bean does nothing special. it is just a jsf managed bean. It doesn't care what it does and what the method returns. If you whant i could provide the sample. I have build a simple app. just for testing this issue.
regards
Dmitri -
3. Re: target _blank don't work with a4j:commandLink under seam
kukeltje.ronald.jbpm.org Jul 22, 2009 1:23 PM (in response to dmitri.ilyin)Can you show how the 'generated' html looks like? e.g. with firebug? Both for h: and a4j: ?
-
4. Re: target _blank don't work with a4j:commandLink under seam
kukeltje.ronald.jbpm.org Jul 22, 2009 1:30 PM (in response to dmitri.ilyin)Oh, and try an a4j:form....
-
5. Re: target _blank don't work with a4j:commandLink under seam
dmitri.ilyin Jul 22, 2009 4:07 PM (in response to dmitri.ilyin)here is it...
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" > <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>seam test</title> </head> <body> <div id="main"> <form id="j_id2" name="j_id2" method="post" action="/seamtest/index.jsf" enctype="application/x-www-form-urlencoded"> <input type="hidden" name="j_id2" value="j_id2" /> <script type="text/javascript" language="Javascript">function dpf(f) {var adp = f.adp;if (adp != null) {for (var i = 0;i < adp.length;i++) {f.removeChild(adp[i]);}}};function apf(f, pvp) {var adp = new Array();f.adp = adp;var i = 0;for (k in pvp) {var p = document.createElement("input");p.type = "hidden";p.name = k;p.value = pvp[k];f.appendChild(p);adp[i++] = p;}};function jsfcljs(f, pvp, t) {apf(f, pvp);var ft = f.target;if (t) {f.target = t;}f.submit();f.target = ft;dpf(f);};</script> <a href="#" onclick="if(typeof jsfcljs == 'function'){jsfcljs(document.getElementById('j_id2'),{'j_id2:j_id3':'j_id2:j_id3'},'_blank');}return false">h:commandLink plus action</a> <br /> <a href="#" id="j_id2:j_id5" name="j_id2:j_id5" onclick="A4J.AJAX.Submit('_viewRoot','j_id2',event,{'similarityGroupingId':'j_id2:j_id5','parameters':{'j_id2:j_id6':'21','j_id2:j_id5':'j_id2:j_id5'} ,'actionUrl':'/seamtest/index.jsf'} );return false;" target="_blank">a4j:commandLink plus action </a> <input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="j_id1" /> </form> </div> </body> </html>
-
6. Re: target _blank don't work with a4j:commandLink under seam
kukeltje.ronald.jbpm.org Jul 22, 2009 4:15 PM (in response to dmitri.ilyin)ok, and did you have a look at the differences? Would be nice if you tried analyzing it to instead just posting ;-)
In the h: the target is one of the params in the javascript call, in the a4j it is a real target attribute. Since both return false (as they should) the target by itself does nothing unless the A4J.AJAX.Submit reads the target attribute from the element where the event originates (the 'a').
If you have put a a4j:form around the a4j:commandLink and it still does not work, it might be a bug. You might try debugging the A4J.AJAX.Submit and see what really happens.
-
7. Re: target _blank don't work with a4j:commandLink under seam
dmitri.ilyin Jul 22, 2009 4:17 PM (in response to dmitri.ilyin)with a4j:form is the same......
-
8. Re: target _blank don't work with a4j:commandLink under seam
dmitri.ilyin Jul 22, 2009 4:22 PM (in response to dmitri.ilyin)well,
i'm not so experiensed in JS. I saw the deferense with target handling, but i don't know the handling.
I'll try to debug....
-
9. Re: target _blank don't work with a4j:commandLink under seam
freakjuancho Mar 2, 2010 10:06 PM (in response to dmitri.ilyin)Hi my friend... I have the same problem with the h:commandLink and a4j:commandLink "target" tag, instead of that element you can use the s:link tag, and with the:
target="#" or target="_new"
elements, I hope this can be helpful...
Cheers -
10. Re: target _blank don't work with a4j:commandLink under seam
zellx May 5, 2011 4:27 PM (in response to dmitri.ilyin)Hi,
I don't see any post to solve this issue, so I'll just post a hack for you :)
Seam will in the following tag remove the target attribute <s:download target="_blank"... and generate an <a href.. tag.
I would say this is a bug because we don't get any error messages from Seam. I have not looked into the bugg reports, maybe a later version will have this fixed or not.
Anyway, this solution will work in any Seam version.
Solution:
In you .xhtml file
<s:div id="something">
<s:download ....></s:download>
</s:div>
I put an id attribute on an enclosing <s:div tag, you would like to do it on <s:download but it will remove the id as it did with the target attribute from the <a href tag.
No all you have to do is to create a javascript that will be called on pageload or when you perform some action that creates this attribute in the tag ;)
var divTag = document.getElementById('something');
var aTag = divTag.getElementsByTagName('a')[0];
aTag.setAttribute('target', '_blank');
Cheers