(1)
在我的JSF页面中想表达这样的语句:
<h:outputText id="scripthere" escape="false" value="<b>This is a text</b>" />
但是页面报错误:The value of attribute "value" associated with an element type "h:outputText" must not contain the '<' character.
查了下,这个比较好解决,办法如下:
<b><h:outputText id="scripthere" escape="false" value="This is a text" /></b>
(2)但是我要达到这样的效果就难了。
<h:outputText id="scripthere" escape="false" value="<script>alert('提示信息');</script>" />
我也用了上面的那个办法,但是还是报那个错误。至今还没有找到办法....
找到了办法:
<script>
<h:outputText id="scripthere" value="alert('提示信息')"/>
</script>
这样每行每行写就不会全部飘红了。(注意这里的id,其实在后面已经验证了这里不要id)
其实我最终的目的不是这样写的,
最终目的写法:
<script>
<h:outputText id="scripthere" value="#{publishTemplate.script}"/>;
</script>
这样写也没有达到我要的效果,因为页面重新加载一次就使得我private String script;这个为空(这里为空的原因在后面也说了是因为按钮的原因我这里用的是ajax4jsf的,在后面也改成普通的按钮,以便点击后来刷新整个页面)
public String getScript() {
System.out.println("getscript="+script);
return script;
}
public void setScript(String script) {
System.out.println("setscript="+script);
this.script = script;
}
我在判断没有目录的时候会设置它的值:
else{
System.out.println("must be publish template at first !");
this.setScript("alert('提示信息');");
}
但是当页面重新加载一次我就得不到它的值了。所以可能这种方法行不通啦 !!!
最后实在没办法了,就把那个script属性设置成static,这时候就弹出对话框来了,因为很难看它当页面还没有加载完的时候就弹出对话框把整个屏幕都全笼罩了,所以修改template.xhtml里面的那段代码:
<script>
window.onload = new Function("<h:outputText value="#{publishTemplate.script}"/>");
</script>
这样修改就好看些了。
但是当用已经存在的目录来操作时,因为它是static所以达不到效果,所以最后放弃这种方式。
哈哈,上面的情况总得不到值是因为我的按钮的问题,我原来用的是:
<a:commandButton value="Publish" action="#{publishTemplate.publishOneDirectory()}" rendered="#{templateBean.select}" />
xmlns:a="http://richfaces.org/a4j"
这里是ajax4jsf的按钮,a 是ajax的功能 它提交执行后 不再重绘整个页面
,重绘整个页面时它会去bean里取的。所有改成h:commandButton了。这样在后台就可以得到值,但是在前台还是没有得到。待解决中...
最终的解决办法找到啦!!!
完整的代码如下:
(1)类:
private String script;
public String getScript() {
return script;
}
public void setScript(String script) {
this.script = script;
}
public void publishOneDirectory(){
if(localFilePath != null && flag == true){
//这里的代码省略了
}else{
this.setScript("alert('must be publish template at first !');");
}
}
(2)页面中:这outputText里面的id已经去掉啦,不去掉会报错。
<script>
window.onload = new Function(" <h:outputText value="#{publishTemplate.script}"/> ");
</script>
<h:commandButton value="Publish" action="#{publishTemplate.publishOneDirectory()}" rendered="#{templateBean.select}" />
分享到:
相关推荐
jsf和jpa 期末大作业 ... <h:outputText value="删除"></h:outputText> <f:param name="p_id" value="#{person.id}"/> </h:outputLink> </h:column> </h:dataTable> </h:form> </f:view>
. 解法如下拿DIV把h:outputText 罩住 <div class="textAreaWrap" style="width:600px">
通过使用Express Language 3(Java EE 7的一部分),多个属性也可以通过EL表达式直接定义。 <h:outputText value="Something" > <f:passThroughAttributes value="{"one":1, "two":2, "three":3}" /> </h:...
而且也有很多很好的控件给发出来了,如:richfaces、primefaces、myfaces等,就日前来讲primefaces功能很强大,控件很多,但有一点不好就是不支持IE6,特别是下拉列表,p:dialog等,其它的分页p:datatable实际使用...
而且也有很多很好的控件给发出来了,如:richfaces、primefaces、myfaces等,就日前来讲primefaces功能很强大,控件很多,但有一点不好就是不支持IE6,特别是下拉列表,p:dialog等,其它的分页p:datatable实际使用...
本文实例讲述了C#调用VB进行简繁转换的方法。分享给大家供大家参考。具体分析如下: 首先在C#项目中引用Microsoft.VisualBasic.dll,版本自己选择合适的 然后在项目中添加引用...另外还可以进行全角与半角转换,平假名
如Abean中download方法调用了该方法,前台可以这样调用: <h:commandButton value="download" action="#{aBean.download}"></h:commandButton> 或者 <h:commandLink value="download" action="#{fileUploadForm....
<h:outputText value=" "/> <h:commandButton value="Submit" action="#{myBean.processMyFile}"/> <h:outputText value=" "/> </h:panelGrid> </h:form> </f:view> 其中tags.jsp文件如下: ...
property OutputText:TStrings read fOutputText; property ErrorText:TStrings read fErrorText; property Running : boolean read fRunning; published property OnOutputText :TOnText read fOnOutputText ...
骑手还可以,但是您不会看到Textractor OutputText回调的输出。 (idk为什么,管道可能发生了某些问题)建议使用VS + Reshaper 只需准备运行F5即可,或者您可以在ErogeHelper的属性中填写命令参数,例如"D:\Ra-se-...
直接导入jar包,并把libs目录拷进项目即可使用。 ocr识别库下载 地址:: https://code.google.com/p/tesseract-ocr/downloads/list 调用示例程序: public void testGetUTF8Text() { // First, make sure the ...
目的 ... 支持的打印机 网页浏览器 Sato E/Pro 网络打印机 特征 文本输出字体大小 Code 39 条码 条码高度 ... ->outputText('HELLO WORLD') ->setPosition(0, 0.25, $printer::UNIT_INCHES) ->outputCo
public static string OutputText(string inputString) { string retVal=inputString; retVal= ConvertStr(retVal); retVal=retVal.Replace("[url]", ""); retVal=retVal.Replace("[/url]", ""); ...
String outputText = buffer.toString(); in.close(); return outputText; } public double getCpuRatio(){ double cpuRatio = 0; if (getOSName().toLowerCase().startsWith("windows")) { cpuRatio = ...
DrawTextOutLine Boolean 是否绘制文字描边 DrawTextShadow Boolean 是否绘制投影,不支持投影平移 Text String 源文,包含颜色代码的源文 TextRect Rectangle 给定...OutputText String 过滤颜色代码后的内容