How-To dinamically add an attribute using "c:if" tag?

Hi,
I have a problem with f:attribute tag.
I need to dinamically add an attribute to a h:panelGroup tag according to the value of a ELExpression. For example the fragment below should output an HTML page with two radio controls; depending to the clicked radio, the "foo" section or the "baz" section is showed (this is controlled client-side vie the javascript function called in the onclick event of the "foobaz" component):
<h:selectOneRadio id="foobaz" layout="lineDirection" value="#{myBean.foobazMode}" onclick="showHideFooBaz(this);">
  <f:selectItem itemValue="#{myBean.fooMode}" itemLabel="Show Foo"/>
  <f:selectItem itemValue="#{myBean.bazMode}" itemLabel="Show Baz"/>
</h:selectOneRadio>
<h:panelGroup id="foo">
  <c:if test="#{myBean.bazVisibile}">
    <f:attribute name="style" value="display: none"/>
  </c:if>
</h:panelGroup>
<h:panelGroup id="baz">
  <c:if test="#{myBean.fooVisibile}">
    <f:attribute name="style" value="display: none"/>
  </c:if>
</h:panelGroup>Well, the problem is this not work.
So my idea was to develop a new AttributeTag with a JSP body content in order to write:
<h:panelGroup id="foo">
  <my:attribute name="style">
    <c:choose>
      <c:when test="#{myBean.fooVisibile}">
        <f:verbatim>display: block</f:verbatim>
      </c:when>
      <c:otherwise>
        <f:verbatim>display: none</f:verbatim>
      </c:otherwise>
    </c:choose>
  </my:attribute>
