How I update fields inside a form from outside this form
I need to update some input fields inside a panelGrid, that are inside a h:form but the trigger must be throws outside of this form.
The panelGrid is even the same, but the forms are dynamics. I can't use a fixed identify.
Somebody can you help me?
this is an example of dynamic form
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html"
xmlns:componente="http://java.sun.com/jsf/composite/componente" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui"
template="/WEB-INF/template/principal.xhtml">
<div id="global">
<ui:define name="content">
<h:form id="formDinamic">
<ui:include src="/pages/templates/adicionaisUsuario.xhtml" />
<p:remoteCommand name="updateCep" process="@form:fixedPanel" />
</h:form>
<ui:include src="/pages/dialogSearchCepPorEndereco.xhtml">
<ui:param name="modo" value="E" />
</ui:include>
</ui:define>
</div>
</ui:composition>
the page adicionaisUsuario.xhtml
<p:panelGrid id="fixedPanel" column="4">
<p:inputText id="input1" value="#{crudMb.object1.value1}" />
<p:inputText id="input2" value="#{crudMb.object1.value2}" />
<p:inputText id="input3" value="#{crudMb.object1.value3}" />
<p:commandButton actionListener="#{enderecoMb.doPrepare}" oncomplete="PF('dlgPesqCep').show();"
process="@this :dialogPesquisaCep" update="fixedPanel">
<f:setPropertyActionListener target="#{enderecoMb.object1}" value="#{crudMb.object1}" />
<f:setPropertyActionListener target="#{enderecoMb.tipoEndereco}" value="Residencial" />
</p:commandButton>
</p:panelGrid>
my dialog
<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui">
<p:dialog id="dialogPesquisaCep" position="center" modal="true" widgetVar="dlgPesqCep" resizable="false" width="670"
height="500" header="#{enderecoMb.titulo}" onShow="rc();">
<h:form id="formPesquisaCep">
<p:remoteCommand name="rc" resetValues="true" update="dtlistCeps pBuscaCep" />
<p:messages closable="true" id="msgCep" redisplay="false" />
<p:panelGrid id="pBuscaCep" >
<p:row>
inputs for search...
</p:row>
<p:row>
<p:column>
<p:commandButton value="" id="btnPesquisaCep" actionListener="#{enderecoMb.doEventListEnderecos()}"
styleClass="btn_pesquisar" style="margin-left: 9px;" update="msgCep dtlistCeps">
<f:setPropertyActionListener value="#{modo}" target="#{enderecoMb.modo}" />
</p:commandButton>
</p:column>
</p:row>
</p:panelGrid>
</fieldset>
<p:dataTable id="dtlistCeps" var="end" value="#{enderecoMb.enderecos}" emptyMessage="#{m['nenhum.registro']}"
rowIndexVar="index"
rowKey="#{end.cep}" selectionMode="single">
<p:ajax event="rowSelect" listener="#{enderecoMb.onRowSelectEndereco}" oncomplete="PF('dlgPesqCep').hide();"
update="@(:table[name*='fixedPanel'])">
<f:setPropertyActionListener target="#{enderecoMb.enderecoPesquisado}" value="#{end}" />
</p:ajax>
<p:columns... />
</p:dataTable>
</h:form>
</p:dialog>
</ui:composition>
I show the dialog clicking on p:commandButton inside page adicionaisUsuario.xhtml, search and choose one of the rows (through onRowSelectEndereco method), hide the dialogPesquisaCep and need to update the input fields in p:panelGrid fixedPanel
Thanks for the help
jsf primefaces facelets
add a comment |
I need to update some input fields inside a panelGrid, that are inside a h:form but the trigger must be throws outside of this form.
The panelGrid is even the same, but the forms are dynamics. I can't use a fixed identify.
Somebody can you help me?
this is an example of dynamic form
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html"
xmlns:componente="http://java.sun.com/jsf/composite/componente" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui"
template="/WEB-INF/template/principal.xhtml">
<div id="global">
<ui:define name="content">
<h:form id="formDinamic">
<ui:include src="/pages/templates/adicionaisUsuario.xhtml" />
<p:remoteCommand name="updateCep" process="@form:fixedPanel" />
</h:form>
<ui:include src="/pages/dialogSearchCepPorEndereco.xhtml">
<ui:param name="modo" value="E" />
</ui:include>
</ui:define>
</div>
</ui:composition>
the page adicionaisUsuario.xhtml
<p:panelGrid id="fixedPanel" column="4">
<p:inputText id="input1" value="#{crudMb.object1.value1}" />
<p:inputText id="input2" value="#{crudMb.object1.value2}" />
<p:inputText id="input3" value="#{crudMb.object1.value3}" />
<p:commandButton actionListener="#{enderecoMb.doPrepare}" oncomplete="PF('dlgPesqCep').show();"
process="@this :dialogPesquisaCep" update="fixedPanel">
<f:setPropertyActionListener target="#{enderecoMb.object1}" value="#{crudMb.object1}" />
<f:setPropertyActionListener target="#{enderecoMb.tipoEndereco}" value="Residencial" />
</p:commandButton>
</p:panelGrid>
my dialog
<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui">
<p:dialog id="dialogPesquisaCep" position="center" modal="true" widgetVar="dlgPesqCep" resizable="false" width="670"
height="500" header="#{enderecoMb.titulo}" onShow="rc();">
<h:form id="formPesquisaCep">
<p:remoteCommand name="rc" resetValues="true" update="dtlistCeps pBuscaCep" />
<p:messages closable="true" id="msgCep" redisplay="false" />
<p:panelGrid id="pBuscaCep" >
<p:row>
inputs for search...
</p:row>
<p:row>
<p:column>
<p:commandButton value="" id="btnPesquisaCep" actionListener="#{enderecoMb.doEventListEnderecos()}"
styleClass="btn_pesquisar" style="margin-left: 9px;" update="msgCep dtlistCeps">
<f:setPropertyActionListener value="#{modo}" target="#{enderecoMb.modo}" />
</p:commandButton>
</p:column>
</p:row>
</p:panelGrid>
</fieldset>
<p:dataTable id="dtlistCeps" var="end" value="#{enderecoMb.enderecos}" emptyMessage="#{m['nenhum.registro']}"
rowIndexVar="index"
rowKey="#{end.cep}" selectionMode="single">
<p:ajax event="rowSelect" listener="#{enderecoMb.onRowSelectEndereco}" oncomplete="PF('dlgPesqCep').hide();"
update="@(:table[name*='fixedPanel'])">
<f:setPropertyActionListener target="#{enderecoMb.enderecoPesquisado}" value="#{end}" />
</p:ajax>
<p:columns... />
</p:dataTable>
</h:form>
</p:dialog>
</ui:composition>
I show the dialog clicking on p:commandButton inside page adicionaisUsuario.xhtml, search and choose one of the rows (through onRowSelectEndereco method), hide the dialogPesquisaCep and need to update the input fields in p:panelGrid fixedPanel
Thanks for the help
jsf primefaces facelets
1
Please start by creating a Minimal, Complete, and Verifiable example
– Kukeltje
Jan 18 at 21:32
add a comment |
I need to update some input fields inside a panelGrid, that are inside a h:form but the trigger must be throws outside of this form.
The panelGrid is even the same, but the forms are dynamics. I can't use a fixed identify.
Somebody can you help me?
this is an example of dynamic form
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html"
xmlns:componente="http://java.sun.com/jsf/composite/componente" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui"
template="/WEB-INF/template/principal.xhtml">
<div id="global">
<ui:define name="content">
<h:form id="formDinamic">
<ui:include src="/pages/templates/adicionaisUsuario.xhtml" />
<p:remoteCommand name="updateCep" process="@form:fixedPanel" />
</h:form>
<ui:include src="/pages/dialogSearchCepPorEndereco.xhtml">
<ui:param name="modo" value="E" />
</ui:include>
</ui:define>
</div>
</ui:composition>
the page adicionaisUsuario.xhtml
<p:panelGrid id="fixedPanel" column="4">
<p:inputText id="input1" value="#{crudMb.object1.value1}" />
<p:inputText id="input2" value="#{crudMb.object1.value2}" />
<p:inputText id="input3" value="#{crudMb.object1.value3}" />
<p:commandButton actionListener="#{enderecoMb.doPrepare}" oncomplete="PF('dlgPesqCep').show();"
process="@this :dialogPesquisaCep" update="fixedPanel">
<f:setPropertyActionListener target="#{enderecoMb.object1}" value="#{crudMb.object1}" />
<f:setPropertyActionListener target="#{enderecoMb.tipoEndereco}" value="Residencial" />
</p:commandButton>
</p:panelGrid>
my dialog
<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui">
<p:dialog id="dialogPesquisaCep" position="center" modal="true" widgetVar="dlgPesqCep" resizable="false" width="670"
height="500" header="#{enderecoMb.titulo}" onShow="rc();">
<h:form id="formPesquisaCep">
<p:remoteCommand name="rc" resetValues="true" update="dtlistCeps pBuscaCep" />
<p:messages closable="true" id="msgCep" redisplay="false" />
<p:panelGrid id="pBuscaCep" >
<p:row>
inputs for search...
</p:row>
<p:row>
<p:column>
<p:commandButton value="" id="btnPesquisaCep" actionListener="#{enderecoMb.doEventListEnderecos()}"
styleClass="btn_pesquisar" style="margin-left: 9px;" update="msgCep dtlistCeps">
<f:setPropertyActionListener value="#{modo}" target="#{enderecoMb.modo}" />
</p:commandButton>
</p:column>
</p:row>
</p:panelGrid>
</fieldset>
<p:dataTable id="dtlistCeps" var="end" value="#{enderecoMb.enderecos}" emptyMessage="#{m['nenhum.registro']}"
rowIndexVar="index"
rowKey="#{end.cep}" selectionMode="single">
<p:ajax event="rowSelect" listener="#{enderecoMb.onRowSelectEndereco}" oncomplete="PF('dlgPesqCep').hide();"
update="@(:table[name*='fixedPanel'])">
<f:setPropertyActionListener target="#{enderecoMb.enderecoPesquisado}" value="#{end}" />
</p:ajax>
<p:columns... />
</p:dataTable>
</h:form>
</p:dialog>
</ui:composition>
I show the dialog clicking on p:commandButton inside page adicionaisUsuario.xhtml, search and choose one of the rows (through onRowSelectEndereco method), hide the dialogPesquisaCep and need to update the input fields in p:panelGrid fixedPanel
Thanks for the help
jsf primefaces facelets
I need to update some input fields inside a panelGrid, that are inside a h:form but the trigger must be throws outside of this form.
The panelGrid is even the same, but the forms are dynamics. I can't use a fixed identify.
Somebody can you help me?
this is an example of dynamic form
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html"
xmlns:componente="http://java.sun.com/jsf/composite/componente" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui"
template="/WEB-INF/template/principal.xhtml">
<div id="global">
<ui:define name="content">
<h:form id="formDinamic">
<ui:include src="/pages/templates/adicionaisUsuario.xhtml" />
<p:remoteCommand name="updateCep" process="@form:fixedPanel" />
</h:form>
<ui:include src="/pages/dialogSearchCepPorEndereco.xhtml">
<ui:param name="modo" value="E" />
</ui:include>
</ui:define>
</div>
</ui:composition>
the page adicionaisUsuario.xhtml
<p:panelGrid id="fixedPanel" column="4">
<p:inputText id="input1" value="#{crudMb.object1.value1}" />
<p:inputText id="input2" value="#{crudMb.object1.value2}" />
<p:inputText id="input3" value="#{crudMb.object1.value3}" />
<p:commandButton actionListener="#{enderecoMb.doPrepare}" oncomplete="PF('dlgPesqCep').show();"
process="@this :dialogPesquisaCep" update="fixedPanel">
<f:setPropertyActionListener target="#{enderecoMb.object1}" value="#{crudMb.object1}" />
<f:setPropertyActionListener target="#{enderecoMb.tipoEndereco}" value="Residencial" />
</p:commandButton>
</p:panelGrid>
my dialog
<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui">
<p:dialog id="dialogPesquisaCep" position="center" modal="true" widgetVar="dlgPesqCep" resizable="false" width="670"
height="500" header="#{enderecoMb.titulo}" onShow="rc();">
<h:form id="formPesquisaCep">
<p:remoteCommand name="rc" resetValues="true" update="dtlistCeps pBuscaCep" />
<p:messages closable="true" id="msgCep" redisplay="false" />
<p:panelGrid id="pBuscaCep" >
<p:row>
inputs for search...
</p:row>
<p:row>
<p:column>
<p:commandButton value="" id="btnPesquisaCep" actionListener="#{enderecoMb.doEventListEnderecos()}"
styleClass="btn_pesquisar" style="margin-left: 9px;" update="msgCep dtlistCeps">
<f:setPropertyActionListener value="#{modo}" target="#{enderecoMb.modo}" />
</p:commandButton>
</p:column>
</p:row>
</p:panelGrid>
</fieldset>
<p:dataTable id="dtlistCeps" var="end" value="#{enderecoMb.enderecos}" emptyMessage="#{m['nenhum.registro']}"
rowIndexVar="index"
rowKey="#{end.cep}" selectionMode="single">
<p:ajax event="rowSelect" listener="#{enderecoMb.onRowSelectEndereco}" oncomplete="PF('dlgPesqCep').hide();"
update="@(:table[name*='fixedPanel'])">
<f:setPropertyActionListener target="#{enderecoMb.enderecoPesquisado}" value="#{end}" />
</p:ajax>
<p:columns... />
</p:dataTable>
</h:form>
</p:dialog>
</ui:composition>
I show the dialog clicking on p:commandButton inside page adicionaisUsuario.xhtml, search and choose one of the rows (through onRowSelectEndereco method), hide the dialogPesquisaCep and need to update the input fields in p:panelGrid fixedPanel
Thanks for the help
jsf primefaces facelets
jsf primefaces facelets
asked Jan 18 at 21:21
RodolfoRodolfo
12
12
1
Please start by creating a Minimal, Complete, and Verifiable example
– Kukeltje
Jan 18 at 21:32
add a comment |
1
Please start by creating a Minimal, Complete, and Verifiable example
– Kukeltje
Jan 18 at 21:32
1
1
Please start by creating a Minimal, Complete, and Verifiable example
– Kukeltje
Jan 18 at 21:32
Please start by creating a Minimal, Complete, and Verifiable example
– Kukeltje
Jan 18 at 21:32
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54261570%2fhow-i-update-fields-inside-a-form-from-outside-this-form%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54261570%2fhow-i-update-fields-inside-a-form-from-outside-this-form%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Please start by creating a Minimal, Complete, and Verifiable example
– Kukeltje
Jan 18 at 21:32