jQuery Primefaces remoteCommand参数问题 [英] JQuery Primefaces remoteCommand parameter issue

查看:84
本文介绍了jQuery Primefaces remoteCommand参数问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标是使用queryString参数(http://localhost:8080/page.html?scrapeU ...://cnn.com来调用此页面,然后尝试从facescontext的requestparametermap中提取该值但是它在我的init方法中为null我的第二个选择是在我的jQuery(document).ready函数中设置一个inputhidden,但是下面的语法不起作用. >

My goal was to call this page with a queryString parameter (http://localhost:8080/page.html?scrapeU ... ://cnn.com and then try to pull the value from the requestparametermap off the facescontext but its null in my init method. My second option is to set an inputhidden in my jQuery(document).ready function but the below syntax doesn't work. Anyone know how to get this to work either way? Thanks for the help!

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
   xmlns:h="http://java.sun.com/jsf/html"
   xmlns:f="http://java.sun.com/jsf/core"
   xmlns:ui="http://java.sun.com/jsf/facelets"
   xmlns:p="http://primefaces.prime.com.tr/ui"
   xmlns:dc="http://dc.dreamcatcher.com/facelet-taglib">
<ui:composition template="/WEB-INF/facelet/layout/external/main.xhtml">
   <ui:define name="content">
   <h:form id="scrapeFrm" binding="#{bookmarklet.bookmarkletFrm}">
   <h:inputHidden id="scrapeURL" value="default"/>
   <p:remoteCommand name="scapeImages" process="@this,scrapeURL" actionListener="#{bookmarklet.loadImages}" update="imageGrid"/>
   <script type="text/javascript">
       jQuery(document).ready(function(){
          alert("here");
          var value=$('#scrapeURL').val();
          alert(value);
          scapeImages();
       }); 
    </script>
    </h:form>
   </ui:define>
</ui:composition>
</html>




@Named
@Scope("request")
public class Bookmarklet extends BaseAction{
    private UIForm bookmarkletFrm;

    public void init(){
        if (!FacesUtils.isPostback()) {
            ExternalContext context = FacesUtils.getExternalContext();
            String scrapeURL = context.getRequestParameterMap().get("sourceURL");
            bookmarkletBean.setScrapeURL(scrapeURL);
        }
    }

推荐答案

在init()方法中,您调用sourceURL,但是在示例URL中,您使用scrapeURL.这可能是错误吗?

In your init() method you call sourceURL, but in your example URL you use scrapeURL. May this be the error?

这篇关于jQuery Primefaces remoteCommand参数问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