1
votes

hello I have a commandLink that executes a method in my baking bean, that method calls an ejb that builds a string and place it as an attribute of the bean (with getters and setters), after executing that method should raise a modal dialog to only display the value of that attribute but it does not, I see the method that builds the chain runs but does not lift the dialogue, this is my code:

xhtml:

<ui:composition>
<p:panelGrid columns="3" style="width: 100%" >
<h:form id="headerForm">
<p:column style="width: 15%;height:auto; text-align: center;">
<p:graphicImage value="#{loginBean.url}" style="align:center;"/>
</p:column>                      
<p:column>
<div align="center">
<h:outputText styleClass="titleHeader" value="#{loginBean.entityName}" />
</div>
</p:column>
<p:column style="width: 15%;height:auto; text-align: center;">
<div align="right">
<h:commandLink onComplete="PF('dlg').show(); return false;" type="button" ajax="false" action="#                {xxxxBean.createString}">
<h:outputText value="Contact" />
</h:commandLink>
</div>
</p:column>
</h:form> 
</p:panelGrid>
<p:dialog id="dlg" header="Some title here" widgetVar="dlg" modal="true">  
<h:outputText value="#{xxxxBean.stringBuild}" />  
</p:dialog>     
</ui:composition>

Backing bean:

@ManagedBean
@SuppressWarnings("serial")
public class XxxxBean implements Serializable{

private String stringBuild;
private someBeanRemote ejb;

public XxxxBean() {
// TODO Auto-generated constructor stub   
try{
ejb = EjbConsumer.getRemoteEjb();
}catch(Exception e){
e.printStackTrace();
}

}    

public void createString(){
List<someObject> list = ejb.findAllActiveObjects(Constants.TOP);
String temp = "";
if( list!=null && list.size() > 0 ){
for(int i=0; i < list.size(); i++){
temp += list.get(i).getName() + "<br/>";        
}

this.stringBuild= temp;
}       

System.out.println(this.stringBuild);

}

public void setStringBuild(String stringBuild) {
this.stringBuild= stringBuild;
}

public String getStringBuild() {
return stringBuild;
}

}

thanks in advance!!!

1

1 Answers

2
votes

You are using ajax=false with oncomplete

oncomplete: Client side callback to execute when ajax request is completed.

Change to:

<p:commandLink oncomplete="PF('dlg').show();" action="#{yourBean.youraction}"></p:commandLink>

that is default ajax = true and everything should work