> For the complete documentation index, see [llms.txt](https://avbravo-2.gitbook.io/stack-jmoordb/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://avbravo-2.gitbook.io/stack-jmoordb/distribuir-componentes-en-jar/distribuir-componentes-desde-java-class/crear-composite-maven.md).

# Crear composite Maven

## Crear composite Maven

Crear el proyecto Maven

![](https://2819834543-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lc1Wg6wzqWd-vuP4MQJ%2F-Lc1WiPBw4oZ0KNAK7bx%2F-Lc1Wu1Xl-PIxWLM5ms1%2Fa0542c26-02f1-43f1-bdca-2fdfb43b44b6.png?generation=1554820618703927\&alt=media)

Indicamos el nombre del proyecto

![](https://2819834543-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lc1Wg6wzqWd-vuP4MQJ%2F-Lc1WiPBw4oZ0KNAK7bx%2F-Lc1Wu1bQoOZW7gkd-z2%2F3352ab53-ee6f-4819-8346-dc7fbe8413e1.png?generation=1554820610576458\&alt=media)

al darle finalizar se crea el proyecto jmoordbjsf

![](https://2819834543-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lc1Wg6wzqWd-vuP4MQJ%2F-Lc1WiPBw4oZ0KNAK7bx%2F-Lc1Wu1eJiEr0uXJCIc8%2F459529d2-40b9-4014-bf05-7a80b579bece.png?generation=1554820613855740\&alt=media)

Revisamos las propiedades del proyecto

![](https://2819834543-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lc1Wg6wzqWd-vuP4MQJ%2F-Lc1WiPBw4oZ0KNAK7bx%2F-Lc1Wu1h8L3IBPxWOiEZ%2F4e672ce0-9205-4f3e-aa87-a8ef93fbb9e6.png?generation=1554820617466793\&alt=media)

### Editar el archivo pom.xml

![](https://2819834543-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lc1Wg6wzqWd-vuP4MQJ%2F-Lc1WiPBw4oZ0KNAK7bx%2F-Lc1Wu1jzS2c5Fsjwwfw%2F85b5013b-4491-45d7-bd54-7b07198ce427.png?generation=1554820618718506\&alt=media)

### Agregar dependencias

* primefaces
* bootfaces

```css
dependencies>
        <dependency>
            <groupId>org.primefaces</groupId>
            <artifactId>primefaces</artifactId>
            <version>6.2</version>
        </dependency>
          <dependency>
            <groupId>net.bootsfaces</groupId>
            <artifactId>bootsfaces</artifactId>
            <version>1.4.0</version>
        </dependency>
    </dependencies>
```

* **Agregar la seccion build**

```java
<build>
    <finalName>${project.artifactId}</finalName> 
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <compilerArguments>
                        <endorseddirs>${endorsed.dir}</endorseddirs>
                    </compilerArguments>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-ejb-plugin</artifactId>
                <version>3.0.1</version>
                <configuration>
                    <ejbVersion>3.1</ejbVersion>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>3.1.1</version>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${endorsed.dir}</outputDirectory>
                            <silent>true</silent>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>javax</groupId>
                                    <artifactId>javaee-endorsed-api</artifactId>
                                    <version>7.0</version>
                                    <type>jar</type>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
```

### Dependencias

![](https://2819834543-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lc1Wg6wzqWd-vuP4MQJ%2F-Lc1WiPBw4oZ0KNAK7bx%2F-Lc1Wu1oRS9bkqV0dVfT%2F3304d06a-8a30-414e-ac7e-c31d520114e0.png?generation=1554820609213782\&alt=media)

### En la pestaña Files de NetBeans

![](https://2819834543-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lc1Wg6wzqWd-vuP4MQJ%2F-Lc1WiPBw4oZ0KNAK7bx%2F-Lc1Wu1qSbb7YCrwEB1o%2F979630db-10c6-49f9-908c-9af44bbed822.png?generation=1554820610487987\&alt=media)

Dar clic derecho New--> Folder...

![](https://2819834543-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lc1Wg6wzqWd-vuP4MQJ%2F-Lc1WiPBw4oZ0KNAK7bx%2F-Lc1Wu1sC86of9OGXxb6%2Fbaa2ba43-0b1b-48aa-8818-8dc341ba4465.png?generation=1554820612850387\&alt=media)

indicar resources/META-INF

![](https://2819834543-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lc1Wg6wzqWd-vuP4MQJ%2F-Lc1WiPBw4oZ0KNAK7bx%2F-Lc1Wu1uza6AdfV2X3bG%2F7bc443ef-aecf-49a1-a046-0e1c2ffab7ff.png?generation=1554820607314969\&alt=media)

### Creamos los archivos xml:

* faces-config.xml
* jmoordbjsf.tablib.xml

![](https://2819834543-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lc1Wg6wzqWd-vuP4MQJ%2F-Lc1WiPBw4oZ0KNAK7bx%2F-Lc1Wu1wPXTnAdn5JYJC%2F8a1ccde5-6c28-4860-9889-f6c1d8f76e52.png?generation=1554820607312191\&alt=media)

#### faces-config.xml

```java
<?xml version="1.0"?>
<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
            http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
        version="2.0">

    <!-- Empty config file to enable JSF annotation scanning -->

</faces-config>
```

#### jmoordbjsf.tablib.xml

* Indicamos el namespace
* library-name

```java
<?xml version="1.0"?>
<facelet-taglib version="2.0"
        xmlns="http://java.sun.com/xml/ns/javaee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facelettaglibrary_2_0.xsd">

    <namespace>http://jmoordbjsf.com/taglib</namespace>
    <composite-library-name>jmoordbjsf</composite-library-name>
</facelet-taglib>
```

### Dentro de la carpeta META-INF

* creamos la carpeta resources/jmoordbjsf

![](https://2819834543-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lc1Wg6wzqWd-vuP4MQJ%2F-Lc1WiPBw4oZ0KNAK7bx%2F-Lc1Wu1yG9iUQft17ZD5%2F72c97a2b-1e84-4bd2-a14a-a6b94af0711f.png?generation=1554820619444584\&alt=media)

indicamos los nombres de carpeta

![](https://2819834543-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lc1Wg6wzqWd-vuP4MQJ%2F-Lc1WiPBw4oZ0KNAK7bx%2F-Lc1Wu2-ehDP227vw3P9%2F95798f58-d636-4090-966d-dc354f15590a.png?generation=1554820609884142\&alt=media)

### En este directorio agregamos:

* composite
* imagenes
* css
* js

![](https://2819834543-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lc1Wg6wzqWd-vuP4MQJ%2F-Lc1WiPBw4oZ0KNAK7bx%2F-Lc1Wu21O33Sdnj2M39r%2Fe416c323-ee14-473f-8241-b01c3a54a5b7.png?generation=1554820609089834\&alt=media)

### Creando el primer componente

* Creamos un componente selectOneMenu de bootfaces simplificando las opciones si/no.
* Ubicarse en la carpeta jmoordbjsf
* Clic derecho --> New -->Other

![](https://2819834543-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lc1Wg6wzqWd-vuP4MQJ%2F-Lc1WiPBw4oZ0KNAK7bx%2F-Lc1Wu23QzqtEyH84PBE%2F217930f9-2e7d-42d3-b161-55e2b01ae673.png?generation=1554820607349919\&alt=media)

**Categories**: Java Server Faces

**File Types:** JSF Page

![](https://2819834543-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lc1Wg6wzqWd-vuP4MQJ%2F-Lc1WiPBw4oZ0KNAK7bx%2F-Lc1Wu25MdMWnuvPVW7K%2F61118e59-5c3b-4800-8163-79f8685a4549.png?generation=1554820607359217\&alt=media)

Nota: Si seleccionamos JSF Composite Component, no permitirá finalizar porque no es un proyecto web, por esta razon seleccionamos JSF Page.

### File Name: yesno

![](https://2819834543-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lc1Wg6wzqWd-vuP4MQJ%2F-Lc1WiPBw4oZ0KNAK7bx%2F-Lc1Wu27fZ90flat06yJ%2F75de9c95-a09a-401d-921c-2245cd371be1.png?generation=1554820608042089\&alt=media)

se crea el archivo yesno.xhtml, sobre el que vamos a editar para agregar el composite.

![](https://2819834543-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lc1Wg6wzqWd-vuP4MQJ%2F-Lc1WiPBw4oZ0KNAK7bx%2F-Lc1Wu29Qd8qgUaKlZzd%2F4295e19a-f90d-4208-b81f-585f0823fd9b.png?generation=1554820611100933\&alt=media)

Reemplazamos por el código

```java
<?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:p="http://primefaces.org/ui"
      xmlns:composite="http://java.sun.com/jsf/composite"
      xmlns:b="http://bootsfaces.net/ui"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:h="http://xmlns.jcp.org/jsf/html">
    <composite:interface >

        <composite:attribute name="value" />

        <composite:attribute name="required"/>
        <composite:attribute name="rendered"/>
        <composite:attribute name="disabled" default="false"/>
        <composite:attribute name="id"/>
        <composite:attribute name="colMd" default="2"/>
        <composite:attribute name="labelColMd" default="2"/>

    </composite:interface>
    <composite:implementation>


        <b:selectOneMenu value="#{cc.attrs.value}"
                         disabled="#{cc.attrs.disabled}"
                         colMd="#{cc.attrs.colMd}" 
                         required="#{cc.attrs.required}" 
                         requiredMessage="#{app['title.sexo']} #{app['info.notnull']}"
                         labelColMd="#{cc.attrs.labelColMd}" >
            <f:selectItem itemLabel="#{app['button.yes']}" itemValue="si" />
            <f:selectItem itemLabel="#{app['button.no']}" itemValue="no" />

        </b:selectOneMenu>
        <h:graphicImage library="jsflive" name="add.png"/>

    </composite:implementation>

</html>
```

**Nota:** El componente tiene asociados etiquetas definidas en avbravoutils y esta orientado a ejbjmoordb.

### Construir el proyecto

Clic derecho--> Clearn & Build

![](https://2819834543-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lc1Wg6wzqWd-vuP4MQJ%2F-Lc1WiPBw4oZ0KNAK7bx%2F-Lc1Wu2BwI_cCvp37hXn%2Fd9e2435f-2410-4fb6-ac40-bce5cfe472d2.png?generation=1554820607355651\&alt=media)

Se crea el archivo .jar y se registra en maven

![](https://2819834543-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lc1Wg6wzqWd-vuP4MQJ%2F-Lc1WiPBw4oZ0KNAK7bx%2F-Lc1Wu2D7wIgnGzeFs9V%2Fba69b1fd-3e8d-43ee-9626-5472367c5ff1.png?generation=1554820612019244\&alt=media)

### CSS

* Creamos un archivo css dentro de resources/jmoordbjsf

![](https://2819834543-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lc1Wg6wzqWd-vuP4MQJ%2F-Lc1WiPBw4oZ0KNAK7bx%2F-Lc1Wu2F4n6D390wVT3l%2Fcdaaa656-22b1-4428-8290-5db8ca9c23cb.png?generation=1554820607332873\&alt=media)

Ejemplo de css

![](https://2819834543-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lc1Wg6wzqWd-vuP4MQJ%2F-Lc1WiPBw4oZ0KNAK7bx%2F-Lc1Wu2HUz539RHHZ4OQ%2F221c2edd-9bd6-48ee-ae11-62547192e963.png?generation=1554820610329814\&alt=media)

### Agregarlo al composite

* usar el   \<h:outputStylesheet library=**"jmoordbjsf**" name=**"jmoordbjsf.css"**/>
* Mediante el styleClass de cada componente usamos la propiedad deseada. \<p:datatable **styleClass="ui-datatable"**>

```java
<?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:p="http://primefaces.org/ui"
      xmlns:composite="http://java.sun.com/jsf/composite"
      xmlns:b="http://bootsfaces.net/ui"
      xmlns:f="http://xmlns.jcp.org/jsf/core">
    <composite:interface >

    <cc:interface >
        <cc:attribute name="id"/>

    </cc:interface>

    <cc:implementation>
       <p:dataTable styleClass="ui-datatable"/>
        <h:outputStylesheet library="jmoordbjsf" name="jmoordb.css"/>
    </cc:implementation>

</ui:composition>
```

### IMAGENES

* Las imagenes las agregamos dentro de resources/jmoordbjsf

![](https://2819834543-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lc1Wg6wzqWd-vuP4MQJ%2F-Lc1WiPBw4oZ0KNAK7bx%2F-Lc1Wu2J_aT2SmPJrOHj%2F47e20bc0-77c6-4bb4-9fe5-3699d17bc0ed.png?generation=1554820615729012\&alt=media)

Usar la imágenes en el componente componente

```java
 <h:graphicImage library="jmoordbjsf" name="add.png"/>
```

Si ejecutamos un proyecto, se vería la imagen

![](https://2819834543-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lc1Wg6wzqWd-vuP4MQJ%2F-Lc1WiPBw4oZ0KNAK7bx%2F-Lc1Wu2LN7vxiuu6guEd%2Fa26217bc-e44a-4d58-aa16-51b916df6307.png?generation=1554820612942222\&alt=media)

## Probar el Componente

* Creamos un proyecto Web
* Agregarmos la dependencia jmordbjsf
* Agregar el componente a una pagina.
* En este ejemplo usaremos el plugin de PayaraMicro para generar el proyecto
* Repositorio del proyecto

<https://github.com/avbravo/jmoordbjsftest>

Crear el proyecto: jmoordbjsftest

![](https://2819834543-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lc1Wg6wzqWd-vuP4MQJ%2F-Lc1WiPBw4oZ0KNAK7bx%2F-Lc1Wu2NtfzOlH_HtLke%2Fbf29efe8-9716-4402-a7fd-1d67366aab15.png?generation=1554820617496018\&alt=media)

Indicar el nombre del proyecto

![](https://2819834543-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lc1Wg6wzqWd-vuP4MQJ%2F-Lc1WiPBw4oZ0KNAK7bx%2F-Lc1Wu2PHEWfDu7Y48MX%2Fa462a269-65c6-4425-bfd6-dbbd5bfb0c45.png?generation=1554820607514956\&alt=media)

PayaraMicro en este ejemplo la versión 5.183 o superior

![](https://2819834543-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lc1Wg6wzqWd-vuP4MQJ%2F-Lc1WiPBw4oZ0KNAK7bx%2F-Lc1Wu2RU47tS73Rvvgy%2Fbef60672-4f36-4586-8a83-42bbf9a8cbbf.png?generation=1554820610471791\&alt=media)

En las propiedades del proyecto activamos la configuración, revisamos la versión del JDK, y seleccionamos primefaces como framework

![](https://2819834543-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lc1Wg6wzqWd-vuP4MQJ%2F-Lc1WiPBw4oZ0KNAK7bx%2F-Lc1Wu2TUvP6qqvAilY1%2F04c809f5-d1c8-4b62-b9a5-3e4a1e0cefca.png?generation=1554820611920636\&alt=media)

### Editamos el archivo pom.xml

* **Actualizar la version de primefaces**

```java
<dependency>
            <groupId>org.primefaces</groupId>
            <artifactId>primefaces</artifactId>
            <version>6.2</version>
        </dependency>
```

* **Agregar avbravoutls**

```java
    <dependency>
        <groupId>com.github.avbravo</groupId>
        <artifactId>avbravoutils</artifactId>
        <version>0.39.4</version>
    </dependency>
```

* **Agregar jmoordbjsf (mediante jitpack)**

```java
      <dependency>
        <groupId>com.github.avbravo</groupId>
        <artifactId>jmoordbjsf</artifactId>
        <version>0.1</version>
    </dependency
```

* **Agregar el repository jitpack**

```java
  <repository>
            <id>jitpack.io</id>
            <url>https://jitpack.io</url>
        </repository>
```

#### En el build

* Actualizar las versiones de los plugins de  maven a las ultimas

```java
 <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <compilerArguments>
                        <endorseddirs>${endorsed.dir}</endorseddirs>
                    </compilerArguments>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.2.2</version>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
```

* Agregar el final name

```java
<finalName>jmoordbjsfg</finalName>
```

### Crearemos un Controller para manejar los datos

* Ubicarse en el paquete com.avbravo.jmoordbjsftest
* Dar clic derecho&#x20;
* Seleccionar -->New -->JSF Managed Bean

![](https://2819834543-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lc1Wg6wzqWd-vuP4MQJ%2F-Lc1WiPBw4oZ0KNAK7bx%2F-Lc1Wu2VQumfmWSSi_NY%2F87f8cb60-47f5-48c9-9144-102656c9219e.png?generation=1554820607624447\&alt=media)

Lo denominamos MyController en el scope: Request

Se crea la clase MyController.java

```java
package com.avbravo.jmoordbjsftest;

import javax.inject.Named;
import javax.enterprise.context.RequestScoped;

/**
 *
 * @author avbravo
 */
@Named(value = "myContoller")
@RequestScoped
public class MyContoller {

    /**
     * Creates a new instance of MyContoller
     */
    public MyContoller() {
    }

}
```

* Implemenamos Serializable
* Agregamos una propiedad para almacenar la opción seleccionada&#x20;
* Creamos un método para mostrar el mensaje
* Utilizar JsfUtil para enviar mensajes

### Código Final

```java
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.avbravo.jmoordbjsftest;

import com.avbravo.avbravoutils.JsfUtil;
import java.io.Serializable;
import javax.inject.Named;
import javax.enterprise.context.RequestScoped;

/**
 *
 * @author avbravo
 */
@Named
@RequestScoped
public class MyController implements Serializable{
private String seleccion;

    public String getSeleccion() {
        return seleccion;
    }

    public void setSeleccion(String seleccion) {
        this.seleccion = seleccion;
    }




    /**
     * Creates a new instance of MyContoller
     */
    public MyController() {
    }

    public String mostrar(){
        JsfUtil.errorDialog("Seleccion:", seleccion); 
        return "";
    }
}
```

### Ahora editamos el archivo index.xhtml

![](https://2819834543-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lc1Wg6wzqWd-vuP4MQJ%2F-Lc1WiPBw4oZ0KNAK7bx%2F-Lc1Wu2XudQ_-b6iSrSs%2F6e74d3c8-e065-478c-abca-e05ed8cbad21.png?generation=1554820618708376\&alt=media)

Archivo inicial

```java
<?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>Facelet Title</title>
    </h:head>
    <h:body>
        Hello from Facelets
        <br />
        <h:link outcome="welcomePrimefaces" value="Primefaces welcome page" />
    </h:body>
</html>
```

* Agregar el namespace jm: para usarlo con los componentes  y el taglib.

```java
xmlns:jm="http://jmoordbjsf.com/taglib"
```

* Agregar el \<f:view>

```java
 <f:view contentType="text/html">
```

* Agregar un \<h:form>

```java
 </h:form>
```

* Agregamos un \<p:message>

```java
<p:messages id="msg"/>
```

* Agregar el componente

```java
 <jm:yesno id="a" value="#{myController.seleccion}"/>
```

* \<p:commandButton> para mostrar la opcion seleccionada por el usuario

```java
 <p:commandButton value="Mostrar" update="msg" action="#{myController.save()}"/>
```

### Cogido completo

```
<?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:jm="http://jmoordbjsf.com/taglib" 
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:p="http://primefaces.org/ui">
    <f:view contentType="text/html">
        <h:head>
            <title>Facelet Title</title>
        </h:head>
        <h:body>
            <h:form>
                <p:messages id="msg"/>
                <jm:yesno id="a" value="#{myController.seleccion}"/>


                <p:commandButton value="Mostrar" update="msg" action="#{myController.mostrar()}"/>
            </h:form>
        </h:body>
    </f:view>
</html>
```

### Ejecutar el proyecto

* Se muestra el componente
* Al dar clic en el botón se despliega un mensaje con la selección.

![](https://2819834543-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lc1Wg6wzqWd-vuP4MQJ%2F-Lc1WiPBw4oZ0KNAK7bx%2F-Lc1Wu2acyjQ57UApZeB%2F611404dc-8e89-464e-bd20-8f04d8eb7382.png?generation=1554820609959839\&alt=media)