</h:panelGroup>
...but don't work too.
Starting from the SUN JSF-RI AttributeTag, I developed my version extending from BodyTagSupport class instead of TagSupport one.
public class AttributeTag extends BodyTagSupport
    public int doStartTag() throws JspException {
        return (EVAL_BODY_INCLUDE);
    public int doEndTag() throws JspException {
       // Locate our parent UIComponentTagBase
        UIComponentClassicTagBase tag = UIComponentELTag.getParentUIComponentClassicTagBase(pageContext);
        if (tag == null) {
                throw new JspException("com.sun.faces.NOT_NESTED_IN_UICOMPONENT_TAG_ERRO");
        // Add this attribute if it is not already defined
        UIComponent component = tag.getComponentInstance();
        if (component == null) {
                throw new JspException("com.sun.faces.NO_COMPONENT_ASSOCIATED_WITH_UICOMPONENT_TAG");
        FacesContext context = FacesContext.getCurrentInstance();
        ELContext elContext = context.getELContext();
        String nameVal = null;
        Object valueVal = null;
        boolean isLiteral = false;
        int result = EVAL_PAGE;
        if (name != null) {
            nameVal = (String) name.getValue(elContext);
        if (value != null) {
            if (isLiteral = value.isLiteralText()) {
                valueVal = value.getValue(elContext);
        else
                BodyContent bodyContent = null;
                String content = null;
                String trimContent = null;
                if (
                        (bodyContent = this.getBodyContent()) == null
                        || (content = bodyContent.getString()) == null
                        ||  (trimContent = content.trim()).length() == 0
                        || (
                                trimContent.startsWith("<!--")
                        return result;
                valueVal = trimContent;;
                bodyContent.clearBody();
                isLiteral = true;
        if (component.getAttributes().get(nameVal) == null) {
            if (isLiteral) {
                component.getAttributes().put(nameVal, valueVal);
            else {
                component.setValueExpression(nameVal, value);
        this.release();
        return result;
}So guy, have you any idea of how to solve my problem?
Any help is very very appreciated!!
Regards,
-- Anthony

Hi BalusC
The first one is not for me because the "rendered" attribute is set on the server-side: the current "invisibl"e section would not be included in the renderer page (what I want is render the page displaying the current visible section and to switch to another section at client-side)
...but...
The second solution you propose is OK!!!! and so simple!!
Yeah man I really really thank you (sorry I didn't find the "?:" expression in the JSP manual http://java.sun.com/products/jsp/syntax/2.0/syntaxref20.html. Now looking again - and better - I find it as "ChoiceExpression")
Again, thanks!!!
-- Anthony

Similar Messages

  • How can i add custom attributes to a new Class Object using the API ?

    Hello everyone,
    Here is my problem. I just created a subclass of Document using the API (not XML), by creating a ClassObjectDefinition and a ClassObject. Here is the code :
    // doc is an instance of Document
    ClassObject co = doc.getClassObject();
    ClassObjectDefinition cod = new ClassObjectDefinition(ifsSession);
    cod.setSuperclass(co);
    cod.setSuperclassName(co.getName());
    cod.setName("MYDocument");
    ClassObject c = (ClassObject)ifsSession.createSchemaObject(cod);
    Everything seems to be OK since i can see the new class when i use ifsmgr. But my question is : how can i add custom attributes to this new class ? Here is what i tried :
    AttributeDefinition value = new AttributeDefinition(ifsSession);
    value.setAttribute("FOO", AttributeValue.newAttributeValue("bar"));
    c.addAttribute(value);
    But i got the following error message :
    oracle.ifs.common.IfsException: IFS-30002: Unable to create new LibraryObject
    java.sql.SQLException: ORA-01400: impossible d'insirer NULL dans ("IFSSYS"."ODM_ATTRIBUTE"."DATATYPE")
    oracle.ifs.server.S_LibraryObjectData oracle.ifs.beans.LibrarySession.DMNewSchemaObject(oracle.ifs.server.S_LibraryObjectDefinition)
    oracle.ifs.beans.SchemaObject oracle.ifs.beans.LibrarySession.NewSchemaObject(oracle.ifs.beans.SchemaObjectDefinition)
    oracle.ifs.beans.SchemaObject oracle.ifs.beans.LibrarySession.createSchemaObject(oracle.ifs.beans.SchemaObjectDefinition)
    void fr.sword.ifs.GestionDocument.IFSDocument.createDocument(java.lang.String)
    void fr.sword.ifs.GestionDocument.IFSDocument.main(java.lang.String[])
    So, what am i doing wrong ?
    More generally, are we restricted in the types of the attributes ? (for example, would it be possible to add an attribute that would be an inputStream ? Or an object that i have already created ?).
    Any help would be appreciated. Thanks in advance.
    Guillaume
    PS : i'm using Oracle iFS 1.1.9 on NT4 SP6 and Oracle 8.1.7
    null

    Hi Guillaume,
    you're welcome. Don't know exactly, but assume that ATTRIBUTEDATATYPE_UNKNOWN
    is used to check for erronous cases only
    and it shouldn't be used otherwise.
    Creating your own objects could be simply done via
    ClassObject ifsClassObject;
    DocumentDefinition ifsDocDef = new DocumentDefinition(ifsSession);
    // get class object for my very own document
    ifsClassObject = ClassObject.getClassObjectFromLabel(ifsSession, "MYDOCUMENT");
    // set the class for the document i'd like to create
    ifsDocDef.setClassObject(ifsClassObject);
    // set attributes and content for the document...
    ifsDocDef.setAttribute("MYFOO_ATTRIBUTE",....);
    ifsDocDef.setContent("This is the content of my document");
    // create the document...
    PublicObject doc = ifsSession.createPublicObject(ifsDocDef);
    null

  • How can I add an attribute to a node?

    Hi,
    How can I add an attribute to a node of a DOM Document?
    I want to add attribute Maximum="6" for all Grade node as <Grade Maximum="6">.
    Grade is a third level node in my document.
    Thanks

    Hi,
    How can I add an attribute to a node of a DOM
    Document?
    I want to add attribute Maximum="6" for all Grade node
    as <Grade Maximum="6">.
    Grade is a third level node in my document.
    ThanksGet the father of "Grade" elements as an element. Then get all elements named "Grade", and for each one set attribute "Maximum" with value "6". If you read api documentation you will know which methods to use.
    But for helping you in getting the "Grade" parent.
    1) get the root element of the Dom Doc
    2)get the father of the "Grade" father: getElementsBytagName("his name") -> it will return a Node List get the first element casting as Element if there's only one, or elese if not case
    3)the same method in 2 get the "Grade" father
    4)getElementByTagName("Grade") over the "Grade" father -> for each "grade" element on nodelist do whatever you need
    i hope u understood...

  • How to dinamically add label to flex application...?

    Hi,
    I'm new to flex and I have to make component similar to this:
    http://imageupload.org/?d=F41EBEC01
    I have 3 questions:
    1. As you can see, component is divided on regions (here is 4 regions with different colors, but there can be more regions - this should be programatically). Now, above this box should be scale with number of region
    (you can see this scale to). Scale should also be programatically, based on number of regions - 4 in this example.
    Which is the best control for doing this? Is there any
    flash builder control that support customization with scales and something like this component, or I have to use drawing for this, as I have already have?
    2. How can I make opacity css effect? For example, in component on previous link I want to make some areas of box black but with opacity, so area under black is seen. Something like on this picture:
    http://imageupload.org/?d=A3B76A421
    3. How can I add label dinamically in action script code? I tried:
    var myLabel:spark.components.Label=new spark.components.Label();
    myLabel.move(0,0);
    myLabel.text="AAA"
    addChild(myLabel);
    but nothing happened.
    I'm using spark layout. I also tried to add label on button click but it also doesn't work. I tried to set wigth and height of label but it also doesn't work.
    Any kind of help would be appreciate.
    Thanks in advance

    you may have to use Hbox then insert label inside
    this may be helpful!!
    http://livedocs.adobe.com/flex/3/html/help.html?content=containers_intro_6.html

  • How do I add money without using my credit card or gift card?

    I'm on a budget and have my bank card as my default card on my account and I need to pay a monthly fee under $5 for an app. I can't use my bank card, they don't sell $5 itunes gift cards so how can I add money to my account?

    Sorry, but other than a prepaid iTunes card or a gift certificate, there's no way to add money to your balance in the iTunes Store. You'll probably need to get a $10 iTunes card, the lowest denomination I've seen, or get a friend to "gift" you the app you want and then reimburse your friend.
    Regards.

  • How can I apply new attributes to a table-Tag in an JEditorPane?

    I'm using a JEditorPane as a base for a small HTML-Editor. The manipulating of the attributes of an image-tag such as href works fine. But now I want to add the width-attribute to an table-tag.
    The result: Nothing in the table-tag, but other strange things (width is set to any TD oder in every cell a new table is added.
    How can I do this? Any suggestions??
    Thanks.

    Did you ever solve this problem?
    I can manipulte the <p> tags and character styles, but the manipulation of <td>, <div> and other standard tags I cannot figure out.
    Please let us know, [email protected]
    By the way:
    If you have only a width tag in your images, does it resize proportionaly, as in a normal browser or is the height taken from the original picture, as it happens with me?
    This is quite nasty, since I do not know the original picture sizes.

  • How could I ADD ITEM by using API

    Hi,
    I have Portal 9.0.3 installed.
    I want to call wwsbr_api from a javascript code (HTML portlet) to add a text item to a region, but I have some problem using this API:
    1; I don't know how could I get the p_caid, the p_folder_id and the region_id
    I found out that p_caid can be find WWSBR_SITES.ID. Is this correct?
    2; when I've tried to call this API from address line I've got a 404 ERROR (but it might have been casued by the wrong attribute values)
    So I need to know:
    - How could I find out the correct IDs?
    - How could I call wwsbr_api.add_item function from a javascript?
    Thanks for your help!
    THE BOOGIE IS OVER

    WWSBR_API is currently not supported in Portal Release 2 (902). Support for this API will return in the next version (9.0.2.6, planned for early 2003).
    Regards,
    Portal Product Manager

  • How can I add excel pictures using activex

    I would like to be able to use activex to insert an image into an excel spreadsheet. I know how to read and write data, but the chart feature is too cunmbersome and when I updated excel to 2007 most of the calls stopped working. I see that there is a pictures property/method that lets me specify an image file, but I don't know which property/method(s) to call it from.

    2007 does take more time to draw the data on the chart. I am not having any problems with errors on the active X for 2007. I is much slower than 2003 I would agree. My IT group moved us to 2007 so I am stuck with it no matter how slow it is. I am trying to figure out how to get the help file back. I had these in 2003 myself. I know it has nothing to do with LabVIEW. It is an add in or some switch that you need to throw in excel to allow for this connection.
    Tim
    Johnson Controls
    Holland Michigan

  • How do I add a TableModelListener using NetBeans IDE 6.0

    I added a JTable using the IDE but I need to be able to detect when someone has changed the value in a cell.
    From reading I found that I need a TableListener and can use TableChanged and GetValueAt but I can not determine how or where I am suppossed to add that code.
    It seems like it should be in the Guarded block because that is the only part of my code where my JTable is in scope.
    I tried adding a TableModelListener in the section of code that I can edit...right above main and the section where the IDE adds lines like these....
    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {                                        
    // TODO add your handling code here:
    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {                                        
    // TODO add your handling code here:
    So long story short I still can not determine how to add a Listener to my table.
    Is it something I have to edit myself or can the IDE add it? I can only see Mouse and Key Listeners that I can add in the IDE.

    Hi,
    Sorry I don't have a ready answer to your question, which by now you have probably resolved already. One reason you did not receive a timely reply is that this is a Java Studio Enterprise (JSE) forum, and not a NetBeans forum. Although these are two different products, many of the Enterprise features of JSE can be found in the current NetBeans 6.0 product.
    The general place to ask NetBeans questions is at [email protected]
    Regards,
    -Brad Mayer

  • How can I add an appoggiatura using the score editor?

    I'm using Logic Pro X to write an ensemble piece and I need to add an appoggiatura, how do I do it?

    Hi
    I'm not sure what your issue is: add extra notes, convert them to Independent Grace notes, and adjust the positions using the Layout tool as needed.
    CCT

  • How can I add an attribute to a SAML 2.0 response?

    I am trying to implement SSO with a relying party while using Azure AD as the IdP and they require the email address to come from one of the following attributes below in the SAML response.  But I can't for the life of my find out where I can configure
    the response in the Azure management console and my search-fu has so far turned up nil.
    name="email"
    name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress"
    name="emailAddress",nameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic"
    name="emailaddress",nameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic"
    name="Email",nameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic"
    name="saml_username",nameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic"
    name="emailAddress",nameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified"
    name="emailaddress",nameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified"
    name="emailaddress",nameFormat="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress"
    name="urn:oid:0.9.2342.19200300.100.1.3",nameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri"
    name="mail",nameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic"
            <AttributeStatement>
                <Attribute Name="http://schemas.microsoft.com/identity/claims/tenantid">
                    <AttributeValue>[MYGUID]</AttributeValue>
                </Attribute>
    <!-- I want an email attribute here -->
                <Attribute Name="http://schemas.microsoft.com/identity/claims/objectidentifier">
                    <AttributeValue>[MYOID]</AttributeValue>
                </Attribute>
                <Attribute Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name">
                    <AttributeValue>[email protected]</AttributeValue>
                </Attribute>
                <Attribute Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname">
                    <AttributeValue>Tindall</AttributeValue>
                </Attribute>
                <Attribute Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname">
                    <AttributeValue>Jeff</AttributeValue>
                </Attribute>
                <Attribute Name="http://schemas.microsoft.com/identity/claims/displayname">
                    <AttributeValue>Jeff Tindall</AttributeValue>
                </Attribute>
                <Attribute Name="http://schemas.microsoft.com/identity/claims/identityprovider">
                    <AttributeValue>https://sts.windows.net/[MYGUID]/</AttributeValue>
                </Attribute>
            </AttributeStatement>
            <AuthnStatement AuthnInstant="2015-02-20T19:51:12.000Z" SessionIndex="_1eb9dd08-0bb7-48b0-b37c-64eb64d9a5f2">
                <AuthnContext>
                    <AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:Password</AuthnContextClassRef>
                </AuthnContext>
            </AuthnStatement>
        </Assertion>
    </samlp:Response>
    Thanks in advance.
    Jeff

    When I did not get a response here, I had to open a ticket with support.  The short answer is that you cannot customize the SAML response when using Azure AD as an IdP.
    Response from support:
    I discussed the issue with senior engineers to get action plan for this issue. After doing research Senior engineers updated me that we cannot add a custom attribute to the default
    SAML response of Azure AD.
    Below is the link to get the list of available attributes
    https://msdn.microsoft.com/en-us/library/azure/dn195587.aspx
    As default SAML response from Azure AD , we have email address of the user sent out as attribute value for the Attribute " NAME ".
    They suggested me to configure the application we are trying to integrate with Azure AD in such a way that it transforms the Attribute  " NAME " into " EMAIL
    This was not particularly helpful in my case as I did not have any control over the 3rd party which specifically documented that they would not extract the email address from the name attribute.
    Cheers,
    Jeff

  • How can I add cursor attribute values or change the size?

    I am using the SetCursorAttribute and would like to create and add additional cursor attribute values insteasd of the current 24 that are available. In particular, I would like to number each cursor in my list to each cursor on a graph so it can be identified easily by the user. Making each cursor a different value from the available 24 Attribute Value's is not desired since they are not easily identified due to the size of the cursor. (it's hard to discern a square box to a square box with an X).
    OR
    Another possiblity could be to allow for modification of the current size of the Attribute Values, is this possible?

    Hi Dennis,
    Unfortunately there is currently no way to change the size of a graph cursor, or to beyond the 24 point styles you mentioned. However, there are many other ways to differentiate cursors beyond point style. You can use differing crosshair styles and colors. Additionally, you can use "PlotBitmap(...)" to plot a bitmap image to the control using relative X and Y coordinates. With a little creative programming, you can use this function to simulate a graph cursor.
    regards,
    Eric Meyer
    Applications Engineer
    National Instruments

  • How Do I Add 2nd Monitor using AppleTV?

    I use a mid - 2012 Mac Pro; run Mavericks MacOS X 10.9.5. 
    1. I would like to know how to connect my SONY TV as a second monitor wirelessly using AppleTV.
    2. Once 2nd monitor is connected:
    3. What do I do to use the cursor and keyboard on the 2nd monitor?
    4. How do I reply to an answered question for more info, or to thank someone?

    Hey again Angel,
    It is the latter:
    If your Mac supports AirPlay Mirroring, an AirPlay Mirroring status icon appears in the menu bar when an Apple TV is on the same network as your Mac.
    OS X Mavericks: Wirelessly mirror your Mac screen to your HDTV
    https://support.apple.com/kb/PH14375
    So the AirPlay icon will only be seen on your Mac when an Apple TV is present on the same network as your Mac. You may also be interested in more information about AirPlay, which can be found here:
    About AirPlay Mirroring in OS X - Apple Support
    https://support.apple.com/en-us/HT201343
    -Braden

  • How can I add page numbers using Adobe Reader?

    I am trying to add page numbers to my document only using Adobe Reader.  Is that possible?  Or do I need to use Adobe Acrobat?

    The free Reader can do very little more than reading (opening) PDF files. I'd use Acrobat.

  • How do I add more pictures using iMovie themes

    I'm having trouble adding more pic's to the theme I selected on imovie. Is there a way to add more pic's? or is this the extent of using the theme's?

    Hi
    You can add photos to it - But they didn't make it easy at all.
    • You first collect photos in a new iMovie Project
    • Export out "Share to QuickTime" and as a QuickTime movie
    • Import this movie into Events
    • This Event can be used in a Project and Themes.
    Some things never got any better. Wonder Why ?
    Yours Bengt W

Maybe you are looking for

  • Ipod not recognized in itunes. tried a billion things. Can you please help?

    Hey there, Ipod problems... a few weeks ago my ipod died and I managed to restore it over a few days. Seemed to be happy until last night when I plugged it into my computer and ... it didn't work. Windows recognises the ipod. I can see it under MY CO

  • Calling QuickTime Functions From PowerBuilder

    I am using PowerBuilder 9 and would like to call the QuickTime functions from my Windows Vista PC. Has anyone else used PowerBuilder to call these functions?

  • RWB not in SLD

    Hi guys, I am facing the following problem in a new PI 7.01 installation (be careful the PI version is 7.01 not 7.1). According to the Readiness Check guide everything seems to be working fine, but the RWB is not registered itself in the SLD, under t

  • How can i trace my lost iphone 4

    how can i trace my iphone since the lost phone is offline?

  • Strange appearance of a new Network Neighborhood

    Hi all, I just opened up my "Shared" section in the finder, about to go to the hard disk on my other computer and, lo, there's a network neighborhood there that I've never seen or heard of. (This is a desktop mac connected to the internet through a N