Hello,

I'm working on writing my first webapp with JavaServer Faces and I'm using a compiled libraries that I checked out earlier today. I'm having a problem with filling in a bunch of select menu and select boxes dynamically.

Here's the situation. I have a <h:selectOneMenu> element for a person to select a company. When they change the selected company the form is submitted and the next <h:selectOneMenu> is populated with the departments in the company. When the department selected is changed a <h:selectManyListbox> is supposed to be populated with the personnel in that department.

Optimally, in the future, I'll change this to be an ajax interface. But for now, because time is limited, I'm doing it all with regular old page requests (I know, yuck, but you gotta do what you gotta do).

The problem is when the department selection changes, it seems as tho the value for the selected organization is not being carried tho to the backing bean. The proper organization is still selected in the form, but because the department select items are populated with a method in the backing bean that tries to use the beans value for the selected organization the department menu shows up empty but the personnel list box is populated.

The company and department <h:selectOneMenu> elements both use the immediate="true" attribute to bypass any validations and then the event handler doesn't do anything other than take the new value and call setSelectedCompany/setSelectedDepartment and then jump to the rendering phase with FacesContext.getCurrentInstance ().renderResponse (). I'm guessing this completely bypasses setting any of the backing beans values and just carries the form across as is cause all the other form values are also maintained.

So what do I need to do to fix this? One idea is to try and find the value that JSF will use in the form and use that if there is one and then otherwise use the backing beans value when I'm generating the department choices. Seems kind of hacky since that's one of the things that JSF is supposed to do for you is provide the form values. I'm also not certain how to get the values that JSF is going to use in the forms without having it update the model values. Another idea is if I can somehow avoid doing the validation some other way. That's really the only reason I need to do the event processing right away and then skip to the rendering phase. But I've looked and there doesn't seem to be another way of bypassing validation.

Any other ideas?  Suggestions?

Thanks,
Rich

P.S. Is there anyway I can get you guys to start pushing SNAPSHOT builds to the maven repos? I've been getting bitten by the null pointer exception bug when forms with list boxes are submitted but nothing in them is selected. I saw it was fixed in svn so checked out, built and tested that and it worked beautifully. But it would be much easier for me if there was a SNAPSHOT build in the maven repos. Thanks.

Reply via email to