Cannot open web page from JavaScript
<p>I have this hidden button which I want to call from JavaScript when I click on a table row:</p>

<pre><code>&lt;h:commandButton id="lnkHidden" style="text-decoration:none; color:white; display:none"
               action="#{bean.pageRedirect}"&gt;
    &lt;f:setPropertyActionListener target="#{bean.sessionValue}" value="#{item.value}" /&gt;
&lt;/h:commandButton&gt;
</code></pre>

<p>The bean must call the Java method which redirects the user to page </p>

<pre><code>public String pageRedirect()
{
    return "/DatacenterProfile.xhtml";
}
</code></pre>

<p>I use this JavaScript to call the button:</p>

<pre><code>// For clicking on a row and opening new page
function addOnclickToDatatableRows() {
    //gets all the generated rows in the html table
    var trs = document.getElementById('form:dataTable').getElementsByTagName('tbody')[0]
    .getElementsByTagName('tr');
    //on every row, add onclick function (this is what you're looking for)
    for (var i = 0; trs.length &gt; i; i++) {
        var cells = trs[i].cells;
        for(var j=1; j &lt; cells.length; j++){
            cells[j].onclick = new Function("rowOnclick(this.parentElement)");
        }
    }
}

function rowOnclick(tr) {
    var elements = tr.cells[0].childNodes;
    for(var i = 0; elements.length &gt; i; i++) {
        if ((typeof elements[i].id != "undefined") &amp;&amp; (elements[i].id.indexOf("lnkHidden") &gt; -1)) {
            location.href=elements[i].href
            break;
        }
    }
    return false;
}
</code></pre>

<p>When I click on table row I'm redirected to page </p>

<pre><code>http://&lt;ip&gt;:8080/app/undefined
</code></pre>

<p>Can you help me to solve this problem?</p>
