Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/340.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在Primefaces 5.0中下载文件后更新组件?_Java_Jsf 2_Primefaces - Fatal编程技术网

Java 在Primefaces 5.0中下载文件后更新组件?

Java 在Primefaces 5.0中下载文件后更新组件?,java,jsf-2,primefaces,Java,Jsf 2,Primefaces,您好社区我有一个问题,我需要在下载文件后更新表单组件,但是由于commandButton指示条件ajax=“false”不处理操作“update”,我希望我可以建议如何执行您提到的操作 prespuesto.xhtml <p:dialog id="dlgPresupuesto" widgetVar="dlgVarPresupuesto" closable="false" hideEffect="clip" showEffect="Bounce" header="#{msg['for

您好社区我有一个问题,我需要在下载文件后更新表单组件,但是由于commandButton指示条件ajax=“false”不处理操作“update”,我希望我可以建议如何执行您提到的操作

prespuesto.xhtml

<p:dialog id="dlgPresupuesto" widgetVar="dlgVarPresupuesto" closable="false"
    hideEffect="clip" showEffect="Bounce" header="#{msg['form.boton.guardar']}"
    modal="true" appendTo="@(body)" resizable="false">
    <h:form id="frmPresupuesto">
        <p:panel id="pnlPresupuesto">
            <fieldset class="fieldset-formulario">
                <h:panelGrid>
                    <p:outputLabel value="#{msg['msg.confirm.confirmacionGrabar']}"
                                   style="font-weight: bold;" />                                
                </h:panelGrid>
                <h:panelGrid columns="3">
                    <p:commandButton value="#{msg['form.boton.aceptar']}" ajax="false"
                                     actionListener="#{cRegistroPresupuesto.grabarPresupuesto}"
                                     onclick="PF('dlgVarPresupuesto').hide()"
                                     update=":frmPresupuesto, :listaMensajes"
                                     icon="ui-icon-disk">
                        <p:fileDownload value="#{cRegistroPresupuesto.file}" contentDisposition="attachment" />
                    </p:commandButton>
                    <p:spacer width="8" />  
                    <p:commandButton value="#{msg['form.boton.salir']}"
                                     oncomplete="PF('dlgVarPresupuesto').hide()"
                                     icon="ui-icon-circle-arrow-w"/>                                                                
                </h:panelGrid>
            </fieldset>
        </p:panel>
    </h:form>
</p:dialog>

可能重复:我理解,但这并不能解决我的更新问题。为什么不呢?据我所知,上面是这么说的
@ManagedBean(name = "cRegistroPresupuesto")
@ViewScoped
public class CRegistroPresupuesto extends BaseController 
{   
    private static final long serialVersionUID = 1L;
    private static final Logger LOGGER = LoggerFactory.getLogger(CRegistroPresupuesto.class);

    @ManagedProperty(value = "#{iPresupuestoService}")
    private IPresupuestoService iPresupuestoService;    
    private PresupuestoBean presupuesto;
    private StreamedContent file;

    /**
     * Graba el presupuesto asociado.
     * @param event - Evento desencadenado en la interfaz de usuario.
     */
    public void grabarPresupuesto(ActionEvent event) 
    {
        try 
        {
            if(this.presupuesto.getSiCodPresupuesto() == Constantes.ZERO_SHORT) 
            {
                this.presupuesto.setSiAnio((short) DateUtil.getAnioActual());
                this.presupuesto.setTsFecSolicitada(Calendar.getInstance().getTime());                      
                this.presupuesto.setVrazSocial(getCliente(this.presupuesto.getIcodEmpresa()));
                this.presupuesto.setVrazSocial(getPersona(this.presupuesto.getIcodPersona()));
            }

            Short siCodPrespuesto = iPresupuestoService.grabarPresupuesto(this.presupuesto,
                                                                          this.listaCuadroCosto,
                                                                          getNombreHost(),
                                                                          getCVariableSesion().getIcodUsu());                               
            StringBuilder titulo = new StringBuilder();

            titulo.append(getMessage("presupuesto.form.presupuesto.nro"));
            titulo.append(String.format("%05d", siCodPrespuesto));
            titulo.append(Constantes.SEPARADOR);
            titulo.append(String.valueOf(this.presupuesto.getSiAnio()).substring(2));
            titulo.append(Constantes.EIG);              
            this.presupuesto.setvTitPresupuesto(titulo.toString());             
            addInfoMessage(null, getMessage("msg.info.grabadoOk"));

            InputStream stream = new FileInputStream("C:\\reporte\\ReportePresupuesto.xls");

            file = new DefaultStreamedContent(stream, "application/xls", "ReportePresupuesto.xls");

            RequestContext.getCurrentInstance().update(":frmRegistro");   
        } 
        catch (Exception e) 
        {
            LOGGER.error(getGenerarError(
                    Thread.currentThread().getStackTrace()[1].getMethodName(),
                    Constantes.NIVEL_APP_CONSTROLLER,
                    this.getClass().getName(), e.getMessage()));
        }
    }       
    // get and set
}