Skip to main content

JSF2 Nightly Build - Custom Component and Form Submit

6 replies [Last post]
israelbgf
Offline
Joined: 2009-03-31
Points: 0

I made a simple component that only allows numbers in the inputText but it throws an invalid argument exception. It's pretty simple so i cant find any problem in it.

/* 31 && (charCode < 48 || charCode > 57))
return false;

return true;
}
/* ]]> */

The error:

javax.faces.component.UpdateModelException: javax.el.ELException: /resources/componentes/inputNumero.xhtml @23,98 value="#{compositeComponent.attrs.value}": /crud.xhtml @15,65 value="#{crudTeste.pessoa.idade}": java.lang.IllegalArgumentException: argument type mismatch

idade is a Integer.

Thks in advance,

Israel

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Ryan Lubke

On 3/31/09 9:19 AM, webtier@javadesktop.org wrote:
>
>
>

>
>
>

>
>
>
Are you using a Mojarra 2.0.0 nightly build? What container/version is
your app deployed to>

I don't see anything obviously wrong here, and when I attempt this
locally with GFv3, based off the information
you've provided, it seems to work fine.

---------------------------------------------------------------------
To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: webtier-help@glassfish.dev.java.net

israelbgf
Offline
Joined: 2009-03-31
Points: 0

Yes, (build from the Monday at 10 p.m). I'm using Tomcat 6.0.18.

rlubke
Offline
Joined: 2003-08-21
Points: 0

Ok, no issues on Tomcat either. Can you post the relevant managed bean code?

israelbgf
Offline
Joined: 2009-03-31
Points: 0

Well, about the error, it was probably cause i'm using JBoss EL, maybe a compatibility issue (i was mixing technologies for my testings), anyway i removed it and it started to work again (now i'm testing with plain jsf). But i found another problem.

When i submit the form (using f:ajax), my action add a faces message and populates a list, i used the render="@all" attribute, so i expected that after the method invocation my list and my message get rendered with their new values, but that's not what happened, not with my custom component rendered in the form at least, because if i comment it all the stuff start to work again. Another strange thing, my faces message is being duplicated (but i think that it probably my fault).

Anyway, here it's the code. (Tomcat 6.0.18 / Nightly Build (yesterday 01/04))

---------------------------------------------------------------------------------------------------------
Main Page
---------------------------------------------------------------------------------------------------------

xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
template="/templates/template.xhtml"
xmlns:my="http://java.sun.com/jsf/composite/componentes">


Nome:


Idade:








Nome

#{item.nome}



Idade

#{item.idade}



Cidade

#{item.cidade.nome}



Funcao









---------------------------------------------------------------------------------------------------------
Backing Bean Code
---------------------------------------------------------------------------------------------------------
@SuppressWarnings("serial")
@ManagedBean(name = "crudTeste")
@ViewScoped
public class CRUDTeste implements Serializable {

private Pessoa pessoa;

private List lista;

@PostConstruct
public void construct() {
lista = new ArrayList();
pessoa = new Pessoa();
}

public void salvar(){
lista.add(pessoa);
pessoa = new Pessoa();
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Pessoa salva com sucesso!"));
}

public void excluir(){
String nome = FacesUtil.getParameter("item").toString();
for(Pessoa p : lista){
if(p.getNome().equals(nome)){
lista.remove(p);
}
}
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Pessoa removida com sucesso!"));
}

public void setPessoa(Pessoa pessoa) {
this.pessoa = pessoa;
}

public Pessoa getPessoa() {
return pessoa;
}

public void setLista(List lista) {
this.lista = lista;
}

public List getLista() {
return lista;
}

/*
* No JSF2 os SelectItens podem apontar diretamente para objetos.
*/
public List getCidades(){
List lista = new ArrayList();

Cidade c = new Cidade("Tubarao");
lista.add(c);

c = new Cidade("Criciuma");
lista.add(c);

c = new Cidade("Ararangua");
lista.add(c);

return lista;
}

}
---------------------------------------------------------------------------------------------------------
Component Code
---------------------------------------------------------------------------------------------------------
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:composite="http://java.sun.com/jsf/composite">





---------------------------------------------------------------------------------------------------------
And sorry about the text formatting, the forum broke it. I putted the lines do make it easier to copy and paste it to an editor.

Jim Driscoll

I'm afraid I wasn't able to duplicate your error, unfortunately.

I was able to get the doubled Messages though, and I've filed that as
bug # 1068.

I wasn't able to completely duplicate your code, of course, and it has a
lot of moving parts - if you could simplfy it to a small code section
demonstrating the bug, that would be helpful in diagnosing the problem...

Jim

