Question on h:selectOneListbox...
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Melinda_Savoy
Posted On:   Wednesday, August 18, 2010 02:22 PM

I am VERY VERY new to JSF. In my JSF page I have the following dropdown box that is getting populated from a database: I am trying to validate the option selected and my understanding is that this component will show what accountType.acctTypeID value is selected when it is selected in the dropdown. But I am having issues when trying to validate that in my bean code. In my createTransaction() bean I have the following code validation code but in the first line when I try to retrieve the acctTypeID which is populated in my dropdown I am getting a NULL value when stepping through my code in the debugger and consequently when I try to validate t   More>>

I am VERY VERY new to JSF.



In my JSF page I have the following dropdown box that is getting populated from a database:



			










I am trying to validate the option selected and my understanding is that this component will show what accountType.acctTypeID value is selected when it is selected in the dropdown. But I am having issues when trying to validate that in my bean code.



In my createTransaction() bean I have the following code validation code but in the first line when I try to retrieve the acctTypeID which is populated in my dropdown I am getting a NULL value when stepping through my code in the debugger and consequently when I try to validate the option selected in my validation section I get an NPE error:



			


public void createTransaction() {
String acctTypeID = acctType.getAcctTypeID();



// Validation of required fields

FacesContext context = FacesContext.getCurrentInstance();

if (acctTypeID.equalsIgnoreCase("0"))

context.addMessage("fromAccountTypes", new FacesMessage("From Account Type must be selected"));

transactionService.create(transaction);

}





One thing I forgot to mention is that when I do a VIEW SOURCE from the browser the default option selected does NOT show SELECTED in the option. Is that something that JSF does with this component in the background?



Any help/direction would be greatly appreciated as I obviously do not know what I'm doing wrong here. I've searched this forum and googled but cannot make it work. Thanks.    <<Less

Re: Question on h:selectOneListbox...

Posted By:   Anonymous  
Posted On:   Thursday, August 19, 2010 12:44 AM

I am curious to this as well, anyone with an answer please advise. Thanks!
About | Sitemap | Contact