myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeanne Waldman <jeanne.wald...@oracle.com>
Subject Re: [Trinidad] Help with autoSubmit
Date Tue, 16 Feb 2010 18:35:19 GMT
This looks ok to me. Can you try simplifying the test case, like
1. always have the second selectOneChoice enabled
2. try seeing what immediate does
3. Yes, the projectChangeListener should not be needed.
4. get rid of all fields but the not working selectOneChoice. does that 
work?

Jean-Noël Colin wrote, On 2/12/2010 8:08 AM PT:
> Hi
>
> I've been working with JSF & IceFaces, but rather new to MyFaces + Trinidad. And
I'm facing a problem with autoSubmit.
>
> Basically, I have two selectOneChoice elements (project and subproject), and the second
should be disabled until the first one has been selected. In the same form, I also have a
few other fields that are marked as required and need some further validation.
>
> The problem I have is the following: when I select an item in the first selectOneChoice,
the second becomes enabled. So far so good... So I fill in the other fields and click the
'add' button. The problem is that the selected value in the second selectOneChoice (#{entryBean.currentLine.subProjectId})
does not get pushed to the backing bean, while the two others are. I can see that when the
 addAction method is fired; only projectId and activityId return the right value, subprojectid
is always 0. 
>
> The first selectOneChoice is marked as immediate to bypass the validation controls. I
have also attached a valueChangeListener (projectChangeListener) to it so that the value gets
stored in the backing bean (btw, why isn't that done automatically?)
>
> Am I doing something wrong or is this a know issue? I don't think my case is really unusual...
>
> Thanks a lot for your help
>
> Jean-Noël Colin
>
>
>
> 	public String addAction() {
> 		System.out.println("Add action called");
> 		System.out.println(currentLine.getProjectId());
> 		System.out.println(currentLine.getSubProjectId());
> 		System.out.println(currentLine.getActivityId());
> 		return null;
> 	}
>
> 	public void projectChangeListener(ValueChangeEvent event) {
> 		System.out.println("new project: " + event.getOldValue() + ":" + event.getNewValue());
> 		System.out.println(currentLine.getSubProjectId());
> 		currentLine.setProjectId((Long) event.getNewValue());
> 	
>
>
> 	<tr:panelHeader text="Hello world">
> 		<tr:panelGroupLayout>
> 			<tr:chooseDate id="dateChooser"></tr:chooseDate>
> 			<tr:separator />
> 			<tr:panelFormLayout>
> 				<tr:inputDate id="dateField" chooseId="dateChooser" label="Day"
> 					value="#{entryBean.currentLine.lineDate}"></tr:inputDate>
> 				<tr:inputText label="#hours" columns="3" required="true"
> 					showRequired="true" value="#{entryBean.currentLine.lineHours}">
> 				</tr:inputText>
> 				<tr:selectOneChoice id="project" label="project"
> 					value="#{entryBean.currentLine.projectId}" required="true"
> 					showRequired="true" autoSubmit="true" unselectedLabel="Select"
> 					immediate="true"
> 					valueChangeListener="#{entryBean.projectChangeListener}">
> 					<f:selectItems value="#{globalData.activeprojects}" />
> 				</tr:selectOneChoice>
> 				<tr:selectOneChoice id="subproject" label="sub-project"
> 					partialTriggers="project"
> 					value="#{entryBean.currentLine.subProjectId}" required="true"
> 					showRequired="true" unselectedLabel="Select"
> 					disabled="#{entryBean.currentLine.projectId eq 0}">
> 					<f:selectItems value="#{globalData.activeprojects}" />
> 				</tr:selectOneChoice>
> 				<tr:outputText value="#{entryBean.currentLine.projectId}"
> 					partialTriggers="project" />
> 				<tr:selectOneChoice label="activity"
> 					value="#{entryBean.currentLine.activityId}" required="true"
> 					showRequired="true" unselectedLabel="Select">
> 					<f:selectItems value="#{globalData.activities}" />
> 				</tr:selectOneChoice>
> 				<tr:inputText label="Comment" required="true" showRequired="true">
> 				</tr:inputText>
> 				<tr:panelButtonBar halign="center">
> 					<tr:commandButton text="Add" action="#{entryBean.addAction}" />
> 					<tr:resetButton text="Cancel" />
> 				</tr:panelButtonBar>
> 			</tr:panelFormLayout>
> 		</tr:panelGroupLayout>
> 	</tr:panelHeader>
>   

Mime
View raw message