Rectangle 27 0

java ShowHide RichFaces component onclick client side (without AJAX)?


<h:outputLink onclick="toggleDetails(this, true); return false;">show</h:outputLink>
<h:outputLink onclick="toggleDetails(this, false); return false;">hide</h:outputLink>
function toggleDetails(link, show) {
    var elementId = determineItSomehowBasedOnGenerated(link.id);
    document.getElementById(elementId).style.display = (show ? 'block' : 'none');
}

+1. You can also use the in-built Richfaces jQuery rich:jQuery to do the similar thing very easy.

Did you check the generated HTML source? Don't you see patterns in generated ID's? Make use of it! :) It's no rocket science. Substring, split, append, etc on the separator character :. I simply couldn't answer that in detail because the lack of information in your question and I don't do RichFaces so I couldn't tell its generated HTML from top of head. I thought it was straightforward enough for you. Nevertheless, you can find another example in this answer :)

In the future, just comment to ask for clarification a bit sooner instead of one month later with a mad smell. I don't shy away from updating the answer with an extended explanation/example how to achieve that :)

To the point, you need to grab the generated HTML element from the DOM in JavaScript and then toggle its CSS display property between block and none. As far as I know, RichFaces doesn't provide out-of-the-box scripts/facilities for this, but it is basically not that hard:

with

Note