2013-10-23 85 views
0

我需要在LifeRay portlet中驗證我的表單。經過一番調查後,我明白LifeRay有兩種驗證表單的方法:使用Alloy UI標籤庫並使用Alloy UI javascript庫。並且使用taglibs這是舊的方式(請糾正我,如果我錯了)。在LifeRay portlet中使用合金UI

所以我想使用Alloy UI Javascript庫進行驗證。但我如何將它包含到portlet?據我瞭解,Alloy UI JS庫自6.x版本起與LifeRay捆綁在一起。可能是我需要指定<header-portlet-css><header-portlet-javascript>?因爲它看起來合金用戶界面沒有自動包含到每個portlet中。

回答

3

這是一個示例。

插入在您在portlet的JSP標籤庫alloyui用正確的使用屬性的範圍內有A.FormValidator對象:

<aui:script use="aui-form-validator"> 

var validator = new A.FormValidator({ 
    boundingBox: form, 
    rules: { 
     '<portlet:namespace />emailAddress': { 
      email: true 
     }, 
     '<portlet:namespace />countryId': { 
      required: true 
     } 
    }, 
    strings: { 
     required: '<liferay-ui:message key="this-field-is-required" />' 
    } 
}); 

</aui:script> 
+0

感謝,現在會嘗試。但是使用這個''(如你所建議的)和這個:'YUI()。use( 'aui-form-validator',' – MyTitle

+0

另外我嘗試了''這個](http://alloyui.com/examples/form-validator/real-world/)''alloyui.com'的例子,但CSS類默認不應用。你能幫我設置一下嗎使用LifeRay 6.1.2。謝謝。 – MyTitle

+0

只有使用ji,你必須使用'AUI()。use('aui-form-validator','。這兩種方式非常相似。 –