0

I have the following code snippets which basically set a hidden field's value to the html content of a div (using jQuery) so I can process it on a backing bean:

MyPage.xhtml

function save_to_hidden()
{
    document.getElementById('hidden_field').value=$('#my_div').html();
}

Further down:

<h:inputHidden id="hidden_field" value="#{myBean.divData}" />

Further down:

`<div id="my_div">
   <!-- content in foreign language (spanish) -->
 </div>

Further down:

<a4j:commandButton value="Save" onclick="save_to_hidden()" action="#{myBean.processDivData}" />

I receive the content on the "processDivData" method, but all the "special" characters are replaced with gibberish. Where the problem could be?

Thank you

etercap
  • 187
  • 3
  • 9

1 Answers1

0

The hidden_field is rendered as an HTML form element and as such probably encoded the data in the application/x-www-form-urlencoded MIME type before sending it to the server.

You can use the URLDecoder class to decode these Unicode characters.

jacroe
  • 106
  • 10
maple_shaft
  • 10,435
  • 6
  • 46
  • 74