i am having some problems because i want to show in some inputText field the value store in selectedIncident attribute so the user could edit the current value. I saw in other question something similar and they used javascript, i try what it does not work for me.
I have an accordion pannel and when i click on a tab it opens and the data of that incident is stored in selectedIncident (this works fine), inside the tab i have a button to edit the data and when i click on it a dialog opens put the fields of title and description are empty.
<h:form id="idFormAllIncidents">
<p:accordionPanel id="panelDetailIncident" value="#{incidentBean.allIncidents}" var="incident" dynamic="true" activeIndex="-">
<p:ajax event="tabChange" listener="#{incidentBean.onTabChange}" immediate="true"/>
<p:tab title="#{incident.title}">
<h:outputText value="#{incident.description}"/>
<p:commandButton id ="editButton" value="Edit Incident" type="button" onclick="PF('dlg2').show();myFunction();"/>
<p:messages id="message" showDetail="true" autoUpdate="true" closable="true" />
</p:tab>
</p:accordionPanel>
<p:dialog id="editIncDialog" header="Edit Incident" widgetVar="dlg2" minHeight="40" >
<p:ajax event="close" listener="#{incidentBean.handleClose}" />
<h:form id="editInc">
<p:outputLabel value="Title:"/>
<h:inputText id="editTitle" value="#{incidentBean.title}" required="true" requiredMessage="Titulo necesarios"/>
<p:outputLabel value="Description: "/>
<p:inputTextarea id="editDescription" value="#{incidentBean.description}" rows="10" cols="50" counter="display" maxlength="200" counterTemplate="{0} caracteres restantes" autoResize="false" required="true" requiredMessage="Descripción necesaria"/>
<p:outputLabel id="display"/>
<p:commandButton value="Send Incident" action="#{incidentBean.editIncident()}" onclick="dlg1.hide()" />
<p:messages id="messages" for="title" showDetail="true" autoUpdate="true" closable="true" />
</h:form>
</p:dialog>
</h:form>
<script type="text/javascript">
function myFunction() {
document.getElementById("editTitle").defaultValue = "#{incidentBean.selectedIncident.title}";
document.getElementById("editDescription").defaultValue = "#{incidentBean.selectedIncident.description}";
}
</script>