0

hi i have HTML content like:

<div id="j_idt33:summary">
  <ul id="j_idt33:summary2" class="summary">
    <li style="margin-right: 85%; Color:red;">Some Error Message.</li>
  </ul>
</div>

i want when the user click on a button to clear all the contents of that DIV to get output like:

<div id="j_idt33:summary">

</div>

is it possible to do something like that with JSF ? or achieve that with JavaScript ? what do you suggest guys ?

please advise.

Mahmoud Saleh
  • 33,303
  • 119
  • 337
  • 498
  • The functional requirement is not clear. Please clarify the functional requirement in detail and show JSF code instead of its generated HTML output. Particularly the mentioning of a HTML parser like Jsoup makes your question very confusing as it serves an entirely different purpose. – BalusC Nov 26 '11 at 14:41
  • i am trying to workaround this issue http://stackoverflow.com/questions/8215720/faces-messages-are-not-cleared-on-subsequent-requests by clearing the div that hold the messages manually before adding new messages. – Mahmoud Saleh Nov 26 '11 at 14:51
  • 1
    Note that the `div` and the nested `ul` have the same id (j_idt33:summary). This could create problems. – Nicolae Albu Nov 26 '11 at 15:36

1 Answers1

1

In JavaScript side, you could do something like this:

document.getElementById("j_idt33:summary").innerHTML = "";

Or when you're using jQuery:

$("#j_idt33\\:summary").empty();

You only need to give the parent NamingContainer compnent which has a HTML representation with id="j_idt33" (I guess it's the <h:form>) a fixed ID so that the code is more robust. The generated ID may change with JSF impl/version and the component tree's state.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555