Bom dia estou desenvolvendo um rotina em um projeto que utiliza JSF 2.0, Richfaces 4.2.0 .
Eu criei um rich:popupPanel que contém um rich:tabPanel, uma das tabs deste rich:tabPanel possui um rich:dataTable com uma listagem comum, em uma das coluna eu criei um a4j:commandLink que deve executar um cancelamento no bean, porém no primeiro acesso a esse a4j:commandLink ele não acessa o Bean, a partir do segunda acesso ele executa normal e completa a requisição corretamente.
Quem sabe alguém aqui do forum ja passou por este problema.
Abaixo segue meu Código:
código do popup:
<h:form>
<rich:popupPanel style="z-index:1022" id="sendCommands" followByScroll="true" domElementAttachment="parent" moveable="true" resizeable="false"
autosized="true" top="50" margin-left="18%" width="1000" minWidth="950" minHeight="650" height="700" reRender="tabActions">
<f:facet name="header">
<h:outputText
value="#{msg.pst_cargo_data_panel_control} - #{embGeoFenceBean.plate}"></h:outputText>
</f:facet>
<f:facet name="controls">
<h:outputLink value="#"
onclick="#{rich:component('sendCommands')}.hide(); return false;"
styleClass="link">
<h:graphicImage value="../resources/images/btn_close_blue.png"
height="17px" title="#{msg.pst_cargo_title_fechar}"></h:graphicImage>
</h:outputLink>
</f:facet>
<!-- control panel -->
<rich:tabPanel id="tabActions" switchType="client"
selectedTab="ctrl00" ajaxRendered="true" immediate="true">
<rich:tab name="ctrl00"
header="#{msg.pst_cargo_grid_tab_header_info}" id="ctrl00">
<rich:togglePanel switchType="client">
<rich:togglePanelItem name="ctrl00">
<ui:include src="sendcmd/ctrl_panel_information.xhtml" />
</rich:togglePanelItem>
</rich:togglePanel>
</rich:tab>
<rich:tab name="cmd00" header="#{msg.pst_cargo_grid_com_tab_com}"
id="cmd00">
<rich:togglePanel switchType="client">
<rich:togglePanelItem name="cmd00">
<ui:include src="sendcmd/ctrl_panel_command.xhtml" />
</rich:togglePanelItem>
</rich:togglePanel>
</rich:tab>
<rich:tab name="msg00"
header="#{msg.pst_cargo_grid_tab_header_mensagens}" id="msg00">
<rich:togglePanel switchType="client">
<rich:togglePanelItem name="msg00">
<ui:include src="sendcmd/ctrl_panel_message.xhtml" />
</rich:togglePanelItem>
</rich:togglePanel>
</rich:tab>
<rich:tab name="cancel00"
header="#{msg.pst_cargo_panel_legend_title}" id="cancel00">
<fieldset style="margin-top: 14px">
<legend style="font-family: Verdana, Geneva, sans-serif; font-weight: bolder;"><h:outputText value="#{msg.pst_cargo_panel_legend_title}" /></legend>
<br />
<rich:dataTable value="#{commandCancelBean.listCommands}" var="lc"
id="tb_commands" iterationStatusVar="it"
rowClasses="odd-row, even-row" styleClass="stable" style="width:100%"
rows="#{commandCancelBean.rowsTable}">
<f:facet name="header">
<h:outputText value="#{msg.pst_cargo_panel_cancel_table_title}" />
</f:facet>
<f:facet name="noData">
<h:outputText value="#{msg.pst_cargo_data_table_not_found}" />
</f:facet>
<rich:column style="width:5%" filterEvent="onclick"
sortBy="#{ale.vehicle.plate}" sortOrder="#{ctrlCmd.plateOrder}"
filterValue="#{ctrlCmd.pFilterAlert}"
filterExpression="#{fn:containsIgnoreCase(ale.vehicle.plate,ctrlCmd.pFilterAlert)}">
<f:facet name="header" style="width:10%">
<h:outputText value="#{msg.pst_cargo_placa}" />
</f:facet>
<h:outputText value="#{lc.vehicle.plate}" />
</rich:column>
<rich:column style="width:30%">
<f:facet name="header" style="width:30%">
<h:outputText value="#{msg.pst_cargo_panel_cancel_header_cmd}" />
</f:facet>
<h:outputText value="#{lc.command.name}" />
</rich:column>
<rich:column style="width:10%">
<f:facet name="header" style="width:10%">
<h:outputText
value="#{msg.pst_cargo_panel_cancel_header_cmd_status}" />
</f:facet>
<h:outputText value="#{lc.commandStatus.commandStatusDescription}" />
</rich:column>
<rich:column style="width:1%">
<f:facet name="header" style="width:10%">
<h:outputText value="#{msg.pst_cargo_relcomando_dt_envio}" />
</f:facet>
<h:outputText value="#{userContextBean.dateByTimeZone(lc.sentDate)}"></h:outputText>
</rich:column>
<rich:column style="width:10%">
<f:facet name="header" style="width:10%">
<h:outputText value="#{msg.pst_cargo_panel_cancel_header_id_ws}" />
</f:facet>
<h:outputText value="#{lc.returnWs}"></h:outputText>
</rich:column>
<rich:column style="width:5%"
rendered="#{userContextBean.isAccess(6,2)}">
<f:facet name="header" style="width:5%">
<h:outputText value="#{msg.pst_cargo_botao_cancelar}" />
</f:facet>
<a4j:region id="regioActionCancel">
<a4j:commandLink styleClass="no-decor"
render="tb_commands messagesCancelCommand messagesCancel"
actionListener="#{commandCancelBean.cancelCommands}"
execute="@this" onclick="#{rich:component('statPane')}.show();" onerror="#{rich:component('statPane')}.hide();"
oncomplete="#{rich:component('statPane')}.hide();if(#{facesContext.maximumSeverity!=null}){#{rich:component('messagesCancelCommand')}.show();}"
rendered="#{userContextBean.isAccessVehicle(lc.vehicle.plate,5) or userContextBean.isAccessVehicle(lc.vehicle.plate,6)}">
<h:outputText value="#{msg.pst_cargo_botao_cancelar}" />
<f:attribute name="return_ws" value="#{lc.returnWs}" />
<f:attribute name="logObj" value="#{lc}" />
</a4j:commandLink>
</a4j:region>
</rich:column>
<f:facet name="footer">
<rich:dataScroller for="tb_commands" maxPages="20"
renderIfSinglePage="false" styleClass="wrap-paginacao"
boundaryControls="show" stepControls="show" fastControls="hide">
<f:facet name="first">
<h:graphicImage
value="../resources/images/richfaces/firstPage.gif" />
</f:facet>
<f:facet name="previous">
<h:graphicImage value="../resources/images/richfaces/prevPage.gif" />
</f:facet>
<f:facet name="next">
<h:graphicImage value="../resources/images/richfaces/nextPage.gif" />
</f:facet>
<f:facet name="last">
<h:graphicImage value="../resources/images/richfaces/lastPage.gif" />
</f:facet>
</rich:dataScroller>
</f:facet>
</rich:dataTable>
</fieldset>
<h:form>
<rich:popupPanel header="#{msg.pst_cargo_popup_messages}"
id="messagesCancelCommand" autosized="true" min-width="425"
min-height="425" style="z-index:1100;">
<f:facet name="controls">
<h:commandLink
onclick="#{rich:component('messagesCancelCommand')}.hide(); return false;">
<h:graphicImage value="../resources/images/btn_close_blue.png"
height="17" title="Fechar" />
</h:commandLink>
</f:facet>
<h:panelGrid id="messagesCancel">
<a4j:repeat value="#{commandCancelBean.listMsgs}" var="it"
id="repeat">
<span class="rf-msgs"> <rich:panel rendered="#{it.error}">
<span class="rf-msgs-err"> <span class="rf-msgs-sum">#{it.text}</span>
</span>
</rich:panel> <rich:panel rendered="#{not it.error}">
<span class="rf-msgs-inf"> <span class="rf-msgs-sum">#{it.text}</span>
</span>
</rich:panel>
</span>
</a4j:repeat>
</h:panelGrid>
</rich:popupPanel>
</h:form>
</rich:tab>
</rich:tabPanel>
</rich:popupPanel>
</h:form>
Bean
package br.com.gotc.pst.web.model;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import br.com.gotc.pst.core.domain.entity.LogCommand;
import br.com.gotc.pst.core.domain.entity.Vehicle;
import br.com.gotc.pst.core.service.IntegrationGdrService;
import br.com.gotc.pst.core.service.LogCommandService;
import br.com.gotc.pst.core.service.VehicleService;
import br.com.gotc.pst.web.bean.Message;
import br.com.gotc.pst.web.util.MSG;
@Component
@Scope("session")
public class CommandCancelBean implements Serializable {
private static final long serialVersionUID = -8150606129602055837L;
@Autowired
private LogCommandService logCommandService;
@Autowired
private VehicleService vehicleService;
@Autowired
private IntegrationGdrService integrationGdrService;
@Autowired
private MSG msg;
private List<LogCommand> listCommands;
private Vehicle vehicle;
private Integer rowsTable;
private List<Message> listMsgs;
private Integer sizeMsgs = 0;
private Integer failRequest = 0;
private Long idWs;
@PostConstruct
public void init() {
this.listCommands = new ArrayList<LogCommand>();
this.vehicle = new Vehicle();
this.rowsTable = 10;
this.listMsgs = new ArrayList<Message>();
}
public void cleanBean() {
if (this.listCommands != null)
this.listCommands.clear();
else
this.listCommands = new ArrayList<LogCommand>();
this.vehicle = new Vehicle();
this.rowsTable = 10;
}
@PreDestroy
public void destroy() {
this.listCommands = null;
this.vehicle = null;
this.rowsTable = null;
}
public void findCommands(ActionEvent event) {
if (event.getComponent().getAttributes().get("plate") == null)
return;
String plate = event.getComponent().getAttributes().get("plate")
.toString();
this.vehicle = vehicleService.getVehicle(plate);
if (this.vehicle != null) {
this.listCommands = logCommandService
.getListLogCommandForCancel(this.vehicle);
}
}
public void cancelCommands(ActionEvent event) {
System.out.println("Cancelando Commandosss");
if (listMsgs != null)
listMsgs.clear();
else
listMsgs = new ArrayList<Message>();
this.sizeMsgs = 0;
if (event.getComponent().getAttributes().get("return_ws") == null
|| event.getComponent().getAttributes().get("logObj") == null)
return;
try {
Message msgFree = new Message();
String idTemp = event.getComponent().getAttributes()
.get("return_ws").toString();
Long idWs = Long.valueOf(idTemp);
LogCommand logUp = (LogCommand) event.getComponent()
.getAttributes().get("logObj");
if (idWs != null) {
integrationGdrService.cancelCommand(idWs);
sizeMsgs = 1;
msgFree.setError(false);
msgFree.setText(msg
.getString("pst_cargo_panel_cancel_cmd_success"));
this.listCommands.remove(logUp);
listMsgs.add(msgFree);
FacesContext
.getCurrentInstance()
.addMessage(
null,
new FacesMessage(
FacesMessage.SEVERITY_ERROR,
msg.getString("pst_cargo_panel_cancel_cmd_success"),
msg.getString("pst_cargo_panel_cancel_cmd_success")));
} else {
sizeMsgs = 1;
msgFree.setError(true);
msgFree.setText(msg
.getString("pst_cargo_panel_cancel_cmd_erro"));
listMsgs.add(msgFree);
FacesContext
.getCurrentInstance()
.addMessage(
null,
new FacesMessage(
FacesMessage.SEVERITY_ERROR,
msg.getString("pst_cargo_panel_cancel_cmd_erro"),
msg.getString("pst_cargo_panel_cancel_cmd_erro")));
}
} catch (Exception e) {
sizeMsgs = 1;
Message msgFree = new Message();
msgFree.setError(true);
msgFree.setText(msg.getString("pst_cargo_panel_cancel_cmd_erro"));
listMsgs.add(msgFree);
FacesContext.getCurrentInstance().addMessage(
null,
new FacesMessage(FacesMessage.SEVERITY_ERROR, msg
.getString("pst_cargo_panel_cancel_cmd_erro"), msg
.getString("pst_cargo_panel_cancel_cmd_erro")));
System.out.println("Exception ERRO: " + e.getMessage() + " Cause: "
+ e.getCause());
return;
}
}
public List<LogCommand> getListCommands() {
return listCommands;
}
public void setListCommands(List<LogCommand> listCommands) {
this.listCommands = listCommands;
}
public Integer getRowsTable() {
return rowsTable;
}
public void setRowsTable(Integer rowsTable) {
this.rowsTable = rowsTable;
}
public List<Message> getListMsgs() {
return listMsgs;
}
public void setListMsgs(List<Message> listMsgs) {
this.listMsgs = listMsgs;
}
public Integer getSizeMsgs() {
return sizeMsgs;
}
public void setSizeMsgs(Integer sizeMsgs) {
this.sizeMsgs = sizeMsgs;
}
public Long getIdWs() {
return idWs;
}
public void setIdWs(Long idWs) {
System.out.println("Settando ID Ws: " + idWs);
this.idWs = idWs;
}
public void resolvRequest(ActionEvent event) {
System.out.println("Resolvendo Poblema do Primeiro request");
}
public Integer getFailRequest() {
return failRequest;
}
public void setFailRequest(Integer failRequest) {
System.out.println("Settando Fail Request");
this.failRequest = failRequest;
}
}
página que contém o popup
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
xmlns:fn="http://java.sun.com/jsp/jstl/functions"
template="/templates/page.xhtml">
<ui:define name="body">
...
<h:form>
<rich:popupPanel style="z-index:1022" id="sendCommands" followByScroll="true" domElementAttachment="parent" moveable="true" resizeable="false"
autosized="true" top="50" margin-left="18%" width="1000" minWidth="950" minHeight="650" height="700" reRender="tabActions">
<f:facet name="header">
<h:outputText
value="#{msg.pst_cargo_data_panel_control} - #{embGeoFenceBean.plate}"></h:outputText>
</f:facet>
<f:facet name="controls">
<h:outputLink value="#"
onclick="#{rich:component('sendCommands')}.hide(); return false;"
styleClass="link">
<h:graphicImage value="../resources/images/btn_close_blue.png"
height="17px" title="#{msg.pst_cargo_title_fechar}"></h:graphicImage>
</h:outputLink>
</f:facet>
<!-- control panel -->
<rich:tabPanel id="tabActions" switchType="client"
selectedTab="ctrl00" ajaxRendered="true" immediate="true">
<rich:tab name="ctrl00"
header="#{msg.pst_cargo_grid_tab_header_info}" id="ctrl00">
<rich:togglePanel switchType="client">
<rich:togglePanelItem name="ctrl00">
<ui:include src="sendcmd/ctrl_panel_information.xhtml" />
</rich:togglePanelItem>
</rich:togglePanel>
</rich:tab>
<rich:tab name="cmd00" header="#{msg.pst_cargo_grid_com_tab_com}"
id="cmd00">
<rich:togglePanel switchType="client">
<rich:togglePanelItem name="cmd00">
<ui:include src="sendcmd/ctrl_panel_command.xhtml" />
</rich:togglePanelItem>
</rich:togglePanel>
</rich:tab>
<rich:tab name="msg00"
header="#{msg.pst_cargo_grid_tab_header_mensagens}" id="msg00">
<rich:togglePanel switchType="client">
<rich:togglePanelItem name="msg00">
<ui:include src="sendcmd/ctrl_panel_message.xhtml" />
</rich:togglePanelItem>
</rich:togglePanel>
</rich:tab>
<rich:tab name="cancel00"
header="#{msg.pst_cargo_panel_legend_title}" id="cancel00">
<fieldset style="margin-top: 14px">
<legend style="font-family: Verdana, Geneva, sans-serif; font-weight: bolder;"><h:outputText value="#{msg.pst_cargo_panel_legend_title}" /></legend>
<br />
<rich:dataTable value="#{commandCancelBean.listCommands}" var="lc"
id="tb_commands" iterationStatusVar="it"
rowClasses="odd-row, even-row" styleClass="stable" style="width:100%"
rows="#{commandCancelBean.rowsTable}">
<f:facet name="header">
<h:outputText value="#{msg.pst_cargo_panel_cancel_table_title}" />
</f:facet>
<f:facet name="noData">
<h:outputText value="#{msg.pst_cargo_data_table_not_found}" />
</f:facet>
<rich:column style="width:5%" filterEvent="onclick"
sortBy="#{ale.vehicle.plate}" sortOrder="#{ctrlCmd.plateOrder}"
filterValue="#{ctrlCmd.pFilterAlert}"
filterExpression="#{fn:containsIgnoreCase(ale.vehicle.plate,ctrlCmd.pFilterAlert)}">
<f:facet name="header" style="width:10%">
<h:outputText value="#{msg.pst_cargo_placa}" />
</f:facet>
<h:outputText value="#{lc.vehicle.plate}" />
</rich:column>
<rich:column style="width:30%">
<f:facet name="header" style="width:30%">
<h:outputText value="#{msg.pst_cargo_panel_cancel_header_cmd}" />
</f:facet>
<h:outputText value="#{lc.command.name}" />
</rich:column>
<rich:column style="width:10%">
<f:facet name="header" style="width:10%">
<h:outputText
value="#{msg.pst_cargo_panel_cancel_header_cmd_status}" />
</f:facet>
<h:outputText value="#{lc.commandStatus.commandStatusDescription}" />
</rich:column>
<rich:column style="width:1%">
<f:facet name="header" style="width:10%">
<h:outputText value="#{msg.pst_cargo_relcomando_dt_envio}" />
</f:facet>
<h:outputText value="#{userContextBean.dateByTimeZone(lc.sentDate)}"></h:outputText>
</rich:column>
<rich:column style="width:10%">
<f:facet name="header" style="width:10%">
<h:outputText value="#{msg.pst_cargo_panel_cancel_header_id_ws}" />
</f:facet>
<h:outputText value="#{lc.returnWs}"></h:outputText>
</rich:column>
<rich:column style="width:5%"
rendered="#{userContextBean.isAccess(6,2)}">
<f:facet name="header" style="width:5%">
<h:outputText value="#{msg.pst_cargo_botao_cancelar}" />
</f:facet>
<a4j:region id="regioActionCancel">
<a4j:commandLink styleClass="no-decor"
render="tb_commands messagesCancelCommand messagesCancel"
actionListener="#{commandCancelBean.cancelCommands}"
execute="@this" onclick="#{rich:component('statPane')}.show();" onerror="#{rich:component('statPane')}.hide();"
oncomplete="#{rich:component('statPane')}.hide();if(#{facesContext.maximumSeverity!=null}){#{rich:component('messagesCancelCommand')}.show();}"
rendered="#{userContextBean.isAccessVehicle(lc.vehicle.plate,5) or userContextBean.isAccessVehicle(lc.vehicle.plate,6)}">
<h:outputText value="#{msg.pst_cargo_botao_cancelar}" />
<f:attribute name="return_ws" value="#{lc.returnWs}" />
<f:attribute name="logObj" value="#{lc}" />
</a4j:commandLink>
</a4j:region>
</rich:column>
<f:facet name="footer">
<rich:dataScroller for="tb_commands" maxPages="20"
renderIfSinglePage="false" styleClass="wrap-paginacao"
boundaryControls="show" stepControls="show" fastControls="hide">
<f:facet name="first">
<h:graphicImage
value="../resources/images/richfaces/firstPage.gif" />
</f:facet>
<f:facet name="previous">
<h:graphicImage value="../resources/images/richfaces/prevPage.gif" />
</f:facet>
<f:facet name="next">
<h:graphicImage value="../resources/images/richfaces/nextPage.gif" />
</f:facet>
<f:facet name="last">
<h:graphicImage value="../resources/images/richfaces/lastPage.gif" />
</f:facet>
</rich:dataScroller>
</f:facet>
</rich:dataTable>
</fieldset>
<h:form>
<rich:popupPanel header="#{msg.pst_cargo_popup_messages}"
id="messagesCancelCommand" autosized="true" min-width="425"
min-height="425" style="z-index:1100;">
<f:facet name="controls">
<h:commandLink
onclick="#{rich:component('messagesCancelCommand')}.hide(); return false;">
<h:graphicImage value="../resources/images/btn_close_blue.png"
height="17" title="Fechar" />
</h:commandLink>
</f:facet>
<h:panelGrid id="messagesCancel">
<a4j:repeat value="#{commandCancelBean.listMsgs}" var="it"
id="repeat">
<span class="rf-msgs"> <rich:panel rendered="#{it.error}">
<span class="rf-msgs-err"> <span class="rf-msgs-sum">#{it.text}</span>
</span>
</rich:panel> <rich:panel rendered="#{not it.error}">
<span class="rf-msgs-inf"> <span class="rf-msgs-sum">#{it.text}</span>
</span>
</rich:panel>
</span>
</a4j:repeat>
</h:panelGrid>
</rich:popupPanel>
</h:form>
</rich:tab>
</rich:tabPanel>
</rich:popupPanel>
</h:form>
...
</ui:define>
</ui:composition>