5 Replies Latest reply on Feb 3, 2008 6:56 PM by Shane Bryzak

    s:link without the href?  Only for the onclick

    Eric H Novice

      Simple question here:

      I'm setting up my entire site in such a way that it will display pages, and the various sections of the page will have an "edit" button next to them. When the user clicks "edit", there is a DHTML operation that transforms the static display into a form. The user can then do things on the form, and click "save", and the data are updated as an AJAX request and the form returns to its static view, and the "edit" button is back. This seems like a very friendly way to display a lot of information on a page, and have it editable in a simple way.

      At this stage, I have it working like this:

      <div id="staticView">
      <div id="formView">
      <s:link value="Switch them!" onclick="showAndHide('staticView', 'formView');false;"/>

      And a corresponding JavaScript function:

      function showAndHide($showId, $hideId) {
       var $showElement = document.getElementById($showId);
       var $hideElement = document.getElementById($hideId);
       $showElement.style.display = 'inline';
       $hideElement.style.display = 'none';
       return false;

      I put all this together, and it works. Then I enclose it in an <h:form>, and it starts doing a whole-page reload on clicking. I tried s:link, h:commandButton, s:button, and it's all the same behavior.

      Any suggestions on this?

      I'm also thinking of using rich:componentControl, which seems like it is intended for doing things like this, but I can't figure out how to use it. Or are there some other RichFaces components I should try out?

      Any pointers would be welcome!