Passing EL method expression as attribute of custom Facelets tagfile

前端 未结 1 358
Happy的楠姐
Happy的楠姐 2020-12-03 20:32

I created a custom JSF tag:


    
        

        
1条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-03 21:09

    My questions are: is this the best way to do this?

    That's the only way anyway, provided that you can only use standard JSF/EL facilities and you cannot create a custom taghandler.

    You could however create a custom taghandler to convert the value expression to a method expression. The OmniFaces JSF utility library has a for exactly this purpose. See also the demo page.

    You could then end up like:

    
    

    and

    
    
    

    See also:

    • Dynamic ui include and commandButton

    How can I make the method optional?

    Theoretically, you could use JSTL tags to build the view conditionally. Something like:

    
        
            
        
    
    

    But that's in the particular case of a special method expression listener attribute unfortunately not possible. There's no such thing as or something which allows you binding a RichFaces specific scrollListener as a separate tag to the . Best what you could do without creating custom taghandlers is duplicating the whole in two s (or a ); one with and other without scrollListener. This is too clumsy. You'd really better create a custom taghandler for this which you could then place in a .

    0 讨论(0)
提交回复
热议问题