Search code examples
jsfinputprimefaceshiddenhiddenfield

Primefaces do not submit hidden input


I'm using Primefaces 5.0.4 and JSF 2.2. I have a dataTable with some hidden inputs in the rows for setting some js values. My Problem is that i want to submit the Table, but not the hidden inputs, because they refer to a non writeable property. Is this possible?

best Regards


Solution

  • Maybe using an HTML hidden field will solve your problem, it will not prevent them from being submitted but they will not update your JSF backing beans.

    <input type="hidden" value="#{yourBean.value}" />
    

    This input can be used as usual via JavaScript, you can also assign directly the bean value to a js variable on your page.

    As per your comment, i've updated my suggestion. Your can also use a JS table that will hold all your table values just add on each row some JS as shown below:

    <script>table['#{yourBean.someId}'] = '#{yourBean.value}';</script>
    

    dont forget to declare the js table variable outside your datatable.