1

I am working with primefaces 4.0, I am wondering how to make the following inplace tag editable without clicking the text here is the code

<p:inplace id="ajax" editor="true">
        <p:inputText value="#{inplaceView.text}" required="true" label="text" />
    </p:inplace>

so I must click the inplace to make it editable, I need to change this code to make it editable without any click or any action from the user once the page is loaded it should rendered as editable

Kukeltje
  • 12,223
  • 4
  • 24
  • 47

1 Answers1

0

As Kukeltje stated you could fake clicks with JavaScript/jQuery. If you don't want to use the id you could make use of data-* attribute and select elements by that, for example:

<html ...
    xmlns:pt="http://xmlns.jcp.org/jsf/passthrough">

    <h:head>
        <title></title>
    </h:head>
    <h:body>
        <script>
            $(document).ready(function() {
                $("[data-show-initial='true'] > span").click();
            });
        </script>

        <h:form id="form">
            <p:inplace id="inplace" editor="true" pt:data-show-initial="true">
                <p:inputText value="#{viewBean.value}" required="true" label="text" />
            </p:inplace>
        </h:form>
    </h:body>
</html>

Note that Pass Through Attributes (pt) only exist since JSF 2.2.

Alex Fire
  • 707
  • 3
  • 7