users@glassfish.java.net

Re: commandButton problem

From: Franck Quinard <franck.quinard_at_gmail.com>
Date: Sat, 11 Mar 2006 07:38:14 +0100

Ryan,

I just change my faces-config.xml as follow.
<managed-bean-scope>session</managed-bean-scope>
But it doesn't change anything.
I change the selection to green, I click the button and the selectOneMenu is
disabled.
I click the button again and the selectOneMenu is still disabled, but the
selected item is reseted to red.

Thanks,

Franck

On 3/10/06, Ryan Lubke <Ryan.Lubke_at_sun.com> wrote:
>
> Franck,
>
> I failed to mention in my repro, I have the managed bean in session scope.
> Looking at your web application, you have it in request scope. Since this
> state needs to persist across requests, you'll want to put your bean in
> session scope as well.
>
> -rl
>
> Franck Quinard wrote:
> > Hello Bryan,
> >
> > I just did a very small exemple base on what you sent me and tried it
> > on b40. It's still doesn't work. Please find the all project in a tar.
> >
> > the TestBean.java is as follow
> >
> > package com.magilis.jsf.test;
> >
> > import javax.faces.event.AbortProcessingException;
> > import javax.faces.event.ActionEvent;
> >
> > public class TestBean {
> >
> > private boolean disabled;
> > private String color;
> >
> > public void toggle(ActionEvent actionEvent) throws
> > AbortProcessingException {
> > disabled = !disabled;
> > }
> >
> > public String getColor() {
> > return color;
> > }
> >
> > public void setColor(String color) {
> > this.color = color;
> > }
> >
> > public boolean isColorSupported() {
> > return disabled;
> > }
> > }
> >
> > and the jsp is :
> >
> > <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
> > <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
> > <f:view>
> > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> > <HTML><BODY><CENTER>
> > <h:form>
> > <h:selectOneMenu value="#{testBean.color}"
> > disabled="#{testBean.colorSupported}">
> > <f:selectItem itemValue="red" itemLabel="red"/>
> > <f:selectItem itemValue="green" itemLabel="green"/>
> > <f:selectItem itemValue="blue" itemLabel="blue"/>
> > </h:selectOneMenu>
> > <h:commandButton value="Click Me"
> > actionListener="#{testBean.toggle}"
> > immediate="true"/>
> > </h:form>
> > </CENTER></BODY></HTML>
> > </f:view>
> >
> > Thank you for your help
> >
> > Franck
> >
> >
> > On 3/9/06, *Ryan Lubke* <Ryan.Lubke_at_sun.com
> > <mailto:Ryan.Lubke_at_sun.com>> wrote:
> >
> > Franck Quinard wrote:
> > > Ryan,
> > >
> > > I just did your test and the result is the same. The first click
> > > works, the second doesn't.
> > > I remember that it was working in previous version, around b29 I
> > > believe. I working with the b39 now.
> > Hi Franck,
> >
> > I just tried my sample on GlassFsih b39 with the expected results.
> > Could you please send me
> > your web application that demonstrates the issue for you on build
> 39?
> >
> > Thanks,
> >
> > -rl
> > >
> > > Thanks,
> > >
> > > Franck
> > >
> > > On 3/7/06, *Ryan Lubke* <Ryan.Lubke_at_sun.com
> > <mailto:Ryan.Lubke_at_sun.com>
> > > <mailto: Ryan.Lubke_at_sun.com <mailto:Ryan.Lubke_at_sun.com>>> wrote:
> > >
> > > Franck Quinard wrote:
> > > > Hello,
> > > >
> > > > I have a problem with the behavior of the commandButton. I
> > want
> > > it to
> > > > disable the comboBox when I click ones on it and I want it
> > to enable
> > > > the comboBox when click on it again. The first part is
> working
> > > but the
> > > > second doesn't.
> > > >
> > > > Here is the code
> > > >
> > > > <h:selectOneMenu value="#{resumeBean.bgColor}"
> > >
> >
> > disabled="#{!resumeBean.colorSupported}">
> > >
> > > > <f:selectItems
> > > value="#{resumeBean.availableColors}"/>
> > > > </h:selectOneMenu>
> > > >
> > > > <h:commandButton value="#{resumeBean.colorSupportLabel }"
> > > >
> > > > actionListener="#{ resumeBean.toggleColorSupport}"
> > > > immediate="true"/>
> > > >
> > > >
> > > > in the bean.
> > > >
> > > > public void toggleColorSupport(ActionEvent event) {
> > > > isColorSupported = !isColorSupported;
> > > > }
> > > >
> > > >
> > > > public boolean isColorSupported() {
> > > > return (isColorSupported);
> > > > }
> > > >
> > > > any idea why the second click on the button doesn't get
> > trigger the
> > > > listener of the selectOneMenu?Thank you
> > > >
> > > > Franck
> > > Franck,
> > >
> > > I've tried a similar test locally and don't see a problem.
> > > Here is what I have:
> > >
> > > -----------------------------------------
> CommandButtonTest.jsp
> > > ------------------------------------
> > > <f:view>
> > > <h:form>
> > > <h:selectOneMenu value="#{test.color}"
> > > disabled="#{test.colorSupported
> }">
> > > <f:selectItem itemValue="red"
> itemLabel="red"/>
> > > <f:selectItem itemValue="green"
> > itemLabel="green"/>
> > > <f:selectItem itemValue="blue"
> > itemLabel="blue"/>
> > > </h:selectOneMenu>
> > > <h:commandButton value="Click Me"
> > > actionListener="#{test.toggle}"
> > > immediate="true"/>
> > > </h:form>
> > > </f:view>
> > >
> >
> --------------------------------------------------------------------------------------------------------------
> > >
> > > ------------------------------------------------ test bean
> > > -------------------------------------------------
> > > public void toggle(ActionEvent actionEvent) throws
> > > AbortProcessingException{
> > > disabled = !disabled;
> > > }
> > >
> > > public String getColor() {
> > > return color;
> > > }
> > >
> > > public void setColor(String color) {
> > > this.color = color;
> > > }
> > >
> > > public boolean isColorSupported() {
> > > return disabled;
> > > }
> > >
> >
> --------------------------------------------------------------------------------------------------------------
> >
> > >
> > >
> > >
> > >
> >
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail:
> > users-unsubscribe_at_glassfish.dev.java.net
> > <mailto:users-unsubscribe_at_glassfish.dev.java.net>
> > > <mailto:users-unsubscribe_at_glassfish.dev.java.net
> > <mailto:users-unsubscribe_at_glassfish.dev.java.net>>
> > > For additional commands, e-mail:
> > users-help_at_glassfish.dev.java.net
> > <mailto:users-help_at_glassfish.dev.java.net>
> > > <mailto:users-help_at_glassfish.dev.java.net
> > <mailto:users-help_at_glassfish.dev.java.net>>
> > >
> > >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> > <mailto:users-unsubscribe_at_glassfish.dev.java.net>
> > For additional commands, e-mail: users-help_at_glassfish.dev.java.net
> > <mailto:users-help_at_glassfish.dev.java.net>
> >
> >
> > ------------------------------------------------------------------------
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> > For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>