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:

  1. create invisible iframe
  2. override href magic path
  3. 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

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -