css - a:visited not working with h:commandLink in JSF 1.2 -
we have requirement change link color if link has been used(clicked). using h:commandlink action method. below code snippet.
.xhtml file -
<h:commandlink styleclass="changelinkcolor" action="#{bean.actionmethod}"> <span><h:outputtext value="username"/></span> </h:commandlink>
.css file -
.changelinkcolor { color:#0000ff; text-decoration:none; } .changelinkcolor a:link { color:blue; text-decoration:none; } .changelinkcolor a:visited { color: black; }
here styles working except a:visited. works fine if change h:commandlink h:outputlink. later not have action method attribute. hence can not use it.
please share if have work around link color changed h:commandlink tag.
when browser see link address(href) visited, change visited color.
but commandlink generate link onclick, return false disable href behavior, ex:
<a onclick="return submitform(x);" href="#">xx</a>
so not jsf issue, html issue.
our solution is:
- create invisible iframe
- override href magic path
- override onclick function, let iframe go magic path first.
use jquery example:
$(document).ready(function() { $("#linkdiv a").each(function(idx, elem)) { elem.href = '/dummy_' + elem.innerhtml + '.xhtml'; var oldfunc = elem.onclick; $(elem).click(function(){ invisibleframe.location.href = elem.href; return oldfunc(); }); }); });
Comments
Post a Comment