Wednesday, December 30, 2009

Produktnøkkel Flying Simulator X Deluxe

Struts 2 actions in Struts 2 interceptors in struts.xml



in Struts 2 interceptors are procedures that run
before or after an action is invoked, there are some
defined we can use directly or create new and
implement these two schemes that have served us
to better understand the famous interceptor of Struts2.

But who better than an example to better understand this concept
.

we will develop a program that spends a
word of a page to another and the time of the change request page
of us display a message that runs automatically
by an interceptor. 1 .- Primiero

we create our home page, as always
page


index.jsp \u0026lt;% @ page contentType = "text / html"%>
\u0026lt;% @ page pageEncoding = "UTF -8 "%>

\u0026lt;% @ taglib uri =" / struts-tags "prefix =" s "%>

\u0026lt;! DOCTYPE HTML PUBLIC "- / / W3C / / DTD HTML 4.01 Transitional / / EN"
"http://www.w3.org/TR/html4/loose.dtd">

\u0026lt;html>

\u0026lt;head> ;
\u0026lt;meta http-equiv="Content-Type" content="text/html;
charset=UTF-8">

\u0026lt;title> Struts2 \u0026lt;/ title>

\u0026lt;/ head>


\u0026lt;body>
\u0026lt;h1> pass the following word \u0026lt;/ h1>

\u0026lt;s:form action="proceso">

name="palabra" \u0026lt;s:textfield label="palabra"/>

\u0026lt;s:submit/>

\u0026lt;/ s: form>

\u0026lt;/ body>

\u0026lt;/ html> ;


2 .- create the following classes import

com.opensymphony.xwork2.ActionSupport;

public class Parameter extends

ActionSupport {private String word;

/ / @ Override public String execute
()
{System.out.println ("entered axecute");
return SUCCESS;}


getPalabra public String ()
{return word;
} public void

setPalabra (String word) {
this.palabra = word;

}} --------------------

-----------------------
this class is the interceptor, as
key things we can say that implements Interceptor
interface and method invoke () is which defines the processes
us before or after the action.

com.opensymphony.xwork2.ActionInvocation import, import
com.opensymphony.xwork2.interceptor.Interceptor;
PruebaInterceptor
public class implements Interceptor {public String intercept

(ActionInvocation next) throws Exception {


Next.invoke String s = ();
System.out.println ("intercept");

return s;}


public void init () {}

public void destroy () {}


}
if we put the System.out.println ("intercept"); before
next.invoke String s = (); will show the message before
System.out.println ("entered axecute") found in parameter class


3 .- create the page response, which is associated to the action
parameter.


\u0026lt;% @ page contentType = "text / html"%>
\u0026lt;% @ page pageEncoding = "UTF-8"%>

\u0026lt;% @ taglib uri = "/ struts-tags" prefix = "s"%>
\u0026lt;html>
\u0026lt;body>

\u0026lt;s:property value="palabra"/>
parameter
\u0026lt;/ body>
\u0026lt;/ html>

4 .- now we would be the most important thing strust.xml
our archive, which has our
configuration.


\u0026lt;!
DOCTYPE struts PUBLIC "- / / Apache Software Foundation / / DTD Struts Configuration 2.0 / / EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>

<!-- Configuration for the default package. -->
<package name="default" extends="struts-default">

<interceptors>
<interceptor name="tiempo_servidor" class="PruebaInterceptor"/>

</interceptors>

<action name="proceso" class="parametro">

<interceptor-ref name="tiempo_servidor"/>
<interceptor-ref name="defaultStack" /> \u0026lt;result

name="success"> / resultado.jsp \u0026lt;/ result>
\u0026lt;/ action>

\u0026lt;/ package>
\u0026lt;/ struts>

of this code we can say that it is important this
interceptor-ref name = "defaultStack" in our action, since
that if the parameter is not word does not come to our website now

respuesta.jsp
when running our code, we
appreciate that at a glance we can see that
the parameter is passed from one page to another, but if we
our console can see that shows what next.

axecute entered


intercept try to make good an example as simple to understand and start
knowledge of this framework, I think
we recommend you read a lot and try to understand how it works
to avoid being stuck in
configuration problems, notably in the file
struts.xml

Tuesday, December 29, 2009

Mulberry Outlet York Review



Struts2 uses a configuration file called
struts.xml this xml file is used to start
project resources. That can be interceptors,
actions, results and others can also define global variables
, validations few bone
words is like the heart of our project.

