-
1. How to use richfaces with javascript
ilya40umov Jan 28, 2011 7:45 AM (in response to clout)1 of 1 people found this helpfulif you are using facelets(xhtml) you should put CDATA like it's shown below:
<script type="text/javascript">
//<![CDATA[
var rowKey;
function doHandleRowSelection(key) {
rowKey = key;
}
//]]>
</script>
-
2. How to use richfaces with javascript
clout Jan 30, 2011 12:29 AM (in response to ilya40umov)Thank you for your answer, but I don't know how to invoke this javascript code in richfaces.
Could you help me, please? Thanks.
-
3. How to use richfaces with javascript
iabughosh Jan 30, 2011 3:49 AM (in response to clout)1 of 1 people found this helpfulDear Lee,
you can use this :
<a4j:commandButton id="btn" value="text" title="text" onclick="yourJSFunction"/>
-
4. How to use richfaces with javascript
ilya40umov Jan 30, 2011 7:17 AM (in response to iabughosh)I think you should alsp look at this two components:
http://docs.jboss.org/richfaces/latest_3_3_X/en/devguide/html/a4j_jsFunction.html
http://docs.jboss.org/richfaces/latest_3_3_X/en/devguide/html/rich_jQuery.html
And learn more about jQuery(If you are not already familiar with it)
-
5. How to use richfaces with javascript
clout Jan 30, 2011 11:03 PM (in response to clout)When I type the following code, the Chrome show a error message.
<script type="text/javascript">
<![CDATA[
function CheckForm(){
if(document.form.text1.value.length ==0 && document.form.text2.value.length ==0){
alert("please reset it !");
}
}
]]>
</script>
This page contains the following errors:error on line 15 at column 3: Sequence ']]>' not allowed in content
Below is a rendering of the page up to the first error. -
6. How to use richfaces with javascript
mp911de Jan 30, 2011 11:49 PM (in response to clout)Hi Lee,
just externalize your Script to a JavaScript file. So you don't need to escape it. In case you need to access your Fields dynamically (in your example), so switch to parameters:
in your JS-File:
function CheckForm(text1, text2){
if(text1.value.length ==0 && text2.value.length ==0){
alert("please reset it !");
}
}
your Action-Component (invoker):
<a4j:commandButton id="btn" value="text" title="text" onclick="CheckForm(#{rich:element('text1Id')}, #{rich:element('text2Id')})"/>
with #{rich:element('yourComponentId')} you can directly access your Components by id.
-
7. How to use richfaces with javascript
clout Jan 31, 2011 1:03 AM (in response to mp911de)Thank you very much, the code could run normally.
Thanks everyone.