DataTable rendered attribute

I can't for the life of me figure out why once I include the rendered attribute my backing bean method gets call so many times .
view
<h:form>
     <h:commandButton action="#{contactController.addContact}">Add Contact</h:commandButton>
     <h:dataTable value="#{contactController.contacts}" var="contact" rendered="#{not empty contactController.contacts}">
     <h:column>
     <h:outputText value="#{contact.name}"/>
     </h:column>                         
     </h:dataTable>
</h:form>
bean
public class ContactController {
     private static List<Contact> contacts = new ArrayList<Contact>();
     public Object addContact() {
          System.out.println("in add contact ...");
          contacts.add(new Contact());
          return null;
     public List<Contact> getContacts() {
          System.out.println("in get contacts ...");
          return contacts;
The backing bean is in the request scope. If I press add contact I get the server output
in get contacts ...
in get contacts ...
in get contacts ...
in add contact ...
in get contacts ...
in get contacts ...
in get contacts ...
in get contacts ...
in get contacts ...
in get contacts ...
in get contacts ...
in get contacts ...
. If I remove the rendered attribute, the message "in get contacts" only appears twice as expected.
Thanks
-Serge-

This is speculation, but I imagine that each child of the dataTable component is trying to determine its rendered status by querying up the tree, resulting in the rendered property of the dataTable being resolved multiple times.
In general you should be aware that the results of an EL expression for a property on a component is not cached by the JSF implementation. You should also be aware that the property may need to be resolved multiple times over the lifetime of a component. If the result should be cached, you need to do the caching in your getter.

Similar Messages

  • CommandButton's rendered attribute doesn't work inside dataTable

    Hi,
    I don't know if anyone could help me...
    I need to access a list of "alarms" in my jsp file (which is rendered by "alarmHandler.sortedGenericDataModel"). For each "alarm" of the list, I test the "alarm.alarmStatus" and I want to create the desired button depending on the it. I'm trying to use the "rendered" attribute to manage the fact the button will be created or not. Note that when I use the "disabled" attribute, everything works fine, but I don't want to use the disabling option, I prefer to don't show the button at all.
    I have a NullPointerException when I run this code (the stack trace of this exception is show at the buttom of this message):
    <h:dataTable value="#{alarmHandler.sortedGenericDataModel}" var="alarm"
    rows="#{alarmHandler.noOfRows}"
    first="#{alarmHandler.firstRowIndex}"
    styleClass="tablebg" rowClasses="oddRow, evenRow"
    columnClasses="left, left, left, right, left" width="100%">
         <h:column>
    <f:facet name="header">
    <h:outputText value="#{labels['alarm.label.action']}" />
    </f:facet>
              <h:commandButton value="#{labels['alarm.label.toActivate']}"
              rendered="#{alarm.alarmStatus != '3'}"
              action="#{alarmHandler.activate}" immediate="true" />
              <h:commandButton value="#{labels['alarm.label.toAcknowledge']}"
              disabled="#{alarm.alarmStatus != '1'}"
              action="#{alarmHandler.acknowledge}" immediate="true" />
              <h:commandButton value="#{labels['alarm.label.toClose']}"
                   disabled="#{alarm.alarmStatus != '2'}"
                   action="#{alarmHandler.close}" immediate="true" />          
    </h:column>
    </h:dataTable>
    *** Here is the stack trace of the error:
    2004-08-30 11:33:13,902 13307343 ERROR [org.jboss.web.localhost.Engine] (http-0.0.0.0-8643-Processor5:) ApplicationDispatcher[abox] Servlet.service() for servlet jsp threw exception
    javax.faces.el.EvaluationException: java.lang.NullPointerException
         at com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:206)
         at com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:154)
         at javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java:307)
         at javax.faces.webapp.UIComponentTag.isSuppressed(UIComponentTag.java:838)
         at javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:470)
         at com.sun.faces.taglib.html_basic.CommandButtonTag.doStartTag(CommandButtonTag.java:469)
         at org.apache.jsp.JSP.alarm.viewAlarmsTemplate_jsp._jspx_meth_h_commandButton_0(viewAlarmsTemplate_jsp.java:588)
         at org.apache.jsp.JSP.alarm.viewAlarmsTemplate_jsp._jspx_meth_h_column_1(viewAlarmsTemplate_jsp.java:505)
         at org.apache.jsp.JSP.alarm.viewAlarmsTemplate_jsp._jspx_meth_h_dataTable_1(viewAlarmsTemplate_jsp.java:445)
         at org.apache.jsp.JSP.alarm.viewAlarmsTemplate_jsp._jspx_meth_h_form_0(viewAlarmsTemplate_jsp.java:202)
         at org.apache.jsp.JSP.alarm.viewAlarmsTemplate_jsp._jspService(viewAlarmsTemplate_jsp.java:125)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
         at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:703)
         at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:589)
         at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:499)
         at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:966)
         at org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:581)
         at org.apache.struts.tiles.TilesUtilImpl.doInclude(TilesUtilImpl.java:137)
         at org.apache.struts.tiles.TilesUtil.doInclude(TilesUtil.java:177)
         at org.apache.struts.taglib.tiles.InsertTag.doInclude(InsertTag.java:756)
         at org.apache.struts.taglib.tiles.InsertTag$InsertHandler.doEndTag(InsertTag.java:881)
         at org.apache.struts.taglib.tiles.InsertTag.doEndTag(InsertTag.java:473)
         at org.apache.jsp.JSP.generic.template_jsp._jspx_meth_tiles_insert_3(template_jsp.java:382)
         at org.apache.jsp.JSP.generic.template_jsp._jspx_meth_f_subview_3(template_jsp.java:346)
         at org.apache.jsp.JSP.generic.template_jsp._jspx_meth_f_view_0(template_jsp.java:146)
         at org.apache.jsp.JSP.generic.template_jsp._jspService(template_jsp.java:80)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
         at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:703)
         at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:589)
         at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:499)
         at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:966)
         at org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:581)
         at org.apache.struts.tiles.TilesUtilImpl.doInclude(TilesUtilImpl.java:137)
         at org.apache.struts.tiles.TilesUtil.doInclude(TilesUtil.java:177)
         at org.apache.struts.taglib.tiles.InsertTag.doInclude(InsertTag.java:756)
         at org.apache.struts.taglib.tiles.InsertTag$InsertHandler.doEndTag(InsertTag.java:881)
         at org.apache.struts.taglib.tiles.InsertTag.doEndTag(InsertTag.java:473)
         at org.apache.jsp.JSP.alarm.viewAlarmsLayout_jsp._jspx_meth_tiles_insert_0(viewAlarmsLayout_jsp.java:100)
         at org.apache.jsp.JSP.alarm.viewAlarmsLayout_jsp._jspService(viewAlarmsLayout_jsp.java:74)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
         at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:703)
         at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
         at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
         at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:312)
         at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
         at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:147)
         at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
         at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
         at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
         at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:703)
         at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
         at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
         at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:312)
         at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
         at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:147)
         at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
         at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
         at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
         at org.apache.struts.faces.application.FacesTilesRequestProcessor.doForward(FacesTilesRequestProcessor.java:144)
         at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
         at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:320)
         at org.apache.struts.faces.application.FacesTilesRequestProcessor.processForwardConfig(FacesTilesRequestProcessor.java:260)
         at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
         at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
         at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
         at com.thevco.abox.web.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:166)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
         at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
         at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:72)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
         at org.jboss.web.tomcat.security.JBossSecurityMgrRealm.invoke(JBossSecurityMgrRealm.java:275)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
         at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
         at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
         at java.lang.Thread.run(Thread.java:595)
    Caused by: java.lang.NullPointerException
         at org.apache.struts.faces.application.PropertyResolverImpl.getValue(PropertyResolverImpl.java:146)
         at com.sun.faces.el.impl.ArraySuffix.evaluate(ArraySuffix.java:167)
         at com.sun.faces.el.impl.ComplexValue.evaluate(ComplexValue.java:151)
         at com.sun.faces.el.impl.BinaryOperatorExpression.evaluate(BinaryOperatorExpression.java:165)
         at com.sun.faces.el.impl.ExpressionEvaluatorImpl.evaluate(ExpressionEvaluatorImpl.java:243)
         at com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:173)

    mleblanc77:
    Thanks for your interest.
    I've modified one of our internal demos to try to reproduce your problem
    and cannot do so. Here is the operative JSP:
    <!-- ... -->
    <h:dataTable binding="#{UIDataBean.data}"
    value="#{list}"
    var="customer">
    <h:column>
         <h:commandButton id="press"
                   action="#{UIDataBean.press}"
                   rendered="#{customer.accountId != '123456'}"
                   immediate="true"
                   value="#{UIDataBean.pressLabel}"
                   type="SUBMIT"/>
    </h:column>
    </h:dataTable>
    <!-- ... -->
    Here's the customer bean
    public class CustomerBean implements Serializable {
    public CustomerBean() {
    this(null, null, null, 0.0);
    public CustomerBean(String accountId, String name,
    String symbol, double totalSales) {
    System.out.println("Created CustomerBean");
    this.accountId = accountId;
    this.name = name;
    this.symbol = symbol;
    this.totalSales = totalSales;
    private String accountId = null;
    public String getAccountId() {
    return (this.accountId);
    This seems to work fine. Can you try the latest weekly build from
    https://javaserverfaces.dev.java.net/servlets/ProjectDocumentList
    Thanks,
    Ed (JSF Co-spec lead)

  • Rendered attribute of commandButton preventing action method from executing

    When I add a rendered tag to my commandButton it'll only execute the method intermittantly. After a lot of testing, I've narrowed down the problem so I now know when it does and does not work properly.
    If rendered="true" it always works fine
    If rendered="#{issue.update}" and isUpdate() is simply "return true;" it'll always work correctly
    If rendered="#{issue.update}" and isUpdate() is simply "return this.getId() != 0;" it will not execute the action specifiied, however the page does refresh.
    It's also interesting to note that on the rendered page, the button is always shown only when it should be. So when the action fails to execute, the button is shown on the screen.
    In the case that doesn't work, I debugged through and noticed that isUpdate() is called six times for a single page refresh. By printing a stacktrace for each call, I discovered that it's called once in the ApplyRequestValues stage of the lifecycle and the other five times are from RenderResponse (I have the stacktraces, let me know if they'd be worth posting). This method is only referenced once and only on the jsf page, never in the java code... but I'll go back and try to understand why it's calling it so many times later.
    The first time isUpdate() is called, it will retrun false because the value for id has not yet been assigned, which makes sense. This causes a "false" to be returned from isUpdate() and this is what is causing the action to not be executed. If I debug through and change the return value to be true here (only the first time) the action is updated. So my question is, what's going on here? I don't understand why is isUpdate() called so many times, why is it called so early in the lifecycle, and why the call in the apply request values stage determines whether or not it executes the action?
    Now, as a workaround, I put a binding on the id, and tried to use that value. That exposed another problem with my page which requires some explanation... Here are the relevent sections of the page and backing bean...
    issue.jsp
    <h:outputText value="#{issue.init}" />
    there's a datatable here which displays all issues and has a commandLink to edit the issues (immediate="true"). It posts back to this page and passes an ID on the URL.
    <h:inputHidden id="id" value="#{issue.id}" binding="#{issue.idBinding}" />
    <h:inputText id="name" value="#{issue.name}" required="true" />
    <h:commandButton id="updateIssue" value="Update" action="#{issue.updateIssue}" rendered="#{issue.update}" />
    Issue.java
    getInit() will get the id from the FacesContext (specifically, the URL) and load the data from the database.
    On the rendered page in my web browser:
    After clicking on an edit link, the page is loaded and the name is filled in, the update button is on the screen, and everything looks good.
    When I view source, I see that the hidden input for id is set to zero. I'm still trying to figure out why this is the case since all the other parameters are set properly. I stepped through getInit() and it is, indeed setting the id property properly.
    So when I added the binding to get the value from there instead of via the local values, I found that it always got zero (presumedly because that's what is rendered in the HTML code). This means that isUpdate() still returns false on the first call, and my attempt at a workaround fails! So, just as a test, I used some "javascript on the URL" trickory to set the id field to "10". That worked just fine. So the root of the problem is that issue.id is not loading. I put code in the getId() method to always look at the binding and then faces context and put the id into this.id if it found a non-null and non-zero value. It now returns the correct value all of the time but the HTML produced still says the value is zero.
    I've spent about 4 hours on this issue and I'm to the point where I need advice from someone who is more educated on how JSF works. I know the inputHidden get the vaule for the HTML tag it produces from getId() because when I hard code that to always return 10, it works. But when I leave it to return the proper value, the debug statements say it's returning the proper value, but the HTML always says it's zero. This isn't an acceptable solution anyway because I use getId() in the datatable to display the IDs of each of the issues; I just wanted to see if it'd work and it didn't.
    Here's my latest getInit() method (which returns the value from the URL when called from the datatable, but not when called from the inputHidden.
        public int getId() {
            if(getIdBinding() != null && !getIdBinding().isLocalValueSet()) {
                if(getIdBinding().getSubmittedValue() != null) {
                    int temp = Integer.parseInt((String)getIdBinding().getSubmittedValue());
                    if(temp != 0) {
                        this.id = temp;
                        log.info("Got binding value of "+this.id);
            FacesContext ctx = FacesContext.getCurrentInstance();
            if(ctx != null) {
                Map<String, String> map = ctx.getExternalContext().getRequestParameterMap();
                    if(map != null) {
                    String given_id = map.get("id");
                    if(given_id != null) {
                        // if given an ID and no action, we load the data
                        try {
                            log.info("Got value from FacesContext of "+given_id);
                            int temp = Integer.parseInt(given_id);
                            if(temp != 0)
                                this.id = temp;
                        } catch(NumberFormatException e) {
                            // if what's passed in isn't an integer, we leave everything at default values
            return this.id;
        }Thanks in advance,
    Adam

    I'm clicking a link which will load data into a form. In the form there is a field called "id" which has a value of something other than zero. I press the update button (which is only rendered when the id is non-zero), it submits the form. When the restore view happens, the id is the default value of 0 because it has not yet applied the values from the form to the backing bean. Therefore the rendered attribute of update button (isUpdate()) will return false, and the update() method does not get queued.
    When I switch my backing bean to session level, the restore view already has the id loaded, even before the values from the form are applied, so everything works as expected. The problem was that I needed to have the correct return values before any values have been loaded into the member variables.
    As a solution to this, I made some private boolean variables called isNew and isUpdate. Both of them are true by default. This makes sure that the isNew() and isUpdate() methods (attached to the render attribute of my command buttons) return true in the restore view phase. When I read in the id from the URL or hidden input, it'll update the boolean values accordingly, which makes sure the buttons are rendered properly. This allowed me to set the backing bean back to the request scope, which make me happy. <img class="emoticon" src="images/emoticons/grin.gif" border="0" alt="" />
    Thank you Mr. De Campo. You gave me exactly what I was looking for... a better understanding of how thigns work, and (indirectly) a clean solution to my problem.

  • Custom tag with rendered attribute

    Is it possible to create a custom tag that operates similar to a JSF tag with the rendered attribute? Wrapping output with c:if test="..." is not as nice as the JSF rendered option, but I don't want to use JSF for this particular project.
    Edited by: black_lotus on Nov 23, 2007 12:13 PM

    TLD File, per your previous recommendation:
    <attribute>
         <name>disabled</name>
         <required>false</required>
         <rtexprvalue>true</rtexprvalue>
         <type>boolean</type>
    </attribute>My Tag class (snippet):
    public class ButtonTag extends TagSupport
      private boolean disabled;
      public ButtonTag() {}
      public boolean isDisabled()
         return disabled;
      public void setDisabled(boolean b)
        disabled = b;
    }A sample of the jsp file invoking it:
    <c:set var="result" value="${computedValue}"/>
    <ltm:button disabled="${result}"/>Regardless of the value of result, ("true" or "false") it always passes false to the setDisabled method of the button tag class.

  • Possible bug when rendered attribute set with EL

    I have the following outer panelform:
    <af:panelForm rendered="#{RoleSearch.roleSelected == RoleSearch.SUPERVISOR}">
    within this panelform i have a table and a selectone commandbutton,
    <af:commandButton text="Edit"
    action="#{RoleSearch.editDetails}">
    <af:setActionListener from="#{row.Userid}"
    to="#{processScope.userIdSelected}"/>
    </af:commandButton>
    don't worry about the parameter my action listener is settting.
    the problem is, when the commandbutton is encapsulated with an outer rendered component, it does not function, it does not trigger the action. if i manually set the rendered attribute to "true" things work fine.
    The components are displayed correctly, i.e. rendered correctly depending on my holder, however the commandbutton won't fire off the action when it is used like this.
    has anyone faced this problem before? is this a known issue?
    any help is much appreciated, i have had to write a few workarounds to resolve similar issues i have run into when developing with ADF BCs.
    thanks.

    Hi,
    i can't see any obvious problems with what you are doing especially considering that it works ok if you manually set the rendered attribute of the panelForm to true.
    Have you tried setting the rendered attribute at the command button level and leaving the panelForm rendered?
    Brenden

  • Problem with rendered attribute in jhs 10.1.3.3

    We are currently trying to migrate our applications from jhs 10.1.3.2.52 to jhs 10.1.3.3.87 using jdeveloper 10.1.3.5. We are facing a problem with all the detail groups structured inside detail group regions - they have all disappear from the pages.
    In my example code i have two master-detail groups Products (Master) and ExpertiseAreas (Detail) on the same page:
    Products - Group
    -> ExpertiseAreasDtl - Detail Group Region
         -> ExpertiseAreas - Group (Samepage="true")
    The problem is that the detail group ExpertiseAreas is not rendered on the page.
    As i looked in through the pages generated by the 2 different releases of jhs using the same app definition, i can see the following:
    CODE GENERATED FOR THE ExpertiseAreasDtl Detail Group Region (all the vms used are the default):
    in jhs10.1.3.3.87:
    <af:panelGroup *rendered="#{(ProductsIterator.currentRow!=null and ProductsIterator.findMode!='true')}"* id="ProductsRegionsExpertiseAreasDtlPanelGroup">
    in *jhs 10.1.3.2. 52*:
    <af:panelGroup id="ProductsRegionsExpertiseAreasDtlPanelGroup">
    First of all a rendered attribute is being generated in the new version of jhs and not in the old.
    The real problem seems to be with the iterator binding generated from verticalRegionContainer.vm in the regular expression: "#{(ProductsIterator.currentRow!=null and ProductsIterator.findMode!='true')}". It should have been *bindings.*ProductsIterator and not plain ProductsIterator. Has anybody got any ideas on how to solve the problem?
    Thanks
    Giorgos
    Edited by: user647567 on 17 Δεκ 2009 2:16 πμ
    Edited by: user647567 on 17 Δεκ 2009 5:58 πμ

    Giorgos,
    We have uploaded a new service update, 10.1.3.3.88, on the cso.oracle.com site. This should fix your issue.
    Steven Davelaar,
    JHeadstart Team.

  • Rendered Attribute

    I have a CommandButton with rendered attribute to display it depend of the step in a bussines process.
    The JSF Page have a request scope then all flags need to be recalculate each request (The page is reloaded severla times to complete the process, the actions return null).
    Well, my problem is that when I render the Commandbutton and make click on it the form be submitted but the action never be executed.
    I think the problem is that when the request be processed maybe the flags to render the button be fasle and the actionevent never be queue.
    Anybody have idea ?
    Some suggest to resolve this problems.
    Thank you in advanced.

    loboEsa wrote:
    I have a CommandButton with rendered attribute to display it depend of the step in a bussines process.
    The JSF Page have a request scope then all flags need to be recalculate each request (The page is reloaded severla times to complete the process, the actions return null).
    Well, my problem is that when I render the Commandbutton and make click on it the form be submitted but the action never be executed.
    I think the problem is that when the request be processed maybe the flags to render the button be fasle and the actionevent never be queue.
    This is exactly right. Some options include:
    1) Storing the rendered attribute value in the session instead of the request.
    2) Making the rendered attribute depend on a request parameter which can be added as a hidden input.

  • Problem with rerendering h:panelGrid with rendered attribute

    Hi,
    I am new to jsf and trying to learn its features as I find it easy and fast for development purpose.I have been developing with jsf for past few weeks and got myself stuck with a problem, tired of which I had to take the forum's help :). My problem is that I need to show/hide h:panelGrid using any of the options below:
    I tried putting the grid in the div and show/hide that div using javascript..works fine but the problem with this is, even when the div is hidden the components (h:inputText ) within the grid are submitted with the form, which should not be the case since its hidden (as with normal jsps).
    I worked around with rendered attribute of the grid, and show/hide this grid using the backing bean method which is actually a valueChangeListener of h:selectOneMenu and set the boolean for the rendered to true/false as required, the grid is hide/shown correctly, but this isn't giving me any solution because when I submit the form with this grid shown on the view, its components values are still not submitted :( I dont know whats the reason behind this or what clue am I missing here. I dont know why when the grid is shown correclty, its components values are not submitted.. hence not validated too..
    Any help will be highly appreciable.
    Regards
    srehman

    >
    gimbal2 wrote:
    No, in "normal jsps" you'll get the same thing - even though you
    visibly hide a component, it is still there and thus will still be part
    of a form submit. If you don't want form fields to submit, you'll have
    to make sure they are physically not there, or the fields are disabled.Well thanks alot for correcting me on this mate.
    Don't know either, it should work if you did everything correctly. Are
    you sure the databinding (to a JSF backing bean field) of the grid is
    correct? When you create a similar setup but without any of the
    show/hide logic, does it work then?I guess I have done it correctly but let me tell you, I have no direct binding to the grid itself, instead I have h:inputText fields in the grid that are bound to the backing bean's properties, which I need to submit and validate too. e.g{color:#800000}<h:panelGrid id="myPanel" columns="3" rendered="Bean.renderStatus">
    <h:outputText value="variable"/>
    <h:inputText id="v" value="Bean.property" required="true">
    <a4j:support ......... />
    </h:inputText>
    </h:panelGrid>{color}
    {color:#800000}<rich:message for="v"/>{color}
    Here I am able to hide and show the grid but I am unable to submit the field in any case whether its hidden or shown :( At first the grid is hidden and then on the valueChangeListener of h:selectOneMenu rendered value is set to either true or false.( renderStatus is set in the value change listener ).
    And yeah without this logic of hide/show its working fine with me. Any guess or idea what am I doing wrong here.
    Thanks for your time by the way.
    Regards,
    Shoaib

  • CommandLink doesn't work with rendered-attribute

    Hello,
    I have quite a strange problem.
    I have a commanLink, which has a rendered attribute. The link is rendered conditionally, so the rendered-value comes from a bean.
    <h:commandLink rendered="#{Bean.canEdit}" action="#{Bean.selectDocumentToEdit}" >
               <h:outputText value="Edit doc" />
                              <f:param name="param" value="#{Bean.doc.id}"/>
    </h:commandLink>Showing the link is working like it should, but commandLink is not working with this. When I change rendered="true", commandLink works ok. But now it doesn't call the commandLink action at all.
    Any help would be appreciated

    rendered="true", commandLink works ok. But now it
    doesn't call the commandLink action at all.I meant it doesn't call the commandLink action method when retrieving rendered-value from bean.
    I'm using RI 1.1.01

  • TaskMenu is not rendering properly using rendered attribute withSecurityCxt

    Hi All,
    I am trying to use this code rendered="#{!(securityContext.userInRole['ZPM_ENT_MARKETING_BUDGET_MANAGER_DUTY'])}" in the itemNode UI component of my Budget_taskmenu.xml. But UI is not rendering it properly.
    I have checked the same code in the backing bean and it is returning true and false as per expectation but at UI level my menu is not coming properly (it is coming as #{null} in place of name in menu).
    But same piece of code is working fine in my .jsff file where I am doing the same check in rendered attribute.
    rendered="#{!(securityContext.userInRole['ZPM_ENT_MARKETING_BUDGET_MANAGER_DUTY'])}"
    Any Suggestion.
    Regards,
    Sarvesh Kaushik

    Hi Frank,
    Thanks for your reply.
    But I found the actual root cause of the issue.
    There is nothing wrong in the expression rendered="#{!(securityContext.userInRole['ZPM_ENT_MARKETING_BUDGET_MANAGER_DUTY'])}".
    The actual issue with my code was one label name was wrong bcoz of which menu was not rendering properly.
    Thanks and Regards,
    Sarvesh Kaushik

  • How do I update "Rendered" attribute property from VO in runtime?

    I can override isAttributeUpdateable() in RowImpl for "updateable" attribute property of a VO in runtime.
    Is there API to update "Rendered" attribute property? I need to set it based on some condition or business rule in runtime.
    thanks,

    If you have a work flow there are several ways to do this. If the attribute is global, and can change on all resources, you can set user.global.<attribute> to what ever you want and it will usually propagate out fine. You can also update the attribute specifically on the resource with user.accounts[LDAP].<attribute>.

  • UIX 2.2.8: rendered attribute for onBlurValidater and onSubmitValidater?

    Hi, i want to create onBlurValidater and / or onSubmitValidater in my subclassed ui:dateField based on a new attribute.
    In UIX 2.2.8 there is no rendered attribute on the onXxValidator tags.
    Any idea how i can achive something like
    <ui:dateField>
      <onBlurValidater
           rendered="${uix.rootAttr.validatorType == 'blur'}">
        <date pattern="${uix.rootAttr.formatPattern}"/>
      </onBlurValidater>
      <onSubmitValidater
           rendered="${uix.rootAttr.validatorType == 'submit'}">
        <date pattern="${uix.rootAttr.formatPattern}"/>
      </onSubmitValidater>
    </ui:dateField>Thanks, Markus

    ping

  • Passing parameter in rendered attribute

    Hi,
    Is there a way to pass parameter in "rendered" attribute.
    e.g.
    <af:commandLink action="#{...}"
    rendered="#{myManagedBean.hasAccess('level1')}"/>
    Kindly advice

    Hi,
    you can't use rendered="#{myManagedBean.hasAccess('level1')}" because it's like calling a function which is not working.
    You have to think the other way around. Tow possibilities:
    1. in your bean define a method the returns true or false for exactly the condition you want to check and use it like rendered="#{myManagedBean.hasAccessLevel1}"2. use a HashMap to store all conditions in your bean
    HashMap accessRights = new HashMap();
    accessRights.put('level1', true);
    accessRights.put('level2', false);
    accessRights.put('level4', true);
    accessRights.put('level5', true);
    public HashMap getAccessRightsMap()
    return accessRights;
    }in you Page your access the map like ]rendered="#{myManagedBean.AccessRightsMap['level1']} Timo

  • Update "rendered" attribute via ajax

    Is there a workaround to update the "rendered" attribute of a commandLink via AJAX? I'm getting an error 'malformedXML: During update: j_idt12:prevCmd not found'.
    code snippet:
    <h:commandLink action="#{controller.previous}"
                                       value="Previous"
                                       rendered="#{controller.hasPreviousPage}"
                                       id="prevCmd">
         <f:ajax render="table prevCmd nextCmd" immediate="true"/>
    </h:commandLink>
    <h:commandLink action="#{controller.next}"
                                       value="Next"
                                       rendered="#{controller.hasNextPage}"
                                       id="nextCmd">
         <f:ajax render="table prevCmd nextCmd" immediate="true"/>
    </h:commandLink>

    Try adding the form name to the components names:
    <f:ajax render="form1:table form1:prevCmd form1:nextCmd" immediate="true"/>

  • Rendered attribute and actions

    If a component has rendered set to false, can it still perform an action? In other words, if I have a button which does something which I don't render for unauthenticated users, is there any way they will be able to save the html to disk, and modify the various form elements to perform that unauthorized action?

    @RaymondDeCamo
    I understand that this is true for most languages eg. PHP, however I was wondering if the server would still execute the action if the button that was bound to it had its rendered attribute set to false. It seems like the JSF people would put in that kind of functionality. In other words, are you sure JSF doesn't run the server-side checks itself?
    @BalusC
    I know the person won't be able to click on the button, but could they add in their own custom HTML into the form to perform the action?

Maybe you are looking for