Skip to content

Commit

Permalink
Backing Bean en JSF
Browse files Browse the repository at this point in the history
Backing Bean en JSF

Resolves: #
see also:#
  • Loading branch information
brian-emarquez committed Aug 13, 2021
1 parent 50fac1c commit 0581893
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,4 @@
/HolaMundoJSF/target/
/ControlClientes/target/
/ManagedBeansJSF/target/
/BackingBeanJSF/target/
1 change: 1 addition & 0 deletions BackingBeanJSF/.settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding/<project>=UTF-8
26 changes: 26 additions & 0 deletions BackingBeanJSF/src/main/java/beans/backing/VacanteForm.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package beans.backing;

import beans.model.Candidato;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.inject.Named;

@Named
@RequestScoped
public class VacanteForm {

@Inject
private Candidato candidato;

public void setCandidato(Candidato candidato){
this.candidato = candidato;
}

public String enviar(){
if(this.candidato.getNombre().equals("Brian")){
return "exito";
}
else
return "fallo";
}
}
3 changes: 2 additions & 1 deletion BackingBeanJSF/src/main/webapp/WEB-INF/beans.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_2_0.xsd"
bean-discovery-mode="all">
bean-discovery-mode="all"
version="2.0">
</beans>
14 changes: 14 additions & 0 deletions BackingBeanJSF/src/main/webapp/exito.xhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html">
<head>
<title>Exito</title>
</head>
<body>
<h:form>
Gracias #{candidato.nombre} por aplicar a la vacante
<br/>
<h:commandLink action="index">Regresar</h:commandLink>
</h:form>
</body>
</html>
14 changes: 14 additions & 0 deletions BackingBeanJSF/src/main/webapp/fallo.xhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html">
<head>
<title>Fallo</title>
</head>
<body>
<h:form>
Lo siento #{candidato.nombre}, no hay vacantes por el momento
<br/>
<h:commandLink action="index">Regresar</h:commandLink>
</h:form>
</body>
</html>
3 changes: 2 additions & 1 deletion BackingBeanJSF/src/main/webapp/index.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<td><h:message for="nombre"></h:message></td>
</tr>
</table>
<h:commandButton action="#{vacanteForm.enviar}" value="Enviar" />
</h:form>
</body>
</html>
</html>

0 comments on commit 0581893

Please sign in to comment.