JSF2: how achieve site-wide viewParam handling policy using a template

后端 未结 2 1866
走了就别回头了
走了就别回头了 2021-01-14 20:04

The following seems to be ignore inside XHTML facelet templates:


    
         


        
2条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-14 20:26

    Unfortunately, that's by spec. Your best bet is to use @ManagedProperty instead.

    public class BackingBean {
    
        @ManagedProperty("#{param.id}")
        private Long id;
    
        // ...
    }
    

    The only disadvantage is that this doesn't offer the advantage of using declarative conversion/validation by XHTML. You can if necessary do this job in a @PostConstruct method.

提交回复
热议问题