Skip to content

Commit 0581893

Browse files
Backing Bean en JSF
Backing Bean en JSF Resolves: # see also:#
1 parent 50fac1c commit 0581893

File tree

7 files changed

+60
-2
lines changed

7 files changed

+60
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,3 +210,4 @@
210210
/HolaMundoJSF/target/
211211
/ControlClientes/target/
212212
/ManagedBeansJSF/target/
213+
/BackingBeanJSF/target/
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
eclipse.preferences.version=1
22
encoding//src/main/java=UTF-8
33
encoding//src/main/resources=UTF-8
4+
encoding//src/test/java=UTF-8
45
encoding/<project>=UTF-8
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package beans.backing;
2+
3+
import beans.model.Candidato;
4+
import javax.enterprise.context.RequestScoped;
5+
import javax.inject.Inject;
6+
import javax.inject.Named;
7+
8+
@Named
9+
@RequestScoped
10+
public class VacanteForm {
11+
12+
@Inject
13+
private Candidato candidato;
14+
15+
public void setCandidato(Candidato candidato){
16+
this.candidato = candidato;
17+
}
18+
19+
public String enviar(){
20+
if(this.candidato.getNombre().equals("Brian")){
21+
return "exito";
22+
}
23+
else
24+
return "fallo";
25+
}
26+
}

BackingBeanJSF/src/main/webapp/WEB-INF/beans.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_2_0.xsd"
5-
bean-discovery-mode="all">
5+
bean-discovery-mode="all"
6+
version="2.0">
67
</beans>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<html xmlns="http://www.w3.org/1999/xhtml"
3+
xmlns:h="http://java.sun.com/jsf/html">
4+
<head>
5+
<title>Exito</title>
6+
</head>
7+
<body>
8+
<h:form>
9+
Gracias #{candidato.nombre} por aplicar a la vacante
10+
<br/>
11+
<h:commandLink action="index">Regresar</h:commandLink>
12+
</h:form>
13+
</body>
14+
</html>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<html xmlns="http://www.w3.org/1999/xhtml"
3+
xmlns:h="http://java.sun.com/jsf/html">
4+
<head>
5+
<title>Fallo</title>
6+
</head>
7+
<body>
8+
<h:form>
9+
Lo siento #{candidato.nombre}, no hay vacantes por el momento
10+
<br/>
11+
<h:commandLink action="index">Regresar</h:commandLink>
12+
</h:form>
13+
</body>
14+
</html>

BackingBeanJSF/src/main/webapp/index.xhtml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<td><h:message for="nombre"></h:message></td>
1414
</tr>
1515
</table>
16+
<h:commandButton action="#{vacanteForm.enviar}" value="Enviar" />
1617
</h:form>
1718
</body>
18-
</html>
19+
</html>

0 commit comments

Comments
 (0)