2013-01-24 51 views
0

我添加了textfield和速度腳本中的一個按鈕,通過web應用程序使用。當web應用程序啓動時,會讀取start.properties文件。有一個屬性:debug_on可以取兩個值0或1.如何使用Java Script從屬性文件讀取值?

所以我想顯示文本字段和按鈕的debug_on值。如果我沒有弄錯(我不是JavaScript的專業人士),它可以通過javascript的速度腳本完成,但我需要獲取屬性值才能進一步移動。

我該如何實現它?

修訂

速度腳本示例,其中主要的GWT(Java)的代碼被嵌入在最後:

<!--doctype head declaration--> 

    <head> 
     <meta http-equiv="content-type" content="text/html; charset=UTF-8"> 
     <title>Web App</title> 
     <style> 
     <!-- styles --> 
     </style> 
     <link rel="stylesheet" href="/css/webapp.css" type="text/css"/> 
     <meta name='gwt:module' content='$uri'> 
    </head> 
    <body> 
     <script language="javascript" src="/$uri/com.myproject.gwt.main.nocache.js"></script> 
     <!-- TextField and button are located here --> 
     <table style="width: 300px; height: 100px;" class="gwt-DialogBox" cellpadding="0" cellspacing="5"> 
      <!-- some other part of a page tha will be persistent through all GWT pages --> 
     </table> 
    </body> 
    </html> 
+2

爲什麼這個標記爲Java?問題是關於JavaScript不是嗎? – Alderath

+0

@Alderath Velocity是一個Java模板引擎。 – Pointy

+0

@積分啊......好的。我的壞話! – Alderath

回答

0

速度在服務器上運行,JavaScript的運行在客戶端上,將無法訪問到任何服務器的文件。

可以使用Velocity設置JavaScript塊中的值並使JS函數使用這些值。

<script type='text/javascript'> 
var startValue = '$debug.value'; 
</script> 
+0

嗯。我打算使用