Product Combo and play value in inputText

1

I am developing a DOCUMENT registry with parameters like Material, Name and other data. And as it will work, I make a normal PRODUCT registration with Material and Name parameters and in the registration screen of the DOCUMENT I want to open a combo like this "Material" code and choosing it, the name will be automatically played in the inputText field of NAME.

I created the combo and I can select it.

How to accomplish this function, something from JSF, JavaScript? I was told of the valueChanceListener, but tmb I do not know what it would be like?

Screen:

::PRODUCTEntity

@Audited@Entity@Table(name="produto")
public class Produto implements Serializable{

private static final long serialVersionUID = 1L;

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(name = "material", unique = true, length = 5, nullable = false)
private int material;

@IdentificaCampoPesquisa(descricaoCampo = "Nome", campoConsulta = "nome",      principal = 1)
@Column(name = "nome", nullable = false, length = 50)
private String nome;

:: Entity DOCUMENT

@Audited
@Entity
@Table(name = "documento")
public class Documento implements Serializable{

private static final long serialVersionUID = 1L;

@IdentificaCampoPesquisa(descricaoCampo = "Código", campoConsulta = "id")
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(name = "material", length = 5, nullable = false)
private int material;

@IdentificaCampoPesquisa(descricaoCampo = "Nome", campoConsulta = "nome",      principal = 1)
@Column(name = "nome", nullable = false, length = 50)
private String nome;

:: SCREEN AND SELECTONEMENU

<h:panelGrid id="gridDocCabecalho" columns="14">

<p:outputLabel for="material" value="Material " />
<p:selectOneMenu id="material" filter="true"
    value="#{documentoBeanView.objetoSelecionado.material}"
    converter="omnifaces.SelectItemsConverter" required="true"
    requiredMessage="Faltou selecionar o campo obrigatório 'Material'!!">

    <f:selectItem noSelectionOption="true"  itemLabel="Selecione material" />

    <f:selectItems value="#{produtoBeanView.produtos}" var="cursor"
    itemLabel="#{cursor.material}" itemValue="#{cursor.material}" 
    actionListener="documentoBeanView.teste()"/>
</p:selectOneMenu>

<p:outputLabel for="nome" value="Nome " />
<p:inputText id="nome" value="Nome " />

:: ProductBeanView entity

@Controller
@Scope(value="session")
@ManagedBean(name="produtoBeanView")
public class ProdutoBeanView extends BeanManagerViewAbstract {

private static final long serialVersionUID = 1L;

private String url = "/cadastro/cad_produto.jsf?faces-redirect=true";
private String urlFind = "/cadastro/busca/find_produto.jsf?faces-redirect=true";

private Produto objetoSelecionado =  new Produto();

private List<Produto> produtos = new ArrayList<Produto>();

@Autowired
private ProdutoController produtoController;

public List<SelectItem> getProduto() throws Exception{      
return produtoController.getListProdutoController();
}
    
asked by anonymous 27.05.2018 / 00:36

0 answers