can work with more xml files, but all
must be included in the file struts.xml
as follows include file (in the form of tag),
separate this file I think it's smaller
recommended when we are present a very large project
, because then we would be more orderly and easier
working, you could say we made a
modularization of our file.

file in practice I always put it in src
is not necessary to have it stored in web-inf folder
we must keep in mind that the structure our
struts.xml must respect the rules of a
xml format, since it will be transformed to (DTD
well formed xml file is as a validator of our
xml file and serves to cover it) to read, my cup
experience I have noticed that many errors are generated by forming
bad or wrong with this famous definition file,
have to note that reading this file
is sequential.

strustdefault.xml there is also the file and struts-plugin.xml
, these two files are included implicitly
(a resemblance to the Object class) and
have the default configuration and are loaded at startup
, in practice I can that are not
in our project, I work with netbeans and eclipce
times, but very little

seeing the structure of this file can see that their main
is tag, bone and within the root
others find it as

this package defines the working group, its
tag is
we share attributes or use of organizational form, a condition is mandatory
its name and its characteristics is that


may extend along with some major labels, we can find the tag
bean, these are created
by the framework and used and finally we discuss
constants (constant), this
are very useful as they can be used to define
settings, you can define what type of bean
to use, etc. As data we can say that
web.xml
initialization parameters are loaded as
FilterDispatchir constant. This is the famous FilterDispatcher
input of our project and is set in web.xml


to work with the constants must be
devmode = true, well this you can see from the
thousands of examples that can be
found in internet, but you know to which this
configuration.

as always I will leave good link, to enter in detail
strust2 more about, because we can find many examples
but if we do not understand what we always give
flying blind

link: Struts2 very good this link and this in English, well
explains the architecture of this framework and with only
next picture we can understand many things in this framework.

Saturday, December 26, 2009

Brazilian Frontier Wikipedia

Beginning with struts 2

I hope to give several examples of this framework, and we need to add comenezar
Struts2 our
netbeans and understand how it works.

the official link is Struts2

but not even pretend to explain this framework because there are many blog and web
explain, but in this article intend
to the starting point to begin working with this framework. 1.-

found this blog that explains how to start so good here


2 .- As always we must begin with the famous "hello world
" hehehe here is the link (the idea is not write and more than
same ADVANTAGE best there is.)

3 .- and finally this link explaining various labels link



Friday, December 25, 2009

Wart Removal Walk In Clinic Toronto

second example of jquery with jsp


the following example using jsp with jdbc, style sheet, it's going
text capture, save and rescue, to show in sequence after
down

insert.jsp


\u0026lt; % @ page contentType = "text / html"%>

\u0026lt;% @ page pageEncoding = "UTF-8"%>

\u0026lt;% @ page language = "java" import = "java.sql .* "errorPage =" "%> \u0026lt;script type="text/javascript" src="js/jquery-1.3.1.js">



\u0026lt;/ script>

\u0026lt;link rel="stylesheet" href="code.css" type="text/css" media="all" />

<script type="text/javascript" >

$(function() {

$(".update_button").click(function() {

var boxval = $("#content").val();

var dataString = 'content='+ boxval;

if(boxval=='')
{
alert("introduzca texto");

}else

{
$.ajax({

type: "POST",
url: "demo.jsp",
data: dataString,
cache: false,
success: function(html){

$("ol#update").prepend(html);
$("ol#update li:first").slideDown("slow");
$("#content").value('');
$("#content").focus(); $("#flash").hide();
}
});

} return false;
});
});

</script>
<div>
<form method="post" name="form" action="">
<h3>ingrese Comuna</h3>
<textarea cols="30" rows="2" name="content" id="content" maxlength="145" >
</textarea><br />
<input type="submit" value="Ingresar" name="submit" class="update_button"/>
</form>
</div>
<div id="flash"></div>
<ol id="update" class="timeline">
</ol>

demo.jsp


<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@ page language="java" import="java.sql.*" errorPage="" %>
<%

String content = request.getParameter ("content");

