Primefaces p:textEditor标记工作不正常
在p:对话框中插入p:textEditor标记时,工具栏中的许多按钮/选择列表都不起作用 复制问题的以下步骤:Primefaces p:textEditor标记工作不正常,primefaces,dialog,text-editor,Primefaces,Dialog,Text Editor,在p:对话框中插入p:textEditor标记时,工具栏中的许多按钮/选择列表都不起作用 复制问题的以下步骤: 我单击相应的按钮打开(启动)对话框 我在文本编辑器区域键入一些文本 然后选择/突出显示刚才键入的部分文本 我单击字体大小选择下拉列表以选择不同的字体 字体大小(如“大”) 什么也没发生。我选择的文本保持不变。没有变化 奇怪的是,如果我退出对话框,然后重新打开对话框,工具栏中的选择列表和按钮可以正常工作。显然,这只是我第一次打开对话框,工具栏按钮不起作用 此外,我还尝试在主窗体上插入
- 我单击相应的按钮打开(启动)对话框
- 我在文本编辑器区域键入一些文本
- 然后选择/突出显示刚才键入的部分文本
- 我单击字体大小选择下拉列表以选择不同的字体 字体大小(如“大”)
- 什么也没发生。我选择的文本保持不变。没有变化
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<h:head>
<title>Facelet Title</title>
</h:head>
<h:body>
<h:form>
<p:commandButton value="Login" oncomplete="PF('dlg').show();" update=":loginForm" >
<p:resetInput target=":loginForm" />
</p:commandButton>
</h:form>
<p:growl id="growl" sticky="true" showDetail="true" life="3000" />
<p:dialog header="Login" widgetVar="dlg" resizable="false">
<h:form id="loginForm">
<h:panelGrid columns="2" cellpadding="5">
<h:outputLabel for="username" value="Username:" />
<p:inputText id="username" value="#{userLoginView.username}" required="true" label="username" />
<h:outputLabel for="password" value="Password:" />
<p:password id="password" value="#{userLoginView.password}" required="true" label="password" />
<h:outputLabel for="comment" value="Comment:" />
<p:textEditor widgetVar="txtEditor1" id="comment" value="#{userLoginView.text1}" height="100" style="margin-bottom:10px;margin-right:10px;" placeholder="Enter your content">
</p:textEditor>
<f:facet name="footer">
<p:commandButton value="Login" update="growl" actionListener="#{userLoginView.login}"
oncomplete="handleLoginRequest(xhr, status, args)" />
</f:facet>
</h:panelGrid>
</h:form>
</p:dialog>
<script type="text/javascript">
function handleLoginRequest(xhr, status, args) {
if(args.validationFailed || !args.loggedIn) {
PF('dlg').jq.effect("shake", {times:5}, 100);
}
else {
PF('dlg').hide();
$('#loginLink').fadeOut();
}
}
</script>
</h:body>
</html>
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package demo;
/**
*
* @author admin
*/
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import org.primefaces.PrimeFaces;
@ManagedBean
public class UserLoginView {
private String username;
private String password;
private String text1;
public String getText1() {
return text1;
}
public void setText1(String text1) {
this.text1 = text1;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public void login(ActionEvent event) {
FacesMessage message = null;
boolean loggedIn = false;
if(username != null && username.equals("admin") && password != null && password.equals("admin")) {
loggedIn = true;
message = new FacesMessage(FacesMessage.SEVERITY_INFO, "Welcome", username);
} else {
loggedIn = false;
message = new FacesMessage(FacesMessage.SEVERITY_WARN, "Loggin Error", "Invalid credentials");
}
FacesContext.getCurrentInstance().addMessage(null, message);
PrimeFaces.current().ajax().addCallbackParam("loggedIn", loggedIn);
}
}
我不知道您是否仍然存在这个问题,但是可以通过@PostConstruct方法打开和关闭对话框来解决这个问题。
它对用户来说是透明的,但仍然希望有一个更可行的解决方案。我如何复制?在…中没有类似的请求。。。戈戈,请为小费做一个手帕。我试试看。我不知道该怎么做:在@PostConstruct方法中打开和关闭对话框。顺便问一下,您是否有一段代码片段,其中有一个示例可以与我分享?我们将不胜感激。谢谢。很抱歉回答晚了。你可以选择这样的内容:
@PostConstruct
init(){
PrimeFaces current=PrimeFaces.current();
current.executeScript(“PF('myDialogVar').show();”;
current.executeScript(“PF('myDialogVar').hide()”););
谢谢,戈尔戈。我要试一试。当做