Markou moment

This commit is contained in:
2024-02-16 17:19:54 -06:00
parent 80bfa39936
commit b96b2eeb8c
74 changed files with 5618 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<project-shared-configuration>
<!--
This file contains additional configuration written by modules in the NetBeans IDE.
The configuration is intended to be shared among all the users of project and
therefore it is assumed to be part of version control checkout.
Without this configuration present, some functionality in the IDE may be limited or fail altogether.
-->
<properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
<!--
Properties that influence various parts of the IDE, especially code formatting and the like.
You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
That way multiple projects can share the same settings (useful for formatting rules for example).
Any value defined here will override the pom.xml file value but is only applicable to the current project.
-->
<org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>10-web</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>
<org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>gfv700ee10</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>
<org-netbeans-modules-projectapi.jsf_2e_language>Facelets</org-netbeans-modules-projectapi.jsf_2e_language>
<netbeans.hint.jdkPlatform>JDK_15__System_</netbeans.hint.jdkPlatform>
</properties>
</project-shared-configuration>

View File

@@ -0,0 +1,83 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>asdv</groupId>
<artifactId>5</artifactId>
<version>1</version>
<packaging>war</packaging>
<name>Ajax5-1-Many</name>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<failOnMissingWebXml>false</failOnMissingWebXml>
<jakartaee>10.0.0</jakartaee>
</properties>
<dependencies>
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId>
<version>${jakartaee}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>13.0.2</version>
<classifier>jakarta</classifier>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>11</source>
<target>11</target>
<compilerArguments>
<endorseddirs>${endorsed.dir}</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${endorsed.dir}</outputDirectory>
<silent>true</silent>
<artifactItems>
<artifactItem>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId>
<version>${jakartaee}</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,20 @@
package asdv.ajax.resources;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.core.Response;
/**
*
* @author
*/
@Path("jakartaee10")
public class JakartaEE10Resource {
@GET
public Response ping(){
return Response
.ok("ping Jakarta EE")
.build();
}
}

View File