try {Class.forName ("org.postgresql.Driver");
Connection con =

DriverManager.getConnection ("jdbc: postgresql: / / localhost / example "," postgres "," 1234 ");
Statement st = con.createStatement ();
int i = st.executeUpdate
(" insert into communes (name) values \u200b\u200b('"+ content +"')"); ResultSet rs =

st.executeQuery
("select * from order by name desc commune");

if (rs.next ()) {

while (rs.next ()) {

String msg = rs . getString ("name");
%>
\u0026lt;li> \u0026lt;div>

\u0026lt;span> \u0026lt;% = msg%> \u0026lt;/ span>
\u0026lt;/ div>
\u0026lt;/ li>
\u0026lt;%

}}

else {out.println ("error");}}

catch (Exception e) {

Exception ex = e;
out.println ("Error connecting to postgres:" + ex);}

%>

data base is a simple table called commune
with a field called name and nothing else.

now create the style sheet in netbeans
we can create new web ,
cascading style sheet.


root {display: block;}


* {margin: 0; padding: 0;}
ol.timeline
{list-style: none; font-size: 0.8em;}


ol.timeline
li {display: none; position: relative;
padding: .7 em 0 .6 em 0;
border-bottom: 1px dashed # 000;
line-height: 0.8em;
background-color: # D3E7F5;
height:

ol.timeline 25px} li: first-child {
border-top: 1px dashed # 000;}


intersante found these examples very well and are self

filled with a text link with java
to enter more in detail we have this other link ,
also this example which is a dependent combo with jsp and ajax
and last link to get more link jQuery indetail



Patty Cake Vapirew Set

org.apache.commons

this is a very interesting library and can help us greatly in our development
to use this library
must download the appropriate jar, which you can find
here

this library provides us with management assistance String,
numbers, date.

lower after jar
add it to our project and we are ready to use.

on the following link can find more details about this library

Numéro Série Néro 3.1

transmission of data through ajax with jquery jquery

we will develop the following example
unlike the previous example is that now you can work with
file structures, and we will work with
a driver for our example. but let the sample.

1 .- First we will create our class book, encapsulated
like god, solomante the get the attributes of the class
because we SETI using a constructor.


public class Book {private String title;
private String type;
private int qty;
private String comment;

book () {}


Book (String title, String type, int qty, String comment) {

this.titulo = title;
this.tipo = type;
this.qty = qty;
this.comentario = comment;}



getTitulo public String () {
return title;}


getTipo public String () {return type
;
} public int

getQty ( )
{return qty;}


getComments public String () {return
comment;
}}




2 .- as a second step we create class books, which we manage objects
class book.

import java.util .*;


{public class

books Map books = new LinkedHashMap ();
public
books () {

books.put (11, new book (
"Java Swing "," java ", 1," for desktop applications "));
books.put (27, new book (
" php "," daniel ", 1," book to start php "

)
)

} public
book fetch (int id) {return books.get (id);}
fetchIds public Set () {return books.keySet ();}}


3 .-
after we create our archive of
getbook_as_table.js type and add the following javascript.

$ (function () {
$ ("# button"). Click (function () {$
. Ajax ({
type: "GET", url
"book_table.jsp"
data: {id $ ("# sel"). val ()},
success: function (data) {
$ ("# out"). html (data)

}})
})}
)

4. - now let's create the jsp pages, the first will
getbook_as_table.jsp


\u0026lt;% @ page contentType = "text / html"%>

\u0026lt;% @ page pageEncoding = "UTF-8"%>

\u0026lt;! DOCTYPE HTML PUBLIC "- / / W3C / / DTD HTML 4.01 Transitional / / EN"

"http://www.w3.org/TR/html4/ loose.dtd ">

\u0026lt;% @ page import =" java.util .* "%>

\u0026lt;% @ page import =" model .* "%>

\u0026lt;JSP: useBean id = "book" scope = "session" class = "modelo.libros" />

\u0026lt;html>

\u0026lt;head>

\u0026lt;meta http-equi = "Content-Type" content = "text / html; charset = UTF-8 ">

\u0026lt;title> selection de libro </title>

<script type="text/javascript" src="js/jquery-1.3.1.js"></script>

<script type="text/javascript" src="js/errors.js"></script>

<script type="text/javascript" src="js/getbook_as_table.js"></script>

</head>

<body>

<h3>Buscar libro</h3>

<select id="sel">

<% for (Integer i: books.fetchIds ()) {%>

\u0026lt;option value ="\u0026lt;%= i% %>">\u0026lt;%= i> \u0026lt;/ option>

\u0026lt; ;%}%>

\u0026lt;/ select>

\u0026lt;button id="button"> Search Book \u0026lt;/ button>

\u0026lt;br /> \u0026lt;br />

Book Selection :

\u0026lt;div id="out"> \u0026lt;/ div>

\u0026lt;/ body>

\u0026lt;/ html>

and last page

book_table.jsp
\u0026lt;% @ page contentType = "text / html"%>

\u0026lt;% @ page pageEncoding = "UTF-8"%>

\u0026lt; ,% @ page import = "model .*"%>

\u0026lt;jsp:useBean id="libros" scope="session" class="modelo.libros"/>

\u0026lt;% String id

= request.getParameter ("id") int

id_num = Integer.parseInt (id);

libros.fetch
Book book = (id_num)

book.getComentario comment = String ();

String title = book.getTitulo ();

book.getTipo type = String ();
book.getQty
int qty = ();

%>

\u0026lt;table border = "1" cellpadding = "5" >

\u0026lt;tr>

\u0026lt;td> Title: \u0026lt;/ td> \u0026lt;% = title%> \u0026lt;/ td>

\u0026lt;/ tr>

\u0026lt;tr> ;

\u0026lt;td> type: \u0026lt;/ td> \u0026lt;% = type%> \u0026lt;/ td>

\u0026lt;/ tr>

\u0026lt;tr>

\u0026lt;td> qty: \u0026lt;/ td> \u0026lt;td \u0026lt;% = qty%> \u0026lt;/ td>

\u0026lt;/ tr>

\u0026lt;tr>

\u0026lt;td> comment: \u0026lt;/ td> \u0026lt;td \u0026lt;% = comment%> \u0026lt;/ td>

\u0026lt;/ tr>

\u0026lt;/ table>

on the code, if you do not understand how it works useBean pu eden
find this blok as you work. Here

Thursday, December 24, 2009

Full Katesplayground Sets

Sample selection based on a combobox with jquery

in the preceding article only explains an introduction,
but really what matters is the implementation
is it that we give some examples
found it very interesting to begin to understand better what is jquery
and how to work with her.

we must first have our project with the
js folder in which we find jquery-1.3.1.js this
what we see in the preceding article.

in the same folder create a file to work with javascript
that we do so:



client_getperson create the file and within
introduce the following code:

$ (function () {
$ ("# button") . click (function () {
$ ("# out"). html ($ ("# sel"). val ())}
)
})



parckage souce then create the package model,
where we

People class package model;

public class People {private String

people []
= new String [] {"Joe", "Felipe", "hector", "enzo" "sergio", };
public int getNumPeople() { return people.length; }
public String getPerson(int num) { return people[num]; }
}

ahora en nuestra pagina jsp


<%@page contentType="text/html"%>

<%@page pageEncoding="UTF-8"%>



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

"http://www.w3.org/TR/html4/loose.dtd">

<%@ page import="java.util.*" %>

<%@ page import="modelo.People" %>

\u0026lt;jsp:useBean id="people" scope="request" class="modelo.People"/>

\u0026lt;html>

\u0026lt;head>

\u0026lt;meta http-equiv = "Content-Type" content = "text / html; charset = UTF-8">

\u0026lt;title> Selection with javascript \u0026lt;/ title>

\u0026lt;script type = "text / javascript" src = "js / jquery-1.3.1.js "> \u0026lt;/ script> \u0026lt;script type="text/javascript"

src="js/client_getperson.js"> \u0026lt;/ script>

\u0026lt;/ head>

\u0026lt;body>

\u0026lt;h3> Seleccion Persona \u0026lt;/ h3>

\u0026lt;select id="sel">

\u0026lt;% for (int i = 0; i \u0026lt;people.getNumPeople (); + + i) {%>

\u0026lt;option value ="\u0026lt;%= people.getPerson (i )%>">\u0026lt;%= i%> \u0026lt; ; / option>

\u0026lt;%}%>

\u0026lt;/ select>

\u0026lt;button id="button"> View person \u0026lt;/ button>

\u0026lt;br /> \u0026lt;br />

Selected Person: \u0026lt;span id="out"> \u0026lt;/ span>

\u0026lt;/ body>

\u0026lt; / html>

and so we are left out:

well this is the simplest example, but it otherwise is so
more complete.


\u0026lt;% @ page import = "java.util .*"%>

\u0026lt;% @ page import = "modelo.People"%>

\u0026lt;jsp: useBean id="people" scope="request" class="modelo.People"/>



<html>

  <head>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <title>Selection con ajax</title>

    <script type="text/javascript" src="js/jquery-1.3.1.js"></script> \u0026lt;script Type="text/javascript"

src="js/server_getperson.js"> \u0026lt;/ script>

\u0026lt;/ head>

\u0026lt;body>

\u0026lt;h3> AJAX "Get Person" \u0026lt;/ h3>



\u0026lt;select id="sel">

& # 160; \u0026lt;% for (int i = 0; i \u0026lt;people.getNumPeople (); + + i) {%>

\u0026lt;option value ="\u0026lt;%= i% %>">\u0026lt;%= i> \u0026lt;/ option>

& # 160; \u0026lt;%}%>

\u0026lt;/ select>

\u0026lt;button id="button"> search person \u0026lt;/ button>

\u0026lt;br /> \u0026lt;br />

& # 160; person Selected: \u0026lt;span id="out"> \u0026lt;/ span>

\u0026lt;/ body>

\u0026lt;/ html>


on file vestments server_getperson.js type:

$ (function () {
$ ("# button"). click (function () {$
. ajax ({
type: "GET" / / The default
url: "GetPerson"
data: {id: $ ("# sel"). Val ()},
success: function (data) {
$ ("# out"). Html (data )

}})

then we have a servlet called GetPerson

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
modelo.People import;
GetPerson
public class extends HttpServlet {private

People people = new People ();


protected void processRequest (HttpServletRequest request, HttpServletResponse response) throws ServletException
,
IOException {response.setContentType ("text / html; charset = UTF-8");
PrintWriter out = response.getWriter ();
try {

String id = request.getParameter ("id");
out.print (people.getPerson (Integer.parseInt (id)));


} finally {out.close ();}

/ /. ....
}

Wednesday, December 23, 2009

Pokemon Frigo Return Rom

jsp


jQuery is a javascript library that is being using far
one of the features of this library is its well
compressed version shares many characteristics of prototype
(one difference is the method call).

explained in a previous link some ajax and if there is any doubt
would be good to see this topic, plus I have a link for further
over the issue.

http://ungranoparajava.blogspot.com/2009/05/empezando-con-ajax.html

ajax understand if we already have or want to go directly to what we view this practice
jquery manual very good (in
official website there is much documentation and even in English)

http://www.librosweb.es/ajax/capitulo10/la_libreria_jquery.html

in the above link can also find a manual
ajax prototype and is very good about this link.

now let that bring us together lol, what fun it is to
code.

as always we will use our
netbeans and the first thing we do is a web project, which does not include any
framework (such as hibernate, jsf, struts, etc.
but can be used with jsf, struts, spring etc.) .

as we see our project has a js folder, create it in this
new-> other-> carperta. To work with this library
have to download the file jquery-1.3.1.js, this is
version but we can work with the former being the well 1.2.1
are many. This file is saved in the folder you created in
js our project is so simple.

and now work as one does with javascript, but we must define our jquery
in the code.


\u0026lt;% @ page contentType = "text / html"%>

\u0026lt;% @ page pageEncoding = "UTF-8"%>

\u0026lt;! DOCTYPE HTML PUBLIC "- / / W3C / / DTD HTML 4.01 Transitional / / EN "

" http://www.w3.org/TR/html4/loose.dtd ">

\u0026lt;html>

\u0026lt;head>

\u0026lt;script src="js/jquery-1.3.1.js"> \u0026lt;/ script> \u0026lt;script type="text/javascript">



$ (document). ready (function () {

alert ("loaded");}

);

\u0026lt;/ script>

\u0026lt;meta http-equi = "Content-Type" content = "text / html; charset = UTF-8 ">

\u0026lt;title> JSP Page \u0026lt;/ title>

\u0026lt;/ head>

\u0026lt;BODY>

\u0026lt;h1> JSP Page \u0026lt;/ h1>


can see in the above code
a small example of how to implement the jQuery library in netbeans

The following link
can see what we can accomplish with this library;
good examples

Now let's take a link from this example that's great, the idea is to communicate
jquery jsp and. date only because I found this link
very good example to begin and the idea is not to copy but reusing code
jejejej the idea is to give a hand to COMUDES java.

http://rekkeb.wordpress.com/2009/03/15/comunicar-jsp-y-jquery/

as the topic is interesting I think we will create another entry on the subject, with more interesting examples.