Java EE / JSF and Nginx: uploading files fails when server behind Nginx

with JSF 2.3, Jakarta EE 8 and Wildfly 23 / Payara 5

Uploading a file with <h:input> or <p:fileUpload> works fine but fails when Nginx is turned on. The file is never received by the backing bean.

  1. is there any configuration to add to the server? (Payara or Wildfly)
  2. the Nginx config file has surely errors in it?

app.conf:

upstream payara{
    least_conn;

    server localhost:8080 max_fails=3 fail_timeout=5s;
    server localhost:8181 max_fails=3 fail_timeout=5s;
}
server {
    if ($host = nocodefunctions.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    listen        80;
    access_log /var/log/nginx/payara-access.log;
    error_log /var/log/nginx/payara-error.log;
    #Replace with your domain
    server_name   nocodefunctions.com;
    return        301 https://$host$request_uri;


}

server {
    listen        443 ssl;
    server_name   nocodefunctions.com;
    ssl_certificate /etc/letsencrypt/live/xxxxx/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/xxxxx/privkey.pem; # managed by Certbot

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";

    location /nocodeapp-web-front-1.0 {
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $http_host;
            proxy_set_header X-Forwarded-Proto https;
           
            proxy_connect_timeout      240;
            proxy_send_timeout         240;
            proxy_read_timeout         240;  
            proxy_http_version 1.1;

            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_pass http://payara$request_uri;
    }
    
    location = / {
            proxy_pass http://payara;
            return 301 https://nocodefunctions.com/nocodeapp-web-front-1.0;
    }

}

jsf – Como dar update em um botão dentro de um ?

Vamos ao meu problema. Eu tenho dois <p:commandLink> dentro de um <ui:repeat>. Esses botões simulam checkbox. Então gostaria de ao clicar neles dar update na linha específica dentro do <ui:repeat> atualizando assim o botão a ser renderizado.
Dando update em um <p:outputPanel> que está acima na árvore de elementos ele funciona. O problema é que para uma lista com muitos registros esse update faz com que se volte ao topo da lista, o que para muitos registros acaba sendo dificultoso quando se precisa adicionar varios itens que estão abaixo na lista.

<tbody>
   <ui:repeat value="#{myBean.itens}" var="item" varStatus="index">
      <tr class="myCustomClass" id="item#{item.id}">
         <th>
            <p:commandLink
               rendered="#{myConditionRendered}"
               actionListener="#{myBean.deselect(item)}"
               update=":panelGroupArroundId"
               process="@this">
               <i style="font-size: 15px;" class="fa fa-check-square-o"></i>
            </p:commandLink>
            <p:commandLink
               rendered="#{!myConditionRendered}"
               actionListener="#{myBean.select(item)}"
               update=":panelGroupArroundId"
               process="@this">
               <i style="font-size: 15px;"
                  class="fa fa-square-o"></i>
            </p:commandLink>
         </th>
         <td>
            <h:outputText value="#{item.field1}"/>
         </td>
         ...                                                         
      </tr>
   </ui:repeat>
</tbody>

JSF versão 2.1, Primefaces versão 3.5.

java – JSF and PrimeFaces problem after executing commandButton method i get redirected to absolute path

I’m newbie in this word and I’m building a page for my academic project. I’m using JAVA, JSF and primefaces. I have to persist an Entity in a DB, and the data is loaded throw a JSF page.

this is my SessionScope bean:

public void crearObservacion() {
    System.out.println("crear obserbacion");
    
    try {
    
    
    
    
        if(FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("usuarioIniciado")instanceof Usuario) {
            
            usrCheck=(Usuario) FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("usuarioIniciado");
            
        }else {
            usrCheck=(Usuario) FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("usuarioAD_Obs");
            
            
            try {
                Usuario comprobacionUsuario=beanUsuario.listarxNombreUsuario(usrCheck.getNombreUsuario());
                
                usrCheck=comprobacionUsuario;
            } catch (Exception e) {
                System.out.println("estoy en el if user nulo");
                beanUsuario.crearUsuario(usrCheck);
            }
        }
            
            
        
    
        //llamo al metodo para crear la imagen en el servidor
        //System.out.println(file.getInputStream().available());
        
        
        System.out.println(file.getSize());
        
        
        
        if(file.getSize()==0) {
            
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR,"Es obligatorio subir una imagen",""));
        }
        else{
            
            
                System.out.println("upload");
                upload();
            
        }
            
        
        
        
        //consulto si la imagen fue creada en el servidor, procedo a crear entidad imagen y observacion, caso contrario no crea registros en db
        if(imagenSubida) {
            //--------aca lo que hago es comprobar si la currenInstance es una Usuario en caso afirmativo(caso contrario seria un DirContext),
            //lo pongo como usuario al dar de alta una observacion
            
            
            
            
            Imagen img=new Imagen();
            img.setPath(pathImagen);
            beanImagen.crearImagen(img); // modificar el bean para que al momento de crear devuelva el id.
            
            
            System.out.println(usrCheck.getNombre());
            System.out.println(usrCheck.getApellido());
            System.out.println(usrCheck.getNombreUsuario());
            System.out.println(usrCheck.getClave());
            System.out.println(usrCheck.getSaltClave());
            System.out.println(usrCheck.getTipoUsuario());
            System.out.println(usrCheck.getEstado());
            System.out.println(usrCheck.getNumeroDocumento());
            
            
            
            
            Observacion obs = new Observacion();
            obs.setFenomeno(fenomeno);
            obs.setDescripcion(descripcion);
            obs.setComentario(comentario);
            obs.setLocalidad(localidad);
            obs.setLongitud(longitud);
            obs.setLatitud(latitud);
            obs.setEstaHabilitado(estaHabilitado);
            obs.setImagen(img);
            
            System.out.println("estoy antes del usr");
            obs.setUsuario(usrCheck);
            System.out.println("estoy despues del usr");
            obs.setFechaHoraRegistro(new java.sql.Date(fechaHoraRegistroJavaUtilDate.getTime()));
            
            
            observacionBean.crear(obs);
            limpiarVariables();
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO,"Observacion ingresada con Éxito",""));
        }
    } catch (Exception e) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR,"No se pudo crear Observacion",""));
        System.out.println(e.getMessage());
        e.printStackTrace();
    }
    
    
    
    
    
}
public StreamedContent devolverImagenStream()  {
    
    System.out.println("voy a leer imagen");
    //File imgPath=new File("C:"+File.separator+"Users"+File.separator+"Usuario"+File.separator+"Desktop"+File.separator+"Upload"+File.separator+"uploadDirectory"+File.separator+"admin"+File.separator+"test imgen3.jpg");
    //BufferedImage bufferedImage;
    //bufferedImage = ImageIO.read(imgPath);
    System.out.println("ya la lei");
    ByteArrayOutputStream os=new ByteArrayOutputStream();

    //ImageIO.write(bufferedImage, "jpeg", os);
    System.out.println("la escribi en el bufferImg");
    InputStream is=new ByteArrayInputStream(os.toByteArray());
    System.out.println("la pase a input stream");
    new DefaultStreamedContent();
    imagenStream=DefaultStreamedContent.builder().contentType("image/jpeg").stream(()->is).build();
    System.out.println("ya construi el imagenStream");
    
    System.out.println("lo voy a retornaaar :O");
    return imagenStream;
    
    
    
    
    
    
}

