0

I have a web service that returns java script. The service is basically a wrapper around Google captcha service. It works simply including it in html code like following.

<body>
       <script type="text/javascript" src="https://host/captchaservice/generate.htm?userName=me">
      </script>
   </body>
   </html>

The service returns output which looks like this

var scripts=[]; scripts.push('https://www.google.com/recaptcha/api.js?hl=en'); for(src in scripts) document.writeln('<scri'+'pt src="'+scripts[src]+'" type="text/javascript"></sc'+'ript>') document.writeln('<div class="g-recaptcha" data-sitekey="12341234234asdf324f324rf34t23f341234"></div>')

Now I need to incude this captcha service in my JSF page.

  • using <h:outputscript> you can only include local scripts
  • using it in separate script by using JQuery get call and use eval() on returned data does not work.
  • Also need to paste it in exact location.
  • -I can try using it in backing bean, but at the end I have to format the script in an html control.

There should be an easy way to do this which I am not probably aware of. BTW, I am using JSF 2.0.

Any help on this will be highly appreciated.

wahid
  • 1
  • 2
  • using works but not sure I can access the param from managed bean, keep you posted. – wahid Nov 13 '15 at 22:37
  • What exactly is your problem when just using ` – BalusC Nov 15 '15 at 11:03
  • I thought – wahid Nov 16 '15 at 16:37
  • JSF is just a HTML code generator. The webbrowser -the HTML retriever/interpreter- absolutely doesn't care who/what/how the HTML generates. – BalusC Nov 17 '15 at 07:48
  • Now that the captcha script showing google captcha link, I am having hard time retrieving value. It is simply fetched by calling 'request.getParameter("g-recaptcha-response");' in JSP. In JSF I should be able to fetch it using FacesContext like following: 'Map parameterMap = (Map)context.getExternalContext().getRequestParameterMap(); String val = parameterMap.get("g-recaptcha-response");' – wahid Nov 18 '15 at 15:48

0 Answers0