【问题标题】:calling a javascript from a4j:jsFunction in richfaces 3.3.3在 Richfaces 3.3.3 中从 a4j:jsFunction 调用 javascript
【发布时间】:2013-05-01 16:08:43
【问题描述】:

我有一个javascript,我把它放在extraHeaderContent 中:

<ui:define name="extraHeaderContent">
    </script> -->
    <script type="text/javascript">
    function getTimezoneName() {
        var timezone = jstz.determine_timezone();
        return timezone.name();
    }
    </script>
</ui:define>

我想用这个脚本来获取时区,然后像这样在 a4j:jsFunction 中使用它:

<a4j:jsFunction name="getTimezoneName" data="#{usertimezone.userTimeZone}" >
             <a4j:actionparam name="userTimeZone" 
                              assignTo="#{usertimezone.userTimeZone}"
                              />
</a4j:jsFunction>

甚至像这样:

<a4j:jsFunction action="#{usertimezone.prepareTimeZone()}" >
             <a4j:actionparam name="userTimeZone" 
                              value="getTimezoneName()"
                              assignTo="#{usertimezone.userTimeZone}"
                              noEscape="true"/>
</a4j:jsFunction>

但这些都不起作用。我做错了什么?

【问题讨论】:

    标签: javascript richfaces jboss7.x jsf-1.2 seam2


    【解决方案1】:

    我认为您对 a4j:jsFunction 的工作原理感到困惑,它允许您从 javascript 触发服务器端方法(您似乎试图以相反的方式工作)

    例如...

    <a4j:jsFunction name="myJavascriptMethod" action="#{myActionBean.myJavaMethod}" >
        <a4j:actionparam name="param" assignTo="#{myActionBean.beanParam}"/>
    </a4j:jsFunction>
    
    <script>
        var param = "foo";
        myJavascriptMethod(param);
    </script>
    

    【讨论】:

      猜你喜欢
      • 2012-07-31
      • 2011-09-23
      • 2015-11-07
      • 1970-01-01
      • 2011-02-23
      • 2012-02-10
      • 2011-12-22
      • 1970-01-01
      • 2013-07-12
      相关资源
      最近更新 更多