no wonder !!
-----Original Message-----
From: Whitney Hunter [mailto:whitney@hunterfam.com]
Sent: Friday, April 22, 2005 3:59 PM
To: MyFaces Discussion
Subject: Re: selectOneMenu issue
That has no effect other than placing the button next to the menu =
instead of below it. The actionListener is still not called.
Rob Decker wrote:=20
I was just saying there is someone out there who would think how lucky I =
was that my=20
action was called at all.
Try setting columns=3D"2" on the panelGrid.
--
Rob
@objectsource.org
---------- Original Message -----------
From: Whitney Hunter <mailto:whitney@hunterfam.com> =
<whitney@hunterfam.com>
To: MyFaces Discussion <mailto:myfaces-user@incubator.apache.org> =
<myfaces-user@incubator.apache.org>
Sent: Fri, 22 Apr 2005 12:29:33 -0700
Subject: selectOneMenu issue
=20
Hi all,
I am having a difficult time getting <h:selectOneMneu> to workwith a=20
converter. I have a very simple jsp that presents a menu and hasa submit =
button. The problem is that the submit() method on controllerclass is =
never=20
called when the selectOneMenu control is on the page. IfI remove this =
control=20
it works. I am getting the same behavior withmyfaces and the reference=20
implementation so I expect that I am missingsomething. Can anyone point =
me in=20
the right direction?
Thanks a lot,
Whitney
Here is my jsp code:
<f:view>
<h:form>
<h:panelGrid columns=3D"1">
<h:selectOneMenu value=3D"#{controller.modelObject}"
converter=3D"converter">
<f:selectItemsvalue=3D"#{controller.modelObjectSelectItems}" />
</h:selectOneMenu>
<h:commandButton value=3D"submit"
actionListener=3D"#{controller.submit}" />
</h:panelGrid>
</h:form>
</f:view>
RIController.java
private static List modelObjects =3D new ArrayList();
private RIModelObject modelObject;
static {
modelObjects.add(new RIModelObject("one"));
modelObjects.add(new RIModelObject("two"));
modelObjects.add(new RIModelObject("three"));
}
public void submit(ActionEvent event) {
System.out.println("Object: " + modelObject.getValue());
}
public List getModelObjectSelectItems() {
List selectItems =3D new ArrayList();
Iterator iter =3D modelObjects.iterator();
while (iter.hasNext()) {
RIModelObject modelObject =3D (RIModelObject) iter.next();
selectItems
.add(new SelectItem(modelObject,modelObject.getValue()));
}
return selectItems;
}
public RIModelObject getModelObject() {
return modelObject;
}
public void setModelObject(RIModelObject modelObject) {
this.modelObject =3D modelObject;
}
RIConverter.java
public Object getAsObject(FacesContext context, UIComponentcomponent,
String value) throws ConverterException {
if (value =3D=3D null) {
return null;
}
return new RIModelObject(value);
}
public String getAsString(FacesContext context, UIComponentcomponent,
Object value) throws ConverterException {
if (value =3D=3D null) {
return null;
}
if (value instanceof RIModelObject) {
return ((RIModelObject) value).getValue();
} else {
throw new ConverterException("Incorrect type");
}
}
RIModelObject.java
private String value;
public RIModelObject(String value) {
this.value =3D value;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value =3D value;
}
=20
------- End of Original Message -------
=20
|