使用撇号可以生成一个对话框并设置一个表单来控制呈现的内容。下面是一个示例代码:
public void enterGroup(){
if(!AuthorizationUtils.isUserInRoles(new String[]{"UPDATER"})){
FacesContext context = FacesContext.getCurrentInstance();
context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL,
"Error", "The user does not have permissions to perform this
action."));
return;
}
else{
Map<String,Object> options = new HashMap<String, Object>();
options.put("resizable", false);
options.put("draggable", false);
options.put("modal", true);
options.put("width", 500);
options.put("height", 90);
options.put("contentWidth", "100%");
options.put("contentHeight", "100%");
PrimeFaces.current().dialog().openDynamic("entergroup",options,null);
}
}
我的问题是,是否有人知道是否有一种方法可以控制对话框X被退出,而不是用户在对话框上执行操作。我知道您可以将closable设置为false并完全消除X,但这并不是完全用户友好的。我只需要能够在单击X时重置对话框形式,或者执行一种清除我的某些Bean的方法,并且想知道是否有办法做到这一点。这比美容更重要。任何帮助,将不胜感激!如果可以帮助绘制图片,则将以下xhtml包括在内。
<!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:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<h:head>
<title>Enter the Name of the new group</title>
<style type="text/css">
.ui-widget {
font-size: 90%;
}
</style>
</h:head>
<h:body>
<div class="main">
<h:form method="post">
<p:panelGrid columns="3" styleClass="ui-noborder">
<p:outputLabel for="newgroupname" value="Group Name: ">
</p:outputLabel>
<p:inputText id="newgroupname" value="#{addgroup.newGroupName}"
/>
<p:commandButton action="#{addgroup.addNewGroup}"
value="Submit"></p:commandButton>
</p:panelGrid>
<h:outputText value="#{addgroup.dialogMessage}" style="color: red;">
</h:outputText>
</h:form>
</div>
</h:body>
</html>
答案 0 :(得分:0)
您可以通过这种怪异的方式做到这一点:
// replace tsrange_col with the name of your tsrange column
rows, err := db.Query("SELECT id, user_id, lower(tsrange_col), upper(tsrange_col) FROM appointments")
utils.CheckErr(err)
var id int
var userID int
var tsrange [2]time.Time
rows.Next()
err = rows.Scan(&id, &userID, &tsrange[0], &tsrange[1])
fmt.Println(tsrange[0]) // from
fmt.Println(tsrange[1]) // to
:
MyBean.java
在您的import static java.util.Collections.emptyMap;
import java.util.HashMap;
import java.util.Map;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
import org.primefaces.PrimeFaces;
@Named
@RequestScoped
public class MyBean {
public void dfShow() {
Map<String, Object> options = new HashMap<>();
// ...
PrimeFaces.current().dialog().openDynamic("entergroup", options, emptyMap());
}
public void dfClosed() {
PrimeFaces.current().dialog().closeDynamic("X");
}
}
中:
entergroup.xhtml