JQuery Primefaces remoteCommand parameter issue

萝らか妹 提交于 2020-01-25 07:23:28

问题


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);
        }
    }

回答1:


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



来源:https://stackoverflow.com/questions/5367689/jquery-primefaces-remotecommand-parameter-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!