<?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:f="http://xmlns.jcp.org/jsf/core">
    
    <f:metadata>
        <f:viewParam id='state' name='state' value='#{bean3.state}' />
        <f:viewAction action='#{bean3.chargeCustomersFromState()}'/>
    </f:metadata>
    <h:message for='state'/>
    
    <h:head>
        <title>Test formulaire HTML et viewParams</title>
    </h:head>
    
    <h:body>
        <form id="form" >
            <label for='input'>Etat : </label>
            <input id="state" type='text' name='state' 
                   value='#{empty bean3.state ? param.state : bean3.state}'/>
            <input type='submit' value='Afficher'/>
        </form>
        
        <h:dataTable value='#{bean3.customers}' var='customer' 
                     rendered='#{not empty bean3.customers}'>
            <h:column>
                <f:facet name="header">Nom</f:facet>
                #{customer.name}
            </h:column>
            <h:column>
                <f:facet name="header">Etat</f:facet>
                #{customer.state}
            </h:column>
        </h:dataTable>
    </h:body>
</html>