• Post Reply Bookmark Topic Watch Topic
  • New Topic

selectOneMenu problem

 
Joe Jose
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am newbie to jsf. I started a project using jsf. I have to use dropdown list in several web screens. I have been trying to work out since last 2 days. Please anyone help me with this. Please please...

I am giving the code here :

jsp :




Backbean :



faces-config :



I am getting the error :

org.apache.jasper.JasperException: Argument Error: One or more parameters are null.

Please have a look into my code and help me to work out where I have mistaken. Please kindly help me... I am getting the values from database for the dropdown list using hibernate. I am not sure the way I have done is correct.

Thanks,
Joe

[ September 15, 2006: Message edited by: Joe Jose ]
[ September 15, 2006: Message edited by: Joe Jose ]
 
Ayan Afridi
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your problem may be here:


public List getQtTypes()throws ServiceException {

List qtTypes = QuoteTypeFacade.getAllQtTypes();
return qtTypes;
}

When QuoteTypeFacade.getAllQtTypes() creats the list, does it do:

list.add( new SelectItem( stuff ));
or just:
list.add( stuff);

It needs to do the first thing.
 
Joe Jose
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much Ayan for your reply.
No, I haven't done anything with SelectItem, as you said. Actually I don't get how to do with that SelectItem class. Here, what I am trying to do is, pupulate dropdown with the type name and when submits I have to get the corresponding the id of the type. I had done it with struts. But in jsf I am not sure how to get it . Could you please help me. In the list, I am getting typeId,typeName and typeDescription. How can I use SelectItem here ? It will be a great help if you could help me with this.

Thanks,
Joe.
 
Ayan Afridi
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

So you are just adding objects to the List like:

Type typ = getType();
list.add(typ);

What you should do depends on what info you want displayed in the menu:
In the constructor of SelectItem should be a String, or it gets converted to a String.

list.add( new SelectItem( typ.getTypeId() + "-" + typ.TypeName ) );

Basically whatever element of Type you want to be displayed in the menu, construct a SelectItem object with those values passed to the constructor, and add the SelectItem to the list.

Then you can send the list to the selectOneMenu and it should have no problem displaying it.
 
Joe Jose
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ayan. Let me ask one more doubt, that is, I am using a combination of sun jsf 1.1 and tomahawk . Can you please let me know , in that case which selectItem class I need to use ?

Thanks,
Joe.
 
Ayan Afridi
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not sure - I am using javax.faces.model.SelectItem.
 
Joe Jose
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, that will do here as well. Let me do the changes. I will let you know. Very thoughtful of you.
 
Joe Jose
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ayan,
I got it worked with h:selectItems.
I need to check when submit the page the id is get selected.

Thanks,
Joe.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!