On 4/2/09 4:45 AM, webtier@javadesktop.org wrote:
> Well, about the error, it was probably cause i'm using JBoss EL, maybe a compatibility issue (i was mixing technologies for my testings), anyway i removed it and it started to work again (now i'm testing with plain jsf). But i found another problem.
>
> When i submit the form (using f:ajax), my action add a faces message and populates a list, i used the render="@all" attribute, so i expected that after the method invocation my list and my message get rendered with their new values, but that's not what happened, not with my custom component rendered in the form at least, because if i comment it all the stuff start to work again. Another strange thing, my faces message is being duplicated (but i think that it probably my fault).
>
> Anyway, here it's the code. (Tomcat 6.0.18 / Nightly Build (yesterday 01/04))
>
> ---------------------------------------------------------------------------------------------------------
> Main Page
> ---------------------------------------------------------------------------------------------------------
>
> > xmlns:f="http://java.sun.com/jsf/core"
> xmlns:h="http://java.sun.com/jsf/html"
> xmlns:ui="http://java.sun.com/jsf/facelets"
> template="/templates/template.xhtml"
> xmlns:my="http://java.sun.com/jsf/composite/componentes">
>
>
> Nome:
>
>

>
>

> Idade:
>
>

>

>
>
>
>

>
>
>
>
>
>
>
> Nome
>

> #{item.nome}
>

>
>
> Idade
>

> #{item.idade}
>

>
>
> Cidade
>

> #{item.cidade.nome}
>

>
>
> Funcao
>

>
>
>
>
>

>

>

>

>
>
> ---------------------------------------------------------------------------------------------------------
> Backing Bean Code
> ---------------------------------------------------------------------------------------------------------
> @SuppressWarnings("serial")
> @ManagedBean(name = "crudTeste")
> @ViewScoped
> public class CRUDTeste implements Serializable {
>
> private Pessoa pessoa;
>
> private List lista;
>
> @PostConstruct
> public void construct() {
> lista = new ArrayList();
> pessoa = new Pessoa();
> }
>
> public void salvar(){
> lista.add(pessoa);
> pessoa = new Pessoa();
> FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Pessoa salva com sucesso!"));
> }
>
> public void excluir(){
> String nome = FacesUtil.getParameter("item").toString();
> for(Pessoa p : lista){
> if(p.getNome().equals(nome)){
> lista.remove(p);
> }
> }
> FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Pessoa removida com sucesso!"));
> }
>
> public void setPessoa(Pessoa pessoa) {
> this.pessoa = pessoa;
> }
>
> public Pessoa getPessoa() {
> return pessoa;
> }
>
> public void setLista(List lista) {
> this.lista = lista;
> }
>
> public List getLista() {
> return lista;
> }
>
> /*
> * No JSF2 os SelectItens podem apontar diretamente para objetos.
> */
> public List getCidades(){
> List lista = new ArrayList();
>
> Cidade c = new Cidade("Tubarao");
> lista.add(c);
>
> c = new Cidade("Criciuma");
> lista.add(c);
>
> c = new Cidade("Ararangua");
> lista.add(c);
>
> return lista;
> }
>
> }
> ---------------------------------------------------------------------------------------------------------
> Component Code
> ---------------------------------------------------------------------------------------------------------
> > xmlns:h="http://java.sun.com/jsf/html"
> xmlns:ui="http://java.sun.com/jsf/facelets"
> xmlns:composite="http://java.sun.com/jsf/composite">
>
>
>
>

>
>
>

>
>
>
>
> ---------------------------------------------------------------------------------------------------------
> And sorry about the text formatting, the forum broke it. I putted the lines do make it easier to copy and paste it to an editor.
> [Message sent by forum member 'israelbgf' (israelbgf)]
>
> http://forums.java.net/jive/thread.jspa?messageID=340253
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: webtier-help@glassfish.dev.java.net
>

---------------------------------------------------------------------
To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: webtier-help@glassfish.dev.java.net

Jim Driscoll

Sorry, I shouldn't answer emails after 9pm - the reason the message is
doubled is because you have a message with only a summary, and you have
showDetail=true.

remove showDetail, and it's only one message.

Jim