//---------------------------CARGA DE IMAGEN---------------------------------------------

        
        
        public void upload(){
            System.out.println("estoy en el crear");
            
            
            try {
                
                System.out.println("adentro de try");
                
                //creo ruta de carpeta nueva pasar a propiedades
                
                File nuevaCarpeta=new File("C:"+File.separator+"Users"+File.separator+"Usuario"+File.separator+"Desktop"+File.separator+"Upload"+File.separator+"uploadDirectory"+File.separator+usrCheck.getNombreUsuario());
                System.out.println(nuevaCarpeta);
                //si no existe la carpeta, la creo
                System.out.println("voy a consultar si existe la carpeta");
                if(!nuevaCarpeta.exists()) {
                    System.out.println("esty dentro del if por crear la carpeta");
                    nuevaCarpeta.mkdir();
                    System.out.println("la cree");
                }
                
                //crea ruta de imagen a subir a partir de su nombre
                File fileImage=new File("C:"+File.separator+"Users"+File.separator+"Usuario"+File.separator+"Desktop"+File.separator+"Upload"+File.separator+"uploadDirectory"+File.separator+usrCheck.getNombreUsuario()+File.separator+file.getFileName());
                
                if(!fileImage.exists()) {
                //guardo el path de la imagen en una variable para poder pasarsela a la entidad imagen
                pathImagen=fileImage.toString();
                
                
                //creo el archivo de datos a partir de la imagen subida
                InputStream inputStream=file.getInputStream();
                
                //guardo los datos que anteriormente guarde en inputStream en la direccion dada por fileImage
                guardarImagen(inputStream,fileImage);
                
                }else {
                    FacesContext.getCurrentInstance().addMessage("mensajeAlta", new FacesMessage(FacesMessage.SEVERITY_ERROR,"Imagen contiene mismo nombre que una ya subida",""));
                }
                
            } catch (IOException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
            
            
            
        }
        
        public void guardarImagen(InputStream inputStream, File fileImage)  {
            System.out.println("ahora estoy en el guardar imagen");
            
            
         
                try {
                    
                    OutputStream outputStream = new FileOutputStream(fileImage);
                    IOUtils.copy(inputStream, outputStream);
                    imagenSubida=true;
                    FacesContext.getCurrentInstance().addMessage("mensajeAlta", new FacesMessage("Imagen subida con exito"));
                } catch (IOException e) {
                    imagenSubida=false;
                    FacesContext.getCurrentInstance().addMessage("mensajeAlta", new FacesMessage(FacesMessage.SEVERITY_ERROR, "No se pudo crear imagen",""));
                    
                }
                
            
            
            
        }

And this is my page: ingreso.xhtml


<!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:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:p="http://primefaces.org/ui"
    ><h:head></h:head>
    <body>
    <f:metadata>
    
    <f:event listener="#{usuarioBean.verificarSesion}" type="preRenderView"></f:event>
    <f:event listener="#{observacionesBean.limpiarVariables}" type="preRenderView"></f:event>
    <f:event listener="#{observacionesBean.context}" type="preRenderView"></f:event>
    
    </f:metadata>
    
    <ui:decorate template="#{login.template}">
    
        
            
        <ui:define name="content">
            <div class="card">
                <h1>Ingreso de observacion!</h1>
                <p:growl id="mensajeAlta" showDetail="true" life="2000" globalOnly="true">
                    <p:autoUpdate/>
                </p:growl>
                <h:form enctype="multipart/form-data">
                    <h:panelGrid id="panelObservacion"   columns="3">
                    
                        Fenomeno:
                        <p:selectOneMenu id="Fenomenos1"
                            value="#{observacionesBean.fenomeno}"
                            converter="omnifaces.SelectItemsConverter">
    
    
                            <f:selectItems value="#{observacionesBean.fenomenos}"
                                itemValue="#{fenomeno}" />
    
    
                        </p:selectOneMenu>
                        <p:column />
                        
                        Descripción:
                        <p:inputTextarea id="Descripcion" rows="5" cols="30"
                            value="#{observacionesBean.descripcion}" required="true" 
                         label="Descripcion"/>
                        <p:message for="Descripcion"/>
                        
                        Comentario:
                        <p:inputTextarea id="Comentario" rows="5" cols="30"
                            value="#{observacionesBean.comentario}" />
                        <p:column />
                        
                        Localidad:
                        <p:selectOneMenu id="Localidad1"
                            value="#{observacionesBean.localidad}"
                            converter="omnifaces.SelectItemsConverter">
    
    
    
                            <f:selectItems value="#{observacionesBean.localidades}" />
    
    
                        </p:selectOneMenu>
                        <p:column />
                        
                        Latitud:
                        <p:inputNumber id="Latitud" value="#{observacionesBean.latitud}"
                            decimalPlaces="6" decimalSeparator="." thousandSeparator="," />
                        <p:column />
                        
                        Longitud:
                        <p:inputNumber id="Longitud" value="#{observacionesBean.longitud}"
                            decimalPlaces="6" decimalSeparator="." thousandSeparator="," />
                        <p:column />
                        
                        Esta Habilitado:
                        <p:selectOneMenu value="#{observacionesBean.estaHabilitado}">
    
    
                            <f:selectItems value="#{observacionesBean.estado}" />
    
    
                        </p:selectOneMenu>
                        <p:column />
                        
                        Fecha:
                        <p:datePicker id="FechaHoraRegistro"
                            value="#{observacionesBean.fechaHoraRegistroJavaUtilDate}"
                            showIcon="true" showTime="true" pattern="dd-MMM-yy" label="Fecha"
                            required="true" maxdate="#{observacionesBean.maxDate2}"/>
                        <p:message for="FechaHoraRegistro" />
                        
                        Imagen:
                        <p:fileUpload id="imagen"   value="#{observacionesBean.file}" mode="simple" label="Imagen"/>
                        <p:column/>
                        
                         
                        
                        <p:column></p:column>
                        <p:commandButton action="#{observacionesBean.crearObservacion}"
                            value="Guardar"  ajax="false"/>
    
    
    
    
    
                    </h:panelGrid>
                </h:form>






            </div>
        </ui:define>

    </ui:decorate>
</body>
</ui:composition>

I get to this page through a menu:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:p="http://primefaces.org/ui">


<h:head>
    <f:event listener="#{usuarioBean.verificarSesion}" type="preRenderView"></f:event>

</h:head> 
    <body>   
      <!--  </!><h5>Experto Meteo</h5>-->
          <div class="logo">
                    <h:graphicImage value = "images/logo_meteo-color.png" width="50px"/>
          </div>
        <div id="top" class="top">
        
        
            <ui:insert name="top">
                <h:form id="menu">
                    <p:menubar>
                        <p:submenu label="Observación" >
                            <p:menuitem value="Nuevo" action="/protegido/Observacion/ingreso.xhtml"/>
                            <p:menuitem value="Listar" action="/protegido/Observacion/listarObservaciones.xhtml" disabled="#{usuarioBean.listarCheck}" />
                        </p:submenu>
                        
                        <p:submenu label="Mi cuenta" icon="pi pi-user" rendered="#{usuarioBean.usuarioDBcheck}">
                            <p:menuitem value="Cambiar Clave"  action="/protegido/Usuario/cambioContraseña.xhtml"/>
                        </p:submenu>
                        <f:facet name="options">
                        
                        
                            
                            <p:commandButton value="Cerrar Sesion"  action="#{usuarioBean.cerrarSesion}"/>
                        
                        
                        
                        </f:facet>
                        
                    </p:menubar>
                </h:form>
            </ui:insert>
        </div>
        <div name="content">
            <ui:insert name="content">
            
            
            
            </ui:insert>
        
        
        
        </div>
    </body> 

</html>

I navigate to this page without problems and the url(localhost:8085/appweb/login.jsf) in my browser stays always the same, until I click the commandButton “Guardar”, once I clicked on it, my entity “observacion” its persisted in the DB and a message of the successfully persisted entity is display on my browser, but my url change to localhost:8085/appweb/protegido/Observacion/ingreso.jsf and i lost all my css part with it.
Any thoughts?

java – um simples projeto crud com jsf + hibernate, mas o meu update é o único que não consegui por para funcionar

Tentei de várias maneiras, mas nenhuma funcionou.

meu xhtml da tela onde eu clico no button e ele me leva para a pag atualizar. TO TENTANDO PELO BOTÃO “Edit”.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:pt="http://xmlns.jcp.org/jsf/passthrough"
    xmlns:opt="http://primefaces.prime.com.tr/optimus"
    xmlns:p="http://primefaces.org/ui">

<h:head>
    <link rel="stylesheet" href="css/style.css" type="text/css" media="all"></link>
    <f:metadata>
2.    <f:viewParam name="usuario" value="#{beanUsuario.usuario.id}" />
3.    <f:event type="preRenderView"
            listener="#{beanUsuario.editarUsuario}" />
4. </f:metadata>

</h:head>
<h:body>
    <ui:composition template="Template.xhtml">
        <ui:define name="corpo">
            <h:form>
                <h:inputHidden value="#{beanUsuario.usuario.id}" />
                <p:dataTable id="tabela-usuario" var="usuario"
                    value="#{beanUsuario.usuarios}">
                    <p:column headerText="Nome">
                        <h:outputText value="#{usuario.nome}" />
                    </p:column>

                    <p:column headerText="Email">
                        <h:outputText value="#{usuario.email}" />
                    </p:column>

                    <p:column headerText="Telefone">
                        <h:outputText value="#{usuario.telefone}" />
                    </p:column>

                    <p:column>
                        <p:commandButton value="Excluir"
                            action="#{beanUsuario.excluirUsuario(usuario)}">
                            <f:ajax render="@form" />
                        </p:commandButton>

                        <h:commandButton value="Edit"
                            action="#{beanUsuario.editarUsuario}" ajax="false">
                            <f:setPropertyActionListener target="#{beanUsuario.usuario}"
                                value="#{usuario}" />
                        </h:commandButton>
                    </p:column>


                </p:dataTable>
                <br />
                <p:linkButton outcome="menu.xhtml" value="Menu"
                    style="margin-left:20px;" />
                <p:linkButton outcome="login.xhtml" value="Sair"
                    style="margin-left:20px;" />
            </h:form>
        </ui:define>
    </ui:composition>
</h:body>
</html>

meu bean:

public void atualizarUsuario() {
    UsuarioDao dao = new UsuarioDao();
    dao.update(usuario);
}

public String editarUsuario() {
    UsuarioDao dao = new UsuarioDao();
    boolean teste = dao.validarId(usuario);
    
       if(teste == true && usuario!=null){
             this.usuario.setId(usuario.getId());
             this.usuario.setNome(usuario.getNome());
             this.usuario.setEmail(usuario.getEmail());
             this.usuario.setTelefone(usuario.getTelefone());
             this.usuario.setSenha(usuario.getSenha());
       }

       return "atualizar";
    }

Meu dao:

public void update(Usuario usuario) {
    
    EntityManager manager = new ConnectionFactory().getConnection();
    try {
        manager.getTransaction().begin();
        manager.merge(usuario);
        manager.getTransaction().commit();
    } catch (Exception e) {
        manager.getTransaction().rollback();
    } finally {
        manager.close();
    }
    
}

public boolean validarId(Usuario usuario) {
    EntityManager manager = new ConnectionFactory().getConnection();
    manager.getTransaction().begin();
    
    javax.persistence.Query query = manager.createQuery("select id from Usuario u where u.id = :pId");
    query.setParameter("pId", usuario.getId());
    /*
     * query.setParameter("pNome", usuario.getNome()); query.setParameter("pEmail",
     * usuario.getEmail()); query.setParameter("pTelefone", usuario.getTelefone());
     * query.setParameter("pSenha", usuario.getSenha());
     */
    boolean usuarioExiste = !query.getResultList().isEmpty();
    
    manager.getTransaction().commit();
    manager.close();
    
    return usuarioExiste;
}

minha pag atualizar:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:pt="http://xmlns.jcp.org/jsf/passthrough"
    xmlns:opt="http://primefaces.prime.com.tr/optimus"
    xmlns:p="http://primefaces.org/ui">
<h:head>
    <link rel="stylesheet" href="css/style.css" type="text/css" media="all"></link>
</h:head>
<ui:composition template="Template.xhtml">

    <ui:define name="corpo">
        <center>
            <h:outputLabel value="Atualizar" styleClass="titulo-cadastro" />
        </center>
        <h:body>
            <h:form>

                <h:panelGrid columns="2" cellpadding="4"
                    styleClass="panel-grid-cadastro">

                    <h:outputLabel for="nome" value="Nome: " />
                    <p:inputText id="nome" value="#{beanUsuario.usuario.nome}" />

                    <h:outputLabel for="email" value="Email: " />
                    <p:inputText id="email" value="#{beanUsuario.usuario.email}" />

                    <h:outputLabel for="telefone" value="Telefone: " />
                    <p:inputMask id="telefone" value="#{beanUsuario.usuario.telefone}"
                        mask="(99) 99999-9999" />

                    <h:outputLabel for="senha" value="Senha: " />
                    <p:password id="senha" value="#{beanUsuario.usuario.senha}" />

                    <h:commandButton value="Atualizar"
                        action="#{beanUsuario.atualizarUsuario}">

                        <f:ajax render="nome email telefone senha" execute="@form" />
                    </h:commandButton>
                </h:panelGrid>
            </h:form>
        </h:body>
    </ui:define>

</ui:composition>
</html>

Debuguei: ele não resgata o id do usuário que eu quero atualizar, vem o id=null:
inserir a descrição da imagem aqui

javascript – Conditionally render outputText based on a timer in JSF

I have an UI that shows countdown clock when the user is idle. I need to render the output based on the clock timer. For example the user gets signed out after 30 min of idling, I would like to show the clock when it has 10 minutes remainin. How to do this?

My javascript:

 <script type="text/javascript">
//<!(CDATA(
var _imin, _isec, _MIN = 0, IDLE_TIME = 0;

_imin = 30; // IDLE time in minutes
_isec = ;

// On Mouse Move
document.addEventListener('mousemove', function(){
_MIN = 0;
IDLE_TIME = 0;
});

// On Click
document.addEventListener('click', function(){
_MIN = 0;
IDLE_TIME = 0;
});

// On Key Press
document.addEventListener('keypress', function(){
_MIN = 0;
IDLE_TIME = 0;
});

window.setInterval('getIdleTime()', 1000);

function getIdleTime(){
var _minute, _sec, _nmin, _nsec;

IDLE_TIME++;

if( (_isec - IDLE_TIME) == 0 ){
_MIN++;
IDLE_TIME = 0;
}

_minute = _imin - _MIN;
_sec = _isec - IDLE_TIME;

_nmin = (_minute.toString().length == 1) ? '0' + _minute : _minute;
_nsec = (_sec.toString().length == 1) ? '0' + _sec : _sec;

document.getElementById('SetIdleTime').innerHTML = _nmin + ':' + _nsec;

// Now Redirect Page
// After complete the time

if( _minute == 0 && _sec == 0 ){
alert('Timeout!');
document.location.href = 'logout.html';
}

}
//))>
</script>

JSF:

    </h:outputText>
        <h:outputText><span id="SetIdleTime"/>
    </h:outputText>

java – ¿Por que al abrir dos páginas JSF al mismo tiempo una sobreescribe los valores de la otra?

tengo una aplicación que utiliza JSF el cual tiene su managed bean asociado, éste bean contiene metodos que realizan cálculos de totales e IVA con valores enviados desde el formulario JSF; el problema viene cuando se abren dos o mas ventanas JSF de manera simultánea, la segunda página toma valores de la primera página y se hacen cálculos con los resultados obtenidos en la primera es decir si se hace un cálculo de un subtotal la segunda toma el resultado de la primera y lo suma. El scope del managed bean es @ViewScoped. Necesito ayuda ya que cuando dos usuarios acceden solicitan la página al mismo tiempo y trabajan en ella obtienen valores uno del otro y esto afecta los calculos y los resultados. De antemano gracias

jsf – Problema com encoding usando properties

Pessoal estou com um problema um pouco complexo. Montando aqui um projeto base JSF estou com o seguinte problema:

  • Usando arquivo properties para mensagem tenho problema com acentuação ao acessar a página.
  • Não uando o properties não ocorre o problema.

inserir a descrição da imagem aqui

Sinceramente já pesquisei, avaliei, etc. Não sei onde está o problema se puderem me ajudar, segue os meus fontes:

Properties:

teste=Máquina
title=Título da Página

Página layout:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:f="http://xmlns.jcp.org/jsf/core">
    <ui:insert name="head">
        <ui:include src="https://pt.stackoverflow.com/header.xhtml" />
    </ui:insert>
    <h:body>
        <ui:insert name="content"/>
        <ui:insert name="footer">
            <ui:include src="footer.xhtml" />
        </ui:insert>
    </h:body>
</html>

Arquivo index:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:f="http://xmlns.jcp.org/jsf/core" xmlns:p="http://primefaces.org/ui">
<ui:composition template="/layout/template.xhtml">
    <ui:define name="content">
        <h:form>
            <h:panelGrid columns="2">
                <h:panelGrid columns="1">
                    <p:outputLabel value="Máquina"/>
                    <p:inputText />
                </h:panelGrid>
                <h:panelGrid columns="1">
                    <p:outputLabel value="#{msg['teste']}"/>
                    <p:selectOneMenu  var="bean">
                        <f:selectItem itemLabel="Primeiro"/>
                        <f:selectItem itemLabel="Segundo"/>
                    </p:selectOneMenu>
                </h:panelGrid>
            </h:panelGrid>
        </h:form>
    </ui:define>
</ui:composition>
</html>

Header:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
        PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets">
    <h:head>
        <h:outputStylesheet library="css" name="styles.css"/>
        <h:outputStylesheet library="css" name="primefaces-custom.css"/>
        <title>Máquina</title>
    </h:head>
</html>

Javascript – Jquery and JSF – format masks for text fields

Good night, I'm doing a college job and I use masks for decimal fields in my text field, where I have to validate with an accuracy of at most 4 digits. I placed a mask with an accuracy of 4, but in view of what He was asked to accept, fill the field with 1, 2, 3 decimal places. He has the option to set the minimum and maximum accuracy in the masked fields.










And I wrote it like this in Javascript.


jQuery(document).ready(function() {
// Configuração para campos de Real.
// Configuração para mudar a precisão da
máscara. Neste caso a máscara irá
// aceitar 4 dígitos após a virgula.
jQuery("#fldConversion").maskMoney({
showSymbol : false,
symbol : “false”,
decimal : “.”,
thousands : “.”,
precision : 4
});

Is there a way to bring this mask to an accuracy of 1 to 5 decimal places in the mask, for example a maximum and minimum value for decimal places?

Java action in JSF is not called for download

Good morning folks, I have to open a dialog box for the report and in the input text p: I have to check if there is this client. If not, I open a customer list in another dialog box and select the client. However, I have to download the report when I open this dialog box no and I click the Generate Report button. The download does not take place because Ajax comes true and the report dialog closes when I open the data again and can download it. I want to know how to get Ajax wrong again so as not to close the screen and download it. I use Primefaces and Apache Poi.

Follow the code

            

        

public void abredialogcliente () {
Cadcli clientep = new Cadcli ();

    if (cliente != null && !cliente.isEmpty()) {
        clientep = new Cadcli();
        EntityManager manager = this.getManager();
        CadcliRepository repository = new CadcliRepository(manager);
        clientep = repository.procuracodigo(cliente);
        if (clientep.getId() == null) {
            session.setAttribute("pagina", "dialogpadrao");
            org.primefaces.context.DefaultRequestContext.getCurrentInstance().execute("PF('dlgcliente').show()");
        } else {
                cliente = clientep.getCodcli();
                this.setDesccli(clientep.getDesccli());
            }
        }
    }
}