我的目标是使用queryString参数(http://localhost:8080/page.html?scrapeU ... ://cnn.com )调用此页面,然后尝试从facescontext中提取requestparametermap中的值,但在我的init方法中为空。我的第二个选择是在我的jQuery(document).ready函数中设置一个inputhidden,但是下面的语法不起作用。有没有人知道怎样才能让它正常工作?谢谢你的帮助!
<?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);
}
}发布于 2011-03-21 03:29:08
在init()方法中调用sourceURL,但在示例URL中使用scrapeURL。这可能是错误吗?
https://stackoverflow.com/questions/5367689
复制相似问题