Package com.webfirmframework.wffweb.js
Class JsUtil
java.lang.Object
com.webfirmframework.wffweb.js.JsUtil
Utility methods to generate JavaScript code.
- Since:
- 2.1.1
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
getJsObjectForFieldsValue
(String... ids) static String
getJsObjectForFieldsValue
(Map<String, Object> jsKeyAndElementId) static String
getJsObjectForFieldsValue
(Map<String, Object> jsKeyAndElementId, String alternativeFunction) static String
static String
getJsObjectForFieldsValue
(Set<Object> ids, String alternativeFunction) static String
getJsObjectForFieldsValue
(Set<Object> inputIds, Set<Object> checkboxIds) static String
getJsObjectForFieldsValue
(Set<Object> inputIds, Set<Object> checkboxIds, String alternativeFunction) static String
getJsObjectForFieldsValueWithAltFun
(String alternativeFunction, String... ids) static String
This method is mainly for internal use.static String
It replaces all new lines by\n
so that it can be used as a dynamic JavaScript string in event attributes js function body.
-
Method Details
-
getJsObjectForFieldsValue
- Parameters:
jsKeyAndElementId
- The map containing key values. The key in the map will be used as the key in the generated js object. The value in the map should be the id of the field.- Returns:
- the JavaScript object for the fields value. Sample :
{username:document.getElementById('uId').value}
- Since:
- 2.1.1
-
getJsObjectForFieldsValue
public static String getJsObjectForFieldsValue(Map<String, Object> jsKeyAndElementId, String alternativeFunction) - Parameters:
jsKeyAndElementId
- The map containing key values. The key in the map will be used as the key in the generated js object. The value in the map should be the id of the field.alternativeFunction
- alternative function name for document.getElementById- Returns:
- the JavaScript object for the fields value. Sample :
{username:gebi('uId').value}
if the alternativeFunction is gebi - Since:
- 3.0.1
-
getJsObjectForFieldsValue
- Parameters:
ids
- The set containing element ids. The id will be used as the key in the generated js object. The value in the set should be the id of the field. The id in the set should be a valid JavaScript object key.- Returns:
- the JavaScript object for the fields value. Sample :
{uId:document.getElementById('uId').value}
- Since:
- 2.1.1
-
getJsObjectForFieldsValue
- Parameters:
ids
- The set containing element ids. The id will be used as the key in the generated js object. The value in the set should be the id of the field. The id in the set should be a valid JavaScript object key.alternativeFunction
- alternative function name for document.getElementById- Returns:
- the JavaScript object for the fields value. Sample :
{uId:gebi('uId').value} if alternativeFunction is gebi
- Since:
- 3.0.1
-
getJsObjectForFieldsValue
- Parameters:
ids
- The string array containing element ids. The id will be used as the key in the generated js object. The value in the array should be the id of the field. The id in the array should be a valid JavaScript object key.- Returns:
- the JavaScript object for the fields value. Sample :
{uId:document.getElementById('uId'.value)}
- Since:
- 2.1.3
-
getJsObjectForFieldsValueWithAltFun
- Parameters:
ids
- The string array containing element ids. The id will be used as the key in the generated js object. The value in the array should be the id of the field. The id in the array should be a valid JavaScript object key.alternativeFunction
- alternative function name for document.getElementById- Returns:
- the JavaScript object for the fields value. Sample :
{uId:document.getElementById('uId'.value)}
- Since:
- 3.0.1
-
getJsObjectForFieldsValue
- Parameters:
inputIds
- input field ids such as input type text etc..checkboxIds
- checkbox field ids such as input type checkbox- Returns:
- the JavaScript object for the fields value. Sample :
{usernameInputId:document.getElementById('usernameInputId').value,dateExpiredCheckboxId:document.getElementById('dateExpiredCheckboxId').checked}
- Since:
- 3.0.1
-
getJsObjectForFieldsValue
public static String getJsObjectForFieldsValue(Set<Object> inputIds, Set<Object> checkboxIds, String alternativeFunction) - Parameters:
inputIds
- input field ids such as input type text etc..checkboxIds
- checkbox field ids such as input type checkboxalternativeFunction
- alternative function name for document.getElementById- Returns:
- the JavaScript object for the fields value. Sample :
{usernameInputId:document.getElementById('usernameInputId').value,dateExpiredCheckboxId:document.getElementById('dateExpiredCheckboxId').checked}
- Since:
- 3.0.1
-
toDynamicJs
This method is mainly for internal use.- Parameters:
s
-- Returns:
- the returned string will be striped and all lines will be replace by
\n
. - Since:
- 3.0.15
-
toDynamicJsString
It replaces all new lines by\n
so that it can be used as a dynamic JavaScript string in event attributes js function body. It is unicode aware.- Parameters:
s
-- Returns:
- the string having all lines replaced by
\n
. - Since:
- 3.0.17
-