2017-07-19 30 views
0

在我的登錄頁面上,我做了一個複選框以將數據保存到cookie。當複選框被選中時,數據將被加載到下一個打開的登錄頁面上的用戶名字段,密碼字段。目前,Cookie數據已加載到用戶名字段上,但基於Tapestry page如何在Tapestry Framework中設置passwordfield的init數據?

PasswordField是TextField的一個版本,但作爲元素呈現。此外,密碼字段的輸出值始終爲空。

所以我不能設置密碼字段的init數據。而且我不允許使用jquery或javascript,只需在服務器端將值設置爲passwordfield即可。有人可以提出解決方案嗎?

Login.tml

<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd" 
    xmlns:p="tapestry:parameter"> 
<body> 
    <t:passwordfield t:id="password" size="30" />   
</body> 
</html> 

Login.java

@Property 
private String password; 
@InjectComponent("password") 
private PasswordField passwordField;  

void setupRender() { 
password = cookieTapestry.readCookieValue("userPassword") != null ?cookieTapestry.readCookieValue("userPassword") : null; 
} 

回答

0

PasswordField就像是一個更有限的TextField。嘗試< t:textfield type =「password」... >,你會發現你對行爲有更多的控制。

+0

Tks鮑勃,其工作像魅力。 –

相關問題