@@ -0,0 +1,276 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package beans;
import model.factoryOneToMany.OneToMany;
import model.factoryOneToMany.OneToManyFactory;
import jakarta.faces.event.AbortProcessingException;
import jakarta.faces.event.AjaxBehaviorEvent;
import jakarta.faces.view.ViewScoped;
import jakarta.inject.Named;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@Named
@ViewScoped
public class PartialProcessingBean implements Serializable
{
private String country;
private String city;
private String[] countries =
{
"USA", "Greece", "France"
};
private String[] citiesFrance =
{
"Paris", "Marseille"
};
private String[] citiesGreece =
{
"Athens", "Sparta"
};
private String[] citiesUsa =
{
"Lafayette", "New Orleans"
};
private OneToMany oneToMany = OneToManyFactory.createOneToMany();
private String name = "";
private String totalValue = "120.00";
private String email = "";
private String emailAgain = "";
private Date date;
private String tickets = "1";
private String price = "120";
private Map<String, Object> ticketAttrs;
private Map<String, Object> priceAttrs;
public PartialProcessingBean()
{
oneToMany.initializeOne(this.countries);
oneToMany.initializeMany(this.countries[0], citiesUsa);
oneToMany.initializeMany(this.countries[1], citiesGreece);
oneToMany.initializeMany(this.countries[2], citiesFrance);
ticketAttrs = new HashMap<>();
this.ticketAttrs.put("type", "number");
this.ticketAttrs.put("min", "1");
this.ticketAttrs.put("max", "4");
this.ticketAttrs.put("required", "required");
this.ticketAttrs.put("title",
"Enter a number between 1 and 4 inclusive.");
this.priceAttrs = new HashMap<>();
this.priceAttrs.put("type", "number");
this.priceAttrs.put("min", "120");
this.priceAttrs.put("max", "1000");
this.priceAttrs.put("required", "required");
this.priceAttrs.put("step", 10);
this.priceAttrs.put("title",
"Enter a number between 120 and 100 inclusive.");
}
public OneToMany getOneToMany()
{
System.out.println("getOneToMany()");
return oneToMany;
}
public String getCountry()
{
System.out.println("getCountry()");
return country;
}
public void setCountry(String country)
{
System.out.println("setCountry(String country) " + country );
this.country = country;
}
public String getCity()
{
return city;
}
public void setCity(String city)
{
System.out.println("setCity(String city) " + city );
this.city = city;
}
public String getEmail()
{
return email;
}
public void setEmail(String email)
{
System.out.println("setEmail(String email) " + city );
this.email = email;
}
public void handleCountryChange()
{
if (country != null && !country.equals(""))
{
getMany();
}
}
public Collection<String> getMany()
{
if (country != null && !country.equals(""))
{
return this.oneToMany.getMany(country);
}
return Arrays.asList(citiesUsa);
}
public String getName()
{
return name;
}
public void setName(String name)
{
System.out.println("setName(String name) " + name );
this.name = name;
}
public String getTotalValue()
{
System.out.println("getTotalValue(String totalValue) " );
return totalValue;
}
public void setTotalValue(String totalValue)
{
System.out.println("setTotalValue(String totalValue) " + totalValue );
this.totalValue = totalValue;
}
public String getEmailAgain()
{
System.out.println("getEmailAgain() " );
return emailAgain;
}
public void setEmailAgain(String emailAgain)
{
System.out.println("setEmailAgain(String emailAgain) " + emailAgain );
this.emailAgain = emailAgain;
}
public Date getDate()
{
System.out.println("getDate() ");
return date;
}
public void setDate(Date date)
{
System.out.println("setDate(Date date) " + date );
this.date = date;
}
public String getTickets()
{
System.out.println("getTickets() " );
return tickets;
}
public void setTickets(String tickets)
{
System.out.println("setTickets(String tickets) " + tickets );
this.tickets = tickets;
}
public String getPrice()
{
System.out.println("getPrice() " );
return price;
}
public void setPrice(String price)
{
System.out.println("setPrice(String price) " + price);
this.price = price;
}
public Map<String, Object> getTicketAttrs()
{
System.out.println("getTicketAttrs() " );
return ticketAttrs;
}
public void setTicketAttrs(Map<String, Object> ticketAttrs)
{
System.out.println("setTicketAttrs(Map<String, Object> ticketAttrs) " + ticketAttrs);
this.ticketAttrs = ticketAttrs;
}
public Map<String, Object> getPriceAttrs()
{
System.out.println("getPriceAttrs() " );
return priceAttrs;
}
public void setPriceAttrs(Map<String, Object> priceAttrs)
{
System.out.println("setPriceAttrs(Map<String, Object> priceAttrs) " + ticketAttrs);
this.priceAttrs = priceAttrs;
}
public void calculateTotal(AjaxBehaviorEvent event)
throws AbortProcessingException
{
System.out.println("calculateTotal(AjaxBehaviorEvent event)");
int ticketsNum = 1;
int ticketPrice = 0;
int total;
if (tickets.trim().length() > 0)
{
ticketsNum = Integer.parseInt(tickets);
}
if (price.trim().length() > 0)
{
ticketPrice = Integer.parseInt(price);
}
total = (ticketsNum * ticketPrice);
totalValue = String.valueOf(total) + ".00";
}
public void clear(AjaxBehaviorEvent event)
throws AbortProcessingException
{
System.out.println("clear(AjaxBehaviorEvent event)");
name = "";
email = "";
emailAgain = "";
date = null;
price = "120.00";
totalValue = "120.00";
tickets = "1";
}
}

View File

@@ -0,0 +1,68 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package model.factoryOneToMany;
import java.util.Collection;
import java.util.Set;
/**
*
* @author asdv5
* @param <One>
* @param <Many>
*/
public interface OneToMany<One, Many>
{
/**
* Initialization of Ones. The method should be used first before any other
* methods
*
* @param one - the ones ( i.e, countries, or SelectItem or any Object) to
* use for initialization
* @return true if the initialization succeeded by using the method once,
* false when the method is used more than once.
*/
boolean initializeOne(One... one);
/**
* Initialization of the many for a given one. The method can be used
* multiple times after the method initializeOne has succeeded.
*
* @param one - the one that has the many
* @param many - the many which belong to th eone
* @throws IllegalArgumentException when the one does not exist (i.e. user's
* typing error for the name of one) or when the initialization of the one
* has not occurred.
*
*/
void initializeMany(One one, Many... many)
throws IllegalArgumentException;
/**
* Gets the many of a specific one.
*
* @param one the one to get its many
* @return the many of the parameter one or null if the one does not exist.
*/
Collection<Many> getMany(One one);
/**
* Given a value of the many it gets the one that the many belongs to.
*
* @param many one of the values of the many
* @return the one
*/
One getOne(Many many);
/**
* Gets a set with all the ones
*
* @return the set of ones.
*/
Set<One> getAllOnes();
}

View File

