论坛首页 Java企业应用论坛

Tapestry中那里做统一的权限验证比较好

浏览 8930 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2005-10-12  
引用
gzdlw:
在T4中,大家可能会发现TextField组件多了一个参数validators


验证讲的很不错!但是我不知道你是在哪里看到的 TextField 的 validators属性,我找变了 t4的网站,但是也找不到这份最新的 T4文档,现在是这个:

TextField
Parameters 
Example 
A form element component that renders an <input> element. 

See also: org.apache.tapestry.form.TextField, Form, ValidField 

Parameters
Name Type Direction Required Default Description 
value string in / out yes   The value to be editted, which is is usually a string. Tapestry has limited ability to convert to and from strings. 
disabled boolean in no false If true, then a disabled attribute will be rendered as part of the <input> tag, and the component will not update its value parameter when the form is submitted. 
displayName string in no   The user-presentable name for the component, which will be used by a FieldLabel connected to the component. 
hidden boolean in no false If true, then the type attribute will be "password", not "text", and user input in the browser will be masked.  

Body: removed 

Informal parameters: allowed 

Reserved parameters: name, type, value 

A TextField may be decorated by the Form's validation delegate, but does not have a validator, so is limited in editting properties types beyond string. In most cases, the ValidField component is preferred. 



看的出来作者还是鼓励使用 “ValidField”的,但是我在“ValidField"文档上又看到这个说明:
This component has been deprecated; Tapestry 4.0 adds even better support for validation to TextField, TextArea and most other form element component. 


文档相互矛盾啊!  能共享一下最新的 T4文档吗,我想看看 TextFiled的验证使用说明最新的内容. 你是在哪里看到的?
0 请登录后投票
   发表时间:2005-10-13  
有啊:)。
http://jakarta.apache.org/tapestry/UsersGuide/validation.html

文档是有些不足,不过半猜半试,也就会用了。
0 请登录后投票
   发表时间:2005-10-16  
gzdlw 写道
有啊:)。
http://jakarta.apache.org/tapestry/UsersGuide/validation.html

文档是有些不足,不过半猜半试,也就会用了。


试了一下 T4的客户端验证,好像只有使用 <bean>标签的情况下才能有客户端验证,例如:这段代码:
<component id="testf" type="TextField">
    <binding name="value" value="ognl:email"/>
       <binding name="value" value="visit.bigdecimal"/>
    <binding name="translator" value="translator:number,pattern=#.#"/>
    <binding name="validators" value="validators:required,min=2,max=100.123456234563456734563456356734567456784567456784567845675678456785678"/>
    <binding name="displayName" value="literal:Big Decimal Field"/>
  </component>

我如过想改成 客户端验证,加上  <binding name="value" value="clientScriptingEnabled"/>
是不起作用的,如下:
<component id="testf" type="TextField">
    <binding name="value" value="ognl:email"/>
    <binding name="value" value="clientScriptingEnabled"/> 
    <binding name="value" value="visit.bigdecimal"/>
    <binding name="translator" value="translator:number,pattern=#.#"/>
    <binding name="validators" value="validators:required,min=2,max=100.123456234563456734563456356734567456784567456784567845675678456785678"/>
    <binding name="displayName" value="literal:Big Decimal Field"/>
  </component>



运行的结果还是会到服务器端验证的?难道不能在 component 上加上需要客户端验证的标示来控制是否在客户端验证么? 一定要定义 bean?
0 请登录后投票
   发表时间:2005-10-21  
我觉得是t4的bug,还是我没弄透彻?我一般明确在form组件中指定


&lt;form jwcid="@Form" ... clientValidationEnabled="ognl:true" ...


瞧t4的form.jwc中说的

&lt;parameter name="clientValidationEnabled"&gt;
    &lt;description&gt;
    If true (the default) then client-side validation will be generated upon render for any
        required or validating fields.
&lt;/description&gt;
  &lt;/parameter&gt;


...

If true(default)  ,我实在找不到哪里保证了这个default了

Form.java中并未实现该方法,交由javassist增强,我理解boolean默认值是false
0 请登录后投票
   发表时间:2005-10-21  
不知道T4的文档是否由HShip一个人维护,要是这样可能失误难免了 ;-(
0 请登录后投票
   发表时间:2005-12-07  
大家是不是跑题了啊??
楼主说的是整个系统的权限验证,不是单个页面的校验呀....
Tapestry最近才开始关注(落伍了^_^),哪个大牛有比较好的解决方案??
0 请登录后投票
论坛首页 Java企业应用版

跳转论坛:
Global site tag (gtag.js) - Google Analytics