这是我的用例:
我在我的.xhtml页面中有一个CKEditor和隐藏的值,如下所示:
<p:panelGrid columns="1" id="pnTemplateHeader" style="width:700px"> <h:inputHidden required="false" value="#{templateBean.headerContent}" id="headerValue" binding="#{templateBean.hiddenHeader}"/> <h:inputTextarea cols="90" rows="20" class="ckeditor" id="head" name="head" > #{templateBean.headerContent} </h:inputTextarea> <script type="text/javascript" > CKEDITOR.replace('head', { removeButtons: 'Underline,Strike,Subscript,Superscript,Anchor,Styles,Specialchar', }); </script> </p:panelGrid>现在,我需要能够检索用户在CKEditor中输入的所有文本,我在http://kb4dev.com/tutorial/jsf-and-ckeditor/jsf-2.x--ckeditor-集成引导
他们说我可以使用以下方法从隐藏的后台bean中检索值。
.xhtml:
<h:commandButton id="previewTemplateButton" onclick="document.getElementById('frmCreateTemplate:footerValue').value = CKEDITOR.instances.footer.getData(); action="#{templateBean.export2PDF}" > </h:commandButton>但是当我获得支持bean的值时,我只是得到一个NULL值。
后盾豆:
System.out.println("Values: footer=" + footerContent + ", body= " + bodyContent + ", header=" + headerContent);什么可能是错的?
我已经测试了几种方法,比如像这样在后台bean中访问隐藏的组件:
UIViewRoot root = FacesContext.getCurrentInstance().getViewRoot(); UIComponent hiddenHeaderComp = root.findComponent("headerValue"); hiddenHeaderComp = getUIComponentOfId(root, "headerValue"); hiddenHeader = (UIInput)hiddenHeaderComp; if(hiddenHeader != null){ System.out.println("After retrieving value: " + hiddenHeader.getValue()); }但是这也不起作用。 我能做什么?
this is my use case:
I have a CKEditor and hidden value in my .xhtml page like this:
<p:panelGrid columns="1" id="pnTemplateHeader" style="width:700px"> <h:inputHidden required="false" value="#{templateBean.headerContent}" id="headerValue" binding="#{templateBean.hiddenHeader}"/> <h:inputTextarea cols="90" rows="20" class="ckeditor" id="head" name="head" > #{templateBean.headerContent} </h:inputTextarea> <script type="text/javascript" > CKEDITOR.replace('head', { removeButtons: 'Underline,Strike,Subscript,Superscript,Anchor,Styles,Specialchar', }); </script> </p:panelGrid>Now, I need to be able to retrieve all text the user has entered in CKEditor, I've found this way in http://kb4dev.com/tutorial/jsf-and-ckeditor/jsf-2.x--ckeditor-integration-guide
They say I can retrieve value from hidden in backing bean using the following.
.xhtml:
<h:commandButton id="previewTemplateButton" onclick="document.getElementById('frmCreateTemplate:footerValue').value = CKEDITOR.instances.footer.getData(); action="#{templateBean.export2PDF}" > </h:commandButton>But when I get the value in backing bean, I just get a NULL, value.
Backing bean:
System.out.println("Values: footer=" + footerContent + ", body= " + bodyContent + ", header=" + headerContent);What could be wrong?
I have tested several approaches like accessing hidden component right in the backing bean like this:
UIViewRoot root = FacesContext.getCurrentInstance().getViewRoot(); UIComponent hiddenHeaderComp = root.findComponent("headerValue"); hiddenHeaderComp = getUIComponentOfId(root, "headerValue"); hiddenHeader = (UIInput)hiddenHeaderComp; if(hiddenHeader != null){ System.out.println("After retrieving value: " + hiddenHeader.getValue()); }But this isn't working either. What can I do?
最满意答案
那么,我发现了这个问题。 这里真正的问题是,我只是使用inputhidden值调用组件,但它位于一个Primefaces Accordion中,该组件位于表单内部,所以我缺少了:form:accordionid input.hidden id之前
Well, I have found the problem. The real problem here is that I was calling the component just with the inputhidden value, but it is inside a Primefaces Accordion which in turn is inside the form, so I was missing :form:accordionid before inputhidden id
更多推荐
value,bean,id,电脑培训,计算机培训,IT培训"/> <meta name="description&quo
发布评论