关于JSF里面的Composite Components

今天学习了 JSF的Composite Components。

这个Composite Components是一个特别的模板可以做component,其他的都还好理解,就是这个composite:editableValueHolder, Oracle的官方文档写的英文非常的绕口,读了半天也没有完全明白。

composite:editableValueHolder

Declares that the composite component whose contract is declared by the composite:interface in which this element is nested exposes an implementation of EditableValueHolder suitable for use as the target of attached objects in the using page.

看了例子,大概理解如下。 首先这个editableValueHolder是用来指向 composite implementation,

       
           
           

           
                                             method-signature="java.lang.String action()"/>
           
           
           

       

注意,target是指向implementation的,这里有个form:,我查了很多文档没有提到,我把form:拿掉,就会报错,后来发现是下面implementation是在form里面,如果我把implementation从form里面拿出来,就没有错了。注意这个target接受多个,用逗号分开,但是因为我们需要在using page验证这两个field,合在一起无法分开验证。

下面是implementation

 
           
                                                    target="head"/>
               
                                                       value="#{cc.attrs.namePrompt}"/>
                                                     value="#{cc.attrs.myLoginBean.name}" 
                                 required="true"/>

                                                       value="#{cc.attrs.passwordPrompt}"/>
                                                       value="#{cc.attrs.myLoginBean.password}" 
                                   required="true"/>

               

               


                                                         value="#{cc.attrs.loginButtonText}"
                                     action="#{cc.attrs.loginAction}"/>
               


           
           

                                            showDetail="false"
                            errorStyle="color: #d20005" 
                            infoStyle="color: blue"/>
           

       

然后呢, 这个可以在using page里被用到

                                               loginAction="#{myLoginBean.login}">
                    for="vals" />
                                                         for="passwordVal"/>
               

以上就是我今天学习心得。

你可能感兴趣的:(Java杂谈)