On 4/7/09 9:57 PM, Jim Driscoll wrote:
> I'm afraid I wasn't able to duplicate your error, unfortunately.
>
> I was able to get the doubled Messages though, and I've filed that as
> bug # 1068.
>
> I wasn't able to completely duplicate your code, of course, and it has a
> lot of moving parts - if you could simplfy it to a small code section
> demonstrating the bug, that would be helpful in diagnosing the problem...
>
> Jim
>
> On 4/2/09 4:45 AM, webtier@javadesktop.org wrote:
>> Well, about the error, it was probably cause i'm using JBoss EL, maybe
>> a compatibility issue (i was mixing technologies for my testings),
>> anyway i removed it and it started to work again (now i'm testing with
>> plain jsf). But i found another problem.
>>
>> When i submit the form (using f:ajax), my action add a faces message
>> and populates a list, i used the render="@all" attribute, so i
>> expected that after the method invocation my list and my message get
>> rendered with their new values, but that's not what happened, not with
>> my custom component rendered in the form at least, because if i
>> comment it all the stuff start to work again. Another strange thing,
>> my faces message is being duplicated (but i think that it probably my
>> fault).
>>
>> Anyway, here it's the code. (Tomcat 6.0.18 / Nightly Build (yesterday
>> 01/04))
>>
>> ---------------------------------------------------------------------------------------------------------
>>
>> Main Page
>> ---------------------------------------------------------------------------------------------------------
>>
>>
>> >> xmlns:f="http://java.sun.com/jsf/core"
>> xmlns:h="http://java.sun.com/jsf/html"
>> xmlns:ui="http://java.sun.com/jsf/facelets"
>> template="/templates/template.xhtml"
>> xmlns:my="http://java.sun.com/jsf/composite/componentes">
>>
>>
>> Nome:
>>
>>

>>
>>

>> Idade:
>>
>>

>>

>>
>>
>>
>>

>>
>>
>> >> showSummary="true"/>
>>
>>
>>
>>
>> Nome
>>

>> #{item.nome}
>>

>>
>>
>> Idade
>>

>> #{item.idade}
>>

>>
>>
>> Cidade
>>

>> #{item.cidade.nome}
>>

>>
>>
>> Funcao
>>

>>
>>
>>
>>
>>

>>

>>

>>

>>
>>
>> ---------------------------------------------------------------------------------------------------------
>>
>> Backing Bean Code
>> ---------------------------------------------------------------------------------------------------------
>>
>> @SuppressWarnings("serial")
>> @ManagedBean(name = "crudTeste")
>> @ViewScoped
>> public class CRUDTeste implements Serializable {
>>
>> private Pessoa pessoa;
>>
>> private List lista;
>>
>> @PostConstruct
>> public void construct() {
>> lista = new ArrayList();
>> pessoa = new Pessoa();
>> }
>>
>> public void salvar(){
>> lista.add(pessoa);
>> pessoa = new Pessoa();
>> FacesContext.getCurrentInstance().addMessage(null, new
>> FacesMessage("Pessoa salva com sucesso!"));
>> }
>>
>> public void excluir(){
>> String nome = FacesUtil.getParameter("item").toString();
>> for(Pessoa p : lista){
>> if(p.getNome().equals(nome)){
>> lista.remove(p);
>> }
>> }
>> FacesContext.getCurrentInstance().addMessage(null, new
>> FacesMessage("Pessoa removida com sucesso!"));
>> }
>>
>> public void setPessoa(Pessoa pessoa) {
>> this.pessoa = pessoa;
>> }
>>
>> public Pessoa getPessoa() {
>> return pessoa;
>> }
>>
>> public void setLista(List lista) {
>> this.lista = lista;
>> }
>>
>> public List getLista() {
>> return lista;
>> }
>>
>> /*
>> * No JSF2 os SelectItens podem apontar diretamente para objetos.
>> */
>> public List getCidades(){
>> List lista = new ArrayList();
>>
>> Cidade c = new Cidade("Tubarao");
>> lista.add(c);
>>
>> c = new Cidade("Criciuma");
>> lista.add(c);
>>
>> c = new Cidade("Ararangua");
>> lista.add(c);
>>
>> return lista;
>> }
>>
>> }
>> ---------------------------------------------------------------------------------------------------------
>>
>> Component Code
>> ---------------------------------------------------------------------------------------------------------
>>
>> >> xmlns:h="http://java.sun.com/jsf/html"
>> xmlns:ui="http://java.sun.com/jsf/facelets"
>> xmlns:composite="http://java.sun.com/jsf/composite">
>>
>>
>>
>>

>>
>>
>>

>> >> onkeypress="return isNumberKey(event)"/>
>>
>>
>>
>> ---------------------------------------------------------------------------------------------------------
>>
>> And sorry about the text formatting, the forum broke it. I putted the
>> lines do make it easier to copy and paste it to an editor.
>> [Message sent by forum member 'israelbgf' (israelbgf)]
>>
>> http://forums.java.net/jive/thread.jspa?messageID=340253
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
>> For additional commands, e-mail: webtier-help@glassfish.dev.java.net
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: webtier-help@glassfish.dev.java.net
>

---------------------------------------------------------------------
To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: webtier-help@glassfish.dev.java.net