how to reRender a Textbox with an action in a modalPanel?
gatosk8 Feb 8, 2011 10:41 AMHi,I'm new in this foro and I have a problem for some time and i don't know how to solve it.
I have a textbox where I need to enter a value of a enterprise and next to this textbox there is a link that opens a modal panel and where I choose an enterprise and the name of this must be loaded into the textbox.
here is de .xhtml
<s:decorate id="conEmprsaField" template="../layout/display.xhtml">
<ui:define name="label">Empresa</ui:define>
<h:inputText id="txtEmpresa1"
disabled="true"
value="#{SeleccionarEmpresa.cogerEmpresa().emrNombre}" />
<a:commandLink style="color:#880000"
ajaxSingle="true"
value="Seleccionar"
onclick="Richfaces.showModalPanel('empresaModalPanel', {top:'10px', left:'10px', height:'400px'});">
</s:decorate>Here is the modal in which i selected the enterprise to be loaded into the textbox.
<rich:modalPanel id="empresaModalPanel" width="350" height="100">
<f:facet name="header">
<h:panelGroup>
<h:outputText value="Empresas"></h:outputText>
</h:panelGroup>
</f:facet>
<h:form>
<rich:datascroller for="empresaList" maxPages="5"/>
<rich:dataTable id="empresaList" rows="10"
var="_empresa"
value="#{empresaList.resultList}"
rendered="#{not empty empresaList.resultList}">
<h:column>
<f:facet name="header">Nombre</f:facet>
<h:outputText value="#{_empresa.emrNombre}"/>
</h:column>
<h:column>
<f:facet name="header">RUC</f:facet>
<h:outputText value="#{_empresa.emrNumruc}"/>
</h:column>
<rich:column styleClass="action">
<f:facet name="header">Acción</f:facet>
<a4j:commandLink value="Seleccionar"
ajaxSingle="true"
action="#{SeleccionarEmpresa.seleccionarEmpresa(_empresa)}"
oncomplete="Richfaces.hideModalPanel('empresaModalPanel');"
reRender="txtEmpresa1">
<a4j:ajaxListener type="org.ajax4jsf.ajax.ForceRender"/>
</a4j:commandLink>
</rich:column>
</rich:dataTable>
<a4j:commandButton value="Cerrar"
ajaxSingle="true"
oncomplete="Richfaces.hideModalPanel('empresaModalPanel');" />
</h:form>
</rich:modalPanel>
and mi Bean is this.
@Name("SeleccionarEmpresa")
@Scope(CONVERSATION)
public class ModalAgregarEmpresa extends EntityHome<Contacto>{
private static final long serialVersionUID = -1901834046536422763L;
private Empresa empresa;
public Empresa getEmpresa() {
return empresa;
}
public void seleccionarEmpresa(Empresa empresa) {
System.out.println("la empresa seleccionada es:------->"+empresa.getEmrNombre());
setEmpresa(empresa);
}
public Empresa cogerEmpresa() {
return getInstance() == null ? null : getInstance().getEmpresa();
}
public void setEmpresa(Empresa empresa) {
this.empresa = getEmpresa();
}
@Override
protected Contacto createInstance() {
Contacto contacto = new Contacto();
return contacto;
}
public boolean isWired() {
return true;
}
public Contacto getDefinedInstance() {
return isIdDefined() ? getInstance() : null;
}
}
The enterprise is selected but i can't put the value into de textbox when i do the reRender, if anyone can help my I'll be very grateful
thanks in advance and sorry for my english :)