I am using MyFaces 1.0.8 for my page and the rendered
attribute for the commandButton seems to work just
fine.

Here is my commandButton on the JSP:

<h:commandButton id="addButton"
action="#{taskBean.addTaskButton}" 
rendered="#{taskBean.rendered}" value="Add"/>

Here are the managed bean methods:

public boolean isRendered() {
        return true;
}

public String addTaskButton() {
        TaskBO taskBo = TaskBO.getInstance();
        try {
                // do nothing for this example
        } catch (Exception e) {
                logger.error(e.getMessage(), e);
                return "internalError";
        }
        ApplicationUtils.setUserMessageByResourceKey(
                "com.javawebapps.todolist.infomsg.addSuccess");
        task = null;
        return "taskNew";
}

The addTaskButton method gets called every time that I
press the button.  One thing though, I have client
side state saving and the bean has session scope.

I know this didn't answer your question but maybe this
will help.

--- CupertinoIndian <[EMAIL PROTECTED]> wrote:
> 
> Allright, I found the source of the problem. I also
> have a web project (wsad
> project) where I can reproduce this easily. 
> 
> Anyway here is the problem. I have a JSP called
> dummy.jsp which is as follows:
>
------------------------------------------------------------------------
> <%@ page contentType="text/html" %>
> 
> <%@ taglib uri="http://java.sun.com/jsf/html";
> prefix="h" %>
> <%@ taglib uri="http://java.sun.com/jsf/core";
> prefix="f" %>
> 
> <HTML>
> 
> <BODY>
> <f:view>
>       <h:form>
>               <!-- jsp:include page="header.jsp" / -->
> 
>               <h:panelGrid columns="2">
> 
>                       <h:outputText value="Process" />
>                       <h:outputText
> value="#{clientTaskHandler.clientTask.process}" />
>                       <h:outputText value="Name" />
>                       <h:outputText
> value="#{clientTaskHandler.clientTask.name}" />
>                       <h:outputText value="Id" />
>                       <h:outputText
> value="#{clientTaskHandler.clientTask.id}"
> />
>               </h:panelGrid>
> 
>       <h:commandButton id="nextButton" value="Next"
> action="#{clientTaskHandler.navNext}" 
> rendered="#{clientTaskHandler.renderNext}" />
> 
>       </h:form>
>       </table>
> </f:view>
> </body>
> </html>
>
------------------------------------------------------------------------
> 
> Very simple JSP right? Now focus on the command
> button. The problem is in the
> clause 
> rendered="#{clientTaskHandler.renderNext}"
> The button is rendered correctly as
> clientTaskHandler.isRenderNext() returns
> true. So far so good? Now if I click the button, the
> action
> clientTaskHandler.navNext() is NEVER CALLED. The JSP
> is displayed again with
> null values.
> 
> I tried to change 
> rendered="#{clientTaskHandler.renderNext}"
> to
> rendered="true"
> and guess what? Everything works fine!!
> 
> So basically if the rendered value is pulled from an
> expression, the rendering
> is improper and clicking the button does not invoke
> the specified action.
> However if rendered value is statically specified on
> the page, everything works
> fine.
> 
> If you need the war file, I can easily export one
> for you.
> 
> Thanks for help.
> 
> 
> 


                
__________________________________ 
Do you Yahoo!? 
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/ 

Reply via email to