Skip to content

Instantly share code, notes, and snippets.

View nosrednawall's full-sized avatar

Anderson José de Souza Inácio nosrednawall

View GitHub Profile
@nosrednawall
nosrednawall / _template.xhtml
Last active June 5, 2018 17:11
Template xhtml para jsf
<?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:f="http://xmlns.jcp.org/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
<h:head>
@nosrednawall
nosrednawall / arquivo.xhtml
Created June 5, 2018 17:14
Carregando mensagem de messages.properties
<f:loadBundle basename="messages" var="msgs" />
<p:outputLabel value="Nome" for="nome" />
<p:inputText id="nome" value="#{seuBean.entidade.nome}"
required="true" requiredMessage="#{msg.nomeBranco}">
<f:ajax event="blur" render="messageNome" />
<p:message for="nome" id="messageNome" />
</p:inputText>
@nosrednawall
nosrednawall / minhaTabelaAtualiza.xhtml
Last active June 18, 2018 12:39
Atualizar campos com primefaces
<h:form>
<!-- aqui fica a declaração da tabela -->
<p:dataTable id="tabela" value="#{meuBean.pessoas}"
var="pessoa"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {Exporters}"
paginator="true" rows="10" style="margin-bottom:20px"
rowStyleClass="#{pessoa.status == 'INATIVO' ? 'inativo-row' : null}"
liveResize="true" emptyMessage="Nenhum Registro Encontrado">
<!-- aqui fica o select com os status da tebela -->
<f:facet name="header">
@nosrednawall
nosrednawall / Bean.java
Created June 19, 2018 13:30
renderiza telas xhtml primefaces
@ManagedBean(name="redBean")
@SessionScoped
public class Bean {
private Integer opcao;
private Boolean isRederiza = false;
public Boolean getIsRederiza() {
return isRederiza;
}
public Integer getOpcao() {
return opcao;
@nosrednawall
nosrednawall / enumComString.java
Last active June 21, 2018 12:33
Enum com string
MACACO_AND_GURILA("Macaco","Gurila"),
JACA_AND_ESCADA("Escada","Jaca");
private String tipoUm, tipoDois;
private TiposEnum(String tipoUm, String tipoDois) {
this.tipoUm = tipoUm;
this.tipoDois = tipoDois;
}
@nosrednawall
nosrednawall / metodoStringToEnum.java
Created July 9, 2018 12:23
Fazendo o parse de String para enum diretamente da classe entity
public void setPaisRecebendoEmString(String paisEmTexto) {
PaisesEnum[] paises = PaisesEnum.values();
for (PaisesEnum paisesEnum : paises) {
if (paisEmTexto.equalsIgnoreCase(paisesEnum.toString())) {
this.pais = paisesEnum;
}
}
}
public void setEstadoRecebendoEmString(String estadoEmTexto) {
@nosrednawall
nosrednawall / BuscaCepWSUtil.java
Created July 10, 2018 16:36
Classe util que busca o cep informado na API VIACEP, funciona bem no java 1.8
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import javax.json.Json;
-- phpMyAdmin SQL Dump
-- version 4.6.6deb4
-- https://www.phpmyadmin.net/
--
-- Host: localhost:3306
-- Tempo de geração: 20/10/2018 às 10:04
-- Versão do servidor: 10.1.26-MariaDB-0+deb9u1
-- Versão do PHP: 7.0.30-0+deb9u1
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
@nosrednawall
nosrednawall / geolocation.js
Created October 21, 2018 00:15
Código para conseguir a longitude e a latitude de um usuário utilizando javascript
// var x = document.getElementById("demo");
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
x.innerHTML = "Geolocation is not supported by this browser.";
}
@nosrednawall
nosrednawall / fluviosidade_rios_curitiba.sql
Created October 21, 2018 01:18
fluviosidade rios de curitiba
-- phpMyAdmin SQL Dump
-- version 4.6.6deb4
-- https://www.phpmyadmin.net/
--
-- Host: localhost:3306
-- Tempo de geração: 20/10/2018 às 15:11
-- Versão do servidor: 10.1.26-MariaDB-0+deb9u1
-- Versão do PHP: 7.0.30-0+deb9u1
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";