开发者

How to call javascript from backingbean jsf

开发者 https://www.devze.com 2023-01-04 07:08 出处:网络
ClientScript.RegisterStartupScript( this.GetType(), \"ReturnScript\", \"<script language=\'javascript\'> alert(\'\" + ErrorMsg + \"\');&l开发者_Python百科t;/script>\");
ClientScript.RegisterStartupScript(
    this.GetType(),
    "ReturnScript", 
    "<script language='javascript'> alert('" + ErrorMsg + "');&l开发者_Python百科t;/script>");

alternate in java (JSF)


Just print the JS code as-is in the JSF view. The JS runs at client machine, not at server machine. You can use <h:outputText> for this.

<h:outputText value="<script>alert('foo');</script>" escape="false" />

You can even get it as a bean property:

<h:outputText value="#{bean.script}" escape="false" />

The escape="false" is there to prevent the (default) HTML-escaping of the value.

See also:

  • Communication between Java/JSP/JSF and JavaScript
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号