@@ -0,0 +1,204 @@
package model.factoryOneToMany;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
public class OneToManyFactory
{
/**
* Creates an object of type OneToMany
*
* @param <One> a generic parameter can be any object that denotes a One.
* @param <Many> a generic parameter can be any object that denotes a city
* that belongs to the one generic type.
* @return a OneCity object.
*/
public static <One, Many> //generic types to be used in the method
OneToMany<One, Many> //rturn type
createOneToMany()
{
return new OneToMany<One, Many>()
{
private Map<Object, Object> oneToMany = new LinkedHashMap();
boolean oneInitialized = false;
boolean manyInitialized = false;
@Override
public boolean initializeOne(One... one)
{
if (oneInitialized == false && manyInitialized == false)
{
for (int i = 0; i < one.length; ++i)
{
oneToMany.put(one[i], new Boolean(true));
}
oneInitialized = true;
return true;
}
return false;
}
@Override
public void initializeMany(One one, Many... many)
throws IllegalArgumentException
{
if (oneToMany.get(one) == null)//if the key of the one is null
{//the method initializekey has not been used
throw new IllegalArgumentException(one + " is not valid");
}
oneToMany.put(one, new ArrayList<Many>(Arrays.asList(many)));
manyInitialized = true;
}
@Override
public Collection<Many> getMany(One one)
throws IllegalArgumentException
{
if (oneInitialized == true && manyInitialized == true)
{
if (oneToMany.get(one) == null)
{
throw new IllegalArgumentException(one + " is not a valid One");
}
Collection c1 = (Collection) oneToMany.get(one);
return c1;
}
return null;
}
@Override
public One getOne(Many many)
{
Set< Entry<Object, Object>> set = oneToMany.entrySet();
for (Map.Entry<Object, Object> entry : oneToMany.entrySet())
{
One key = (One) entry.getKey();
Collection<Many> value = (Collection<Many>) oneToMany.get(key);
if (value.contains(many))
{
return key;
}
}
return null;
}
@Override
public Set<One> getAllOnes()
{
return (Set<One>) oneToMany.keySet();
}
};
}
public static void main(String[] args)
{
OneToMany cc = OneToManyFactory.createOneToMany();
try
{
cc.initializeMany("France", "Paris");
}
catch (Exception e)
{
System.err.println(e);
}
boolean b1 = cc.initializeOne("USA", "Greece");
System.out.println(b1);
boolean b2 = cc.initializeOne("USA", "Greece");
System.out.println(b2);
cc.initializeMany("USA", "Lafayette", "New Orleans");
cc.initializeMany("Greece", "Athens", "Sparta");
Collection<String> cities1 = cc.getMany("USA");
System.out.println(cities1);
Collection<String> cities2 = cc.getMany("Greece");
System.out.println(cities2);
System.out.println(cc.getOne("Athens"));
System.out.println(cc.getOne("Lafayette"));
System.out.println(cc.getOne("France"));
try
{
System.out.println(cc.getMany("Germany"));
}
catch (Exception e)
{
System.err.println(e);
}
System.out.println(cc.getAllOnes());
System.out.println("--------------------------------------");
OneToMany supplierParts = OneToManyFactory.createOneToMany();
Supplier s1 = new Supplier("s1");
Supplier s2 = new Supplier("s2");
supplierParts.initializeOne(s1, s2);
Part p1 = new Part("p1");
Part p2 = new Part("p2");
Part p3 = new Part("p3");
Part p4 = new Part("p4");
supplierParts.initializeMany(s1, p1,p2);
supplierParts.initializeMany(s2, p3,p4);
System.out.println( supplierParts.getMany(s1));
System.out.println( supplierParts.getMany(s2));
System.out.println( supplierParts.getOne(p1) );
}
}
class Supplier
{
private String name;
public Supplier(String name)
{
this.name = name;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
@Override
public String toString()
{
return "Supplier{" + "name=" + name + '}';
}
}
class Part
{
private String name;
public Part(String name)
{
this.name = name;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
@Override
public String toString()
{
return "Part{" + "name=" + name + '}';
}
}

View File

@@ -0,0 +1,39 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package model.factoryOneToMany;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
/**
*
* @author asdv5
*/
public class TestMap
{
public static void main(String[] args)
{
HashMap<String, ArrayList<String>> map = new HashMap();
ArrayList l1 = new ArrayList<String>();
l1.add("p1");
l1.add("p2");
map.put("e1", l1);
ArrayList l2 = new ArrayList<String>();
l2.add("p2");
l2.add("p3");
map.put("e2", l2);
System.out.println(map);
Collection<ArrayList<String>> c = map.values();
System.out.println(c);
for (ArrayList<String> a : c )
a.remove("p2");
System.out.println(c);
System.out.println(map);
}
}

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="3.0" xmlns="https://jakarta.ee/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd">
<!-- Define Persistence Unit -->
<persistence-unit name="my_persistence_unit">
</persistence-unit>
</persistence>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="https://jakarta.ee/xml/ns/jakartaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/beans_4_0.xsd"
bean-discovery-mode="all">
</beans>

View File

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
http://www.eclipse.org/legal/epl-2.0.
This Source Code may also be made available under the following Secondary
Licenses when the conditions for such availability set forth in the
Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
version 2 with the GNU Classpath Exception, which is available at
https://www.gnu.org/software/classpath/license.html.
SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
-->
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app error-url="">
<class-loader delegate="true"/>
<jsp-config>
<property name="keepgenerated" value="true">
<description>Keep a copy of the generated servlet class' java code.</description>
</property>
</jsp-config>
</glassfish-web-app>

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="6.0" xmlns="https://jakarta.ee/xml/ns/jakartaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd">
<context-param>
<param-name>jakarta.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>jakarta.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>faces/index.xhtml</welcome-file>
</welcome-file-list>
</web-app>

View File

@@ -0,0 +1,15 @@
<?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">
<h:head>
<title>Ajax 5</title>
</h:head>
<h:body>
<h:form>
<h:commandLink value="Prime Faces Ajax" action="prime-faces-ajax"/>
<br/><br/>
<h:commandLink value="JSF Ajax" action="jsf-ajax"/>
</h:form>
</h:body>
</html>

View File

@@ -0,0 +1,122 @@
<?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:p="http://primefaces.org/ui"
xmlns:f5="http://xmlns.jcp.org/jsf/passthrough"
>
<h:head>
<title>JSF Ajax</title>
</h:head>
<h:body>
<html lang="en"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:jsf="http://xmlns.jcp.org/jsf"
>
<h:head>
<h:outputStylesheet library="css" name="stylesheet.css" />
<h:outputScript library="js" name="do_validation.js"/>
</h:head>
<h:body>
<h:form id="f1">
<h1>Ajax Prime Faces</h1>
<h2>Partial Proccess &amp; Partial Update</h2>
<p:panelGrid columns="1" layout="grid" >
<p:column>
<p:inputText id="full_name"
value="#{partialProcessingBean.name}"
required="required" title="Enter your name."
f5:placeholder="Name first &amp; last"
>
</p:inputText>
</p:column>
<p:column>
<p:outputLabel value="Country: " />
<p:selectOneMenu
id="countries" value="#{partialProcessingBean.country}">
<f:selectItems value="#{partialProcessingBean.oneToMany.getAllOnes()}" />
<p:ajax listener= "#{partialProcessingBean.handleCountryChange}"
event="change" update="cities" process="@this"/>
</p:selectOneMenu>
<p:outputLabel value="City: " />
<p:selectOneMenu id="cities" value="#{partialProcessingBean.city}">
<f:selectItems value="#{partialProcessingBean.getMany()}" />
</p:selectOneMenu>
</p:column>
<p:column>
<p:inputText id="email1"
f5:placeholder="Enter your email"
value="#{partialProcessingBean.email}"
required="required"
title="Enter email"/>
<p:inputText id="email2"
f5:placeholder="Enter email again"
value="#{partialProcessingBean.emailAgain}"
required="required"
title="Enter email again."
onblur="check('f1:email1', 'f1:email2')" />
</p:column>
<p:column>
<p:calendar id="date"
f5:placeholder="Performance date"
readonlyInput="true"
value="#{partialProcessingBean.date}"
required="required"
title="Enter or choose a date."/>
</p:column>
<p:column style="padding: 30px;">
<p:outputLabel value="Number of Tickets: " />
<p:inputText id="tickets" value="#{partialProcessingBean.tickets}">
<f:passThroughAttributes value="#{partialProcessingBean.ticketAttrs}"/>
<p:ajax event="change" update="total"
listener="#{partialProcessingBean.calculateTotal}"/>
</p:inputText>
<p:outputLabel value="Ticket price: " />
<p:inputText id="price"
value="#{partialProcessingBean.price}"
p:required="required" >
<f:passThroughAttributes value="#{partialProcessingBean.priceAttrs}"/>
<p:ajax event="change" update="total" process="@this"
listener="#{partialProcessingBean.calculateTotal}"/>
</p:inputText>
<br/>
<p:outputLabel value="Estimated total: " />
<p:outputLabel id="total"
value="#{partialProcessingBean.totalValue}"
>
</p:outputLabel>
</p:column>
</p:panelGrid>
<p:commandButton value="Clear and update all"
action="confirmation">
<p:ajax update="@all" listener="#{partialProcessingBean.clear}"/>
</p:commandButton>
</h:form>
</h:body>
</html>
</h:body>
</html>

View File

@@ -0,0 +1,122 @@
<?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:p="http://primefaces.org/ui"
xmlns:f5="http://xmlns.jcp.org/jsf/passthrough"
>
<h:head>
<title>Prime Paces Ajax</title>
</h:head>
<h:body>
<html lang="en"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:jsf="http://xmlns.jcp.org/jsf"
>
<h:head>
<h:outputStylesheet library="css" name="stylesheet.css" />
<h:outputScript library="js" name="do_validation.js"/>
</h:head>
<h:body>
<h:form id="f1">
<h1>Ajax Prime Faces</h1>
<h2>Partial Proccess &amp; Partial Update</h2>
<p:panelGrid columns="1" layout="grid" >
<p:column>
<p:inputText id="full_name"
value="#{partialProcessingBean.name}"
required="required" title="Enter your name."
f5:placeholder="Name first &amp; last"
>
</p:inputText>
</p:column>
<p:column>
<p:outputLabel value="Country: " />
<p:selectOneMenu
id="countries" value="#{partialProcessingBean.country}">
<f:selectItems value="#{partialProcessingBean.oneToMany.getAllOnes()}" />
<p:ajax listener= "#{partialProcessingBean.handleCountryChange}"
event="change" update="cities" process="@this"/>
</p:selectOneMenu>
<p:outputLabel value="City: " />
<p:selectOneMenu id="cities" value="#{partialProcessingBean.city}">
<f:selectItems value="#{partialProcessingBean.getMany()}" />
</p:selectOneMenu>
</p:column>
<p:column>
<p:inputText id="email1"
f5:placeholder="Enter your email"
value="#{partialProcessingBean.email}"
required="required"
title="Enter email"/>
<p:inputText id="email2"
f5:placeholder="Enter email again"
value="#{partialProcessingBean.emailAgain}"
required="required"
title="Enter email again."
onblur="check('f1:email1', 'f1:email2')" />
</p:column>
<p:column>
<p:calendar id="date"
f5:placeholder="Performance date"
readonlyInput="true"
value="#{partialProcessingBean.date}"
required="required"
title="Enter or choose a date."/>
</p:column>
<p:column style="padding: 30px;">
<p:outputLabel value="Number of Tickets: " />
<p:inputText id="tickets" value="#{partialProcessingBean.tickets}">
<f:passThroughAttributes value="#{partialProcessingBean.ticketAttrs}"/>
<p:ajax event="change" update="total"
listener="#{partialProcessingBean.calculateTotal}"/>
</p:inputText>
<p:outputLabel value="Ticket price: " />
<p:inputText id="price"
value="#{partialProcessingBean.price}"
p:required="required" >
<f:passThroughAttributes value="#{partialProcessingBean.priceAttrs}"/>
<p:ajax event="change" update="total" process="@this"
listener="#{partialProcessingBean.calculateTotal}"/>
</p:inputText>
<br/>
<p:outputLabel value="Estimated total: " />
<p:outputLabel id="total"
value="#{partialProcessingBean.totalValue}"
>
</p:outputLabel>
</p:column>
</p:panelGrid>
<p:commandButton value="Clear and update all"
action="confirmation">
<p:ajax update="@all" listener="#{partialProcessingBean.clear}"/>
</p:commandButton>
</h:form>
</h:body>
</html>
</h:body>
</html>

View File

@@ -0,0 +1,37 @@
/**
* Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
*
* You may not modify, use, reproduce, or distribute this software except in
* compliance with the terms of the License at:
* http://java.net/projects/javaeetutorial/pages/BerkeleyLicense
*/
input {
-moz-border-radius:6px;
-webkit-border-radius:6px;
border-radius:6px;
font-size:14px;
width:300px;
min-height:24px;
}
output {
font-size:14px;
}
body {
background-color: #ffffff;
font-size: 14px;
font-family: Verdana, "Verdana CE", Arial, "Arial CE", "Lucida Grande CE", lucida, "Helvetica CE", sans-serif;
color: #000000;
margin: 10px;
}
h2 {
font-family: Arial, "Arial CE", "Lucida Grande CE", lucida, "Helvetica CE", sans-serif;
border-bottom: 1px solid #AFAFAF;
font-size: 18px;
font-weight: bold;
margin: 0px;
padding: 0px;
color: #D20005;
}

View File

@@ -0,0 +1,9 @@
function check(email1, email2) {
var e1 = document.getElementById(email1).value;
var e2 = document.getElementById(email2).value;
if (e1 != e2)
alert("Emails don't match.");
}