Mostrando postagens com marcador html. Mostrar todas as postagens
Mostrando postagens com marcador html. Mostrar todas as postagens

quarta-feira, 15 de outubro de 2014

trocando texto com css

<html>
<head><title>trocando texto html</title>
<style>
button {
  position: absolute;
  visibility: hidden;
}

button:before {
  content: "novo texto";
  visibility: visible;
}
</style>
</head>
<body>
<button>texto original</button>
</body>
</html>


Fonte: http://stackoverflow.com/questions/7896402/how-can-i-replace-text-through-css

sexta-feira, 7 de junho de 2013

Limit do TextArea


<html>
<body>
<script>
    function limitTextArea(field){
        //field = document.getElementById(field.id);
        var str = field.value;
        var newStr = "";
        var linhas = new Array();
        var replaceLine = false;
        linhas = str.split("\n");
        var cont = linhas.length;

        for (x in linhas){
            if(linhas[x].length > field.cols-2){
                linhas[x] = linhas[x].substring(0, field.cols);
                replaceLine=true;
            }
            if(x < field.rows){
                newStr += linhas[x] + "\n";
            }
        }

        if (cont > field.rows || replaceLine) {
            field.value = newStr.substring(0, newStr.length-1);
        }
        return cont <= field.rows;
    }
</script>
<textarea id="teste" rows=3 cols=3 onkeypress="return limitTextArea(this)">
</textArea><br><br>
</body>
</html>
Fonte: http://forum.imasters.com.br/topic/289857-maximo-de-linha-e-coluna-no-textarea/

quarta-feira, 8 de maio de 2013

Converter HTML em PDF com iText


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package teste.pdf;

import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.PageSize;
import com.lowagie.text.html.simpleparser.HTMLWorker;
import com.lowagie.text.pdf.PdfWriter;
import java.io.BufferedReader;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.OutputStream;
import java.io.StringReader;

/**
 *
 * @author smart
 */
public class ConverterHtmlEmPdf {

    public static OutputStream convertHTMLtoPDF(BufferedReader html, OutputStream pdf) throws IOException, DocumentException {
        String htmlContent = "";
        try {
            StringBuilder sb = new StringBuilder();
            String line = html.readLine();
            while (line != null) {
                sb.append(line);
                sb.append("\n");
                line = html.readLine();
            }
            htmlContent = sb.toString();
        } finally {
            html.close();
        }
        Document doc = new Document(PageSize.A4);
        PdfWriter.getInstance(doc, pdf);
        doc.open();
        HTMLWorker hw = new HTMLWorker(doc);
        hw.parse(new StringReader(htmlContent));
        doc.close();
        return pdf;
    }

    public static void main(String[] args) throws IOException, DocumentException {
//        String File_To_Convert = "/tmp/teste2.html";
        String File_To_Convert = "/tmp/modelo3.html";

        BufferedReader br = new BufferedReader(new FileReader(File_To_Convert));

        String HTML_TO_PDF = "/tmp/MODELOTESTE.pdf";
        OutputStream os = new FileOutputStream(HTML_TO_PDF);

        convertHTMLtoPDF(br, os);
    }
}

terça-feira, 15 de janeiro de 2013

Alinhamento Vertical dentro de uma div



< ?xml version="1.0" encoding="iso-8859-1"? >
< !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >
< html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pt" lang="pt" >
< head >
< title >Vertical Align< /title >
< style type="text/css" >
< !--
#main {
display: table;
}
#row {
display: table-row;
}
#cell {
float: none;
display: table-cell;
vertical-align: middle;
background-color: #CCCC00;
height: 200px;

}
-- >
< /style >
< /head >

< body >
< div id="main" >
  < div id="rows" >
         < div id="cell" >ok< /div >
  < /div >
< /div >
< /body >
< /html >

Fonte: http://forum.imasters.com.br/topic/132304-tableless-alinhamento-vertical-o-mito/

segunda-feira, 7 de janeiro de 2013

WARNING: Parameters: Invalid chunk ignored"

Esse warning ocorre quando o formulário enviado possui campos não identificados

exemplo de post que gera este problema

  1. j_idt108:j_idt168:0:j_idt171:0:quantidade:10
  2. :
  3. j_idt108:j_idt168:0:j_idt171:1:quantidade:10
  4. :
Ao analizar o submit com uma ferramenta de profile pude encontrar esta divergência no form.

A causa deste problema foi:
em uma página jsf possuía um formulário


< h:form >
quantidade: < h:inputtext id="quantidade" >< /h:inputtext >
comentario: < textArea >< /textArea >

< /h:form >



Havia colocado o textarea somente para teste de layout, porém como ele está dentro do formulário, durante uma requisição ajax ele é submetido, o que gera o warning

WARNING: Parameters: Invalid chunk ignored"

para cada tag não jsf.

para resolver isso somente substitui o textArea por


< h:form >
quantidade: < h:inputtext id="quantidade" >< /h:inputtext >
comentario: < h:inputtextarea id="comentatio" >< /h:inputtextarea >

< /h:form >



O que gerou o seguinte post

  1. j_idt108:j_idt168:0:j_idt171:0:quantidade:10
  2. j_idt108:j_idt168:0:j_idt171:0:comentatio:
  3. j_idt108:j_idt168:0:j_idt171:1:quantidade:10
  4. j_idt108:j_idt168:0:j_idt171:0:comentario:

Que resolveu o problema

quarta-feira, 3 de outubro de 2012

Recuperar o conteúdo do uma tag HTML com regex

Site Teste
http://regexpal.com/
http://www.regexplanet.com/advanced/java/index.html

Regex
<tag.*<\/tag>
ou
<tag>(?:[^\n]*(\n+|.*))+</tag>
ou
<\s*tag[^>]*>(.*?)<\s*/\s*tag>
ou
(?<=<\s*tag[^>]*>)(.*?)(?=<\s*/\s*tag\s*>)
ou
(?<=<root.*>\n*)(.*?)(?=\n*</root>)
ou
(?<=<tag.*>\n*)(.*?)(?=\n*</tag>)

String de teste

<root>
<tag id=rodrigo para seual >valor</tag>
</root>

<root>
<tag id="meu id">valor</tag>
</root>

<root><tag id="meu id">valor</tag></root>


(?<=% of )(.*)(?= at )



https://www.regexpal.com/96872
https://www.regexpal.com/27540


regex no java


String html="<root><tag>Medicamento</tag></root>"
String conteudo = null;
Pattern pattern = Pattern.compile("<tag.*<\\/tag>");
Matcher matcher = pattern.matcher(html);
if (matcher.find()) {
    conteudo = matcher.group(0).replace("<tag>", "").replace("</tag>", "").toUpperCase();
}


sexta-feira, 14 de setembro de 2012

Tag Object no lugar de um iframe


<!DOCTYPE html>
<html>
<body>

<object id="page" type="text/html"
    data="http://www.google.com.br"
    width="500" height="600">
  <p>Oops! That didn't work...</p>
</object>

</body>
</html>