Setting ui:param conditionally

前端 未结 2 1602
遥遥无期
遥遥无期 2021-01-12 01:04

I want to set a ui:param depending on a bean value and I thought using c:if was a good idea. So I put in my page the following code:



        
2条回答
  •  星月不相逢
    2021-01-12 01:15

    As indicated by , this page represents a template client.

    Any outside applies to the master template (the file which you declared in template attribute) and is ignored inside the template client itself. If you intend to prepare variables for inside the template client, you should put inside .

    But there's another thing: the original purpose of is to pass variables to the file referenced by , or , not to prepare/set variables inside the current facelet context. For the sole functional requirement of preparing/setting variables in the current EL context, you'd better be using JSTL for the job. You can use for this, but this isn't its original intent and didn't work that way in older MyFaces versions.

    Thus, so:

    
        
            
        
        
            
        
        
            
        
        ...
    
    

    Unrelated to the concrete problem, you can optimize this as follows without the need for an unmaintainable group which would only grow with every subscription type:

    
        
        
        ...
    
    

    with those keys

    subscriptionTitle.mySubscriptions = Title for my subscriptions
    subscriptionTitle.paidSubscriptions = Title for paid subscriptions
    subscriptionTitle.allSubscriptions = Title for all subscriptions
    

提交回复
热议问题