Quick skim through the prime faces cookbook

Community Driven Extensions Project
Post Reply
Eduardo48
Posts: 1
Joined: 25 Feb 2019, 12:50

25 Feb 2019, 13:00

I have a quick skim through the primefaces cookbook but I still do not quite understand how to use p:component. Maybe, I am blind or stupid. Do you mind giving me a simple example how to use it.

Let use the case in the DynaForm example, and use the "basic usage" example which has "Author" and "ISBN" as input text field. Assume that when the form get generated these two fields will be rendered but they can appear in any order and in any row, i.e. you do not know where they are. And assume that I need to perform a javascript that need to access the content of both "Author" and "ISBN" for processing when the user presss the "Submit" button.

My question is how to I write a javascript to access the content of "Author" and "ISBN" since I do not know what their ids before build time since they can be anywhere and this will affect the ids being generated. Sorry, might be a simple question, I am weak in Javascripts.

Thanks

User avatar
Melloware
Posts: 1226
Joined: 22 Apr 2013, 15:48

25 Feb 2019, 14:26

I will let @Rapster answer this one he is the DynaForm expert.
PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 7.0.6 / PF Extensions 7.0.2

Babas007
Posts: 251
Joined: 24 May 2011, 09:42

27 May 2019, 18:26

I'm working on a similar feature: https://stackoverflow.com/questions/563 ... components

Based on your use case scenario, I recommand to have a look at this: https://www.primefaces.org/showcase-ext ... ientId.jsf

The dirty workaround is to write something like:

Code: Select all

 <pe:dynaForm id="dynaForm" value="#{containerDynaFormController.model}" var="data" varContainerId="ccId">
    <pe:dynaFormControl type="INPUT">
         <p:inputText id="_input" value="#{bean.property}" 
         <p:button value="Click" onclick="callbackDynaButton(#{ccId}:_input)" />
    </pe:dynaFormControl>
</pe:dynaForm>
And in your page:

Code: Select all

<script>
    function callbackDynaButton(id) {
        alert(id);
    }
</script

Post Reply

Return to “Extensions”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest