How to Set Property Values on the Client

Using ADF Faces Architecture 3-15

3.7.2 What You May Need to Know About Marshalling Bonus Attributes

Although client-side bonus attributes are automatically delivered from the server to the client, the reverse is not true. That is, changing or setting a bonus attribute on the client will have no effect on the server. Only known nonbonus attributes are synchronized from the client to the server. If you want to send application-defined data back to the server, you should create a custom event. For more information, see Section 5.4, Sending Custom Events from the Client to the Server.

3.8 Understanding Rendering and Visibility

All ADF Faces display components have two attributes that relate to whether or not the component is displayed on the page for the user to see: rendered and visible. The rendered attribute has very strict semantics. When rendered is set to false, there is no way to show a component on the client without a roundtrip to the server. To support dynamically hiding and showing page contents, the RCF adds the visible attribute. When set to false, the components markup is available on the client but the component is not displayed. Therefore calls to the setVisibletrue or setVisiblefalse method will, respectively, show and hide the component within the browser as long as rendered is set to true, whether those calls happen from Java or from JavaScript. Example 3–9 shows two outputText components, only one of which is rendered at a time. The first outputText component is rendered when no value has been entered into the inputText component. The second outputText component is rendered when a value is entered. Example 3–9 Rendered and Not Rendered Components af:panelGroupLayout layout=horizontal af:inputText label=Input some text id=input value={myBean.inputValue} af:commandButton text=Enter af:panelGroupLayout af:panelGroupLayout layout=horizontal af:outputLabel value=You entered: af:outputText value=No text entered id=output1 rendered={myBean.inputValue==null} af:outputText value={myBean.inputValue} rendered={myBean.inputValue =null} af:panelGroupLayout Provided a component is rendered in the client, you can either display or hide the component on the page using the visible property. Performance Tip: You should set the visible attribute to false only when you absolutely need to be able to toggle visibility without a roundtrip to the server, for example in JavaScript. Nonvisible components still go through the component lifecycle, including validation. If you do not need to toggle visibility only on the client, then you should instead set the rendered attribute to false. Making a component not rendered instead of not visible will improve server performance and client response time because the component will not have client-side representation, and will not go through the component lifecycle.