ADF - How to get the value of a field for validation?

Forum sobre a ferramenta Oracle JDeveloper, ADF, OAF, etc. (Não é destinado ao aprendeziado da Linguagem Java em geral)
Post Reply
juniovitor
Rank: Programador Júnior
Rank: Programador Júnior
Posts: 15
Joined: Mon, 23 Jun 2008 1:54 pm
Location: Perdões - MG / Uberlândia - MG
Contact:
Júnio Vitor de Paula
www.vcnanetdesigners.com.br

PERSONALL,

I'm starting to develop using the ADF, so anything I say wrong except me!

The question is:

I would like to help me get the value of a field so I can make a validation! inside the method, how do I do this?

Note: The page is JSF (.jspx).

Select all

 
   1. public void validaValorCompra() {   
   2.    
   3.     // Quero obter aqui o valor do campo!   
   4.        
   5.     // Quero também setar um valor à outro campo caso o resultado que eu pegar do objeto anterior for satisfatório!   
   6.      
   7.     // Quero também mostrar mensagem na tela!         
   8.    
   9. }   
  10.    
  11. //Já desenvolvi algumas coisas usando o OAF, sendo assim no OAF, ficaria da seguinte forma:   
  12.    
  13. //"salvar" é o nome do botão.   
  14. if (pageContext.getParameter(EVENT_PARAM).equals("salvar")){   
  15.       
  16.    //jtfParceiro é o nome do campo   
  17.    OAMessageLovInputBean parceiro = (OAMessageLovInputBean)webBean.findChildRecursive("jtfParceiro");   
  18.       
  19.    String partner = (String)parceiro.getValue(pageContext);   
  20.          
  21.       //Se campo for nulo, mostra apresenta erro ao usuário, senão, commit e mostra mensagem de sucesso!   
  22.       if (partner == null){   
  23.           throw new OAException("Selecione um valor válido para 'Parceiro'.", OAException.ERROR);   
  24.       }else{   
  25.           meuApplicationModule.commit;   
  26.           throw new OAException("Dados gravados com sucesso!", OAException.CONFIRMATION);                    
  27.       }   
  28. }   
If anyone can help me, thank you!
victorhugomuniz
Moderador
Moderador
Posts: 1396
Joined: Fri, 01 Feb 2008 2:06 pm
Location: Rio de Janeiro - RJ
Contact:
:D

See if it helps you ..

JSP

Select all

 
<af:inputText valueChangeListener="#{nomeBean.validaValorCompra}" 
	      autoSubmit="true"/> 
Java

Select all

 
public void validaValorCompra (ValueChangeEvent evt) { 
	evt.getValue(); 
} 
carmaniacs
Rank: Estagiário Júnior
Rank: Estagiário Júnior
Posts: 1
Joined: Thu, 02 Jul 2009 9:49 am
Location: SP

Look for something about the JSF validator

below follows an example of the validator property of the INPUTTEXT component of the ADF

The object brings the string typed in the field, and validates The field before giving submit in the form.

Select all

 
    public void inputText3_validator(FacesContext facesContext,  
                                     UIComponent uiComponent, Object object) { 
        // Add event code here... 
         String cpf = object.toString();                
         if(validaCPF(cpf) != true){ 
             throw new ValidatorException(new FacesMessage("O cpf informado não é válido.")); 
         } 
    } 
Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 7 guests