putViewScope(“types”, Type.values());
<h:outputText value="#{msg['dms']['type']}" />
<p:selectOneMenu id="type" style="width:140px;"
value="#{viewScope.type}" converter="#{enumConverter}">
<f:selectItem itemLabel="" itemValue="" />
<f:selectItems value="#{viewScope.types}" var="type"
itemLabel="#{type.name}" itemValue="#{type}" />
p:selectOneMenu>
document.getElementById("orgChartForm:orgChartNodeIndex").value = index;
var departmentOptions = document.getElementById("orgChartForm:department_input").options;
for(var i = 0; i < departmentOptions.length; i++){
if(departmentId == departmentOptions[i].value){
departmentOptions[i].selected = 'selected';
document.getElementById('orgChartForm:department_label').innerText = departmentOptions[i].text;
break;
}
}
JSONArray types = new JSONArray();
for (Type type : Type.values()) {
JSONObject typeElement = new JSONObject();
try {
typeElement.put(type.toString(), type.getName());
types.put(typeElement);
} catch (JSONException e) {
e.printStackTrace();
}
}
putViewScope("types", types.toString());
@MessageRequired(type = MessageType.SAVE)
@Query("select count(state) from DeceasedState state where state.serviceTransaction.serviceCode =:serviceCode")
public Long findCountQueryCode(@Param("serviceCode") ServiceCode serviceCode);
import javax.faces.context.FacesContext;
public void onRowSelect(SelectEvent event) {
Semester semester = (Semester) event.getObject();
semester.setIndex(semester.getIndex() + 1);
putViewScope("semesterObject", semester);
initSemester();
}
private OrgChartNode orgChartNodeStateToOrgChart(Long nodeId, List orgChartNodeStates, OrgChart orgChart){
List newOrgChartNodeStates = new ArrayList();
OrgChartNode orgChartNode = orgChartNodeDao.findById(nodeId);
List childNodes = new ArrayList();
for(OrgChartNodeState nodeState : orgChartNodeStates){
System.out.println("循環ing...");
//OrgChartNodeState nodeState = orgChartNodeStates.get(0);
if(nodeState.getParentId().equals(nodeId)){
OrgChartNode node = new OrgChartNode();
if(nodeState.getDbNodeId().equals(new Long(-1))){
node = getNewNode(nodeState.getName());
Long curNodeId = nodeState.getId();
Long newNodeId = node.getId();
nodeState.setId(newNodeId);
nodeState.setDbNodeId(newNodeId);
orgChartNodeStates = updateOrgChartNodeStateParentId(
orgChartNodeStates, curNodeId, newNodeId);
}else{
node = orgChartNodeDao.findById(nodeState.getDbNodeId());
}
node.setOrgChart(orgChart);
node.setParent(orgChartNode);
node.setName(nodeState.getName());
node.setDepartment(departmentDao.findById(nodeState.getDepartmentId()));
node.setRole(orgChartRoleDao.findById(nodeState.getRoleId()));
node.setType(Type.valueOf(nodeState.getType()));
//orgChartNodeStates.remove(0);
//node = orgChartNodeStateToOrgChart(node.getId(), orgChartNodeStates);
childNodes.add(node);
}else{
newOrgChartNodeStates.add(nodeState);
}
}
orgChartNode.setChildren(childNodes.size()>0 ? childNodes: null);
for(OrgChartNode childNode : childNodes){
orgChartNodeStateToOrgChart(childNode.getId(), newOrgChartNodeStates, orgChart);
}
return orgChartNode;
}
function getSelectManyCheckboxVal(name){
var nameStr = "[name='" + name + "']:checked";
var nameVal = [];
$(nameStr).each(function(){
nameVal.push($(this).val());
});
return nameVal;
}
function setSelectManyCheckboxVal(name, values){
var nameStr = "[name='" + name + "']";
clearSelectManyCheckboxVal(name);
//set
$(nameStr).each(function(){
for(var i = 0; i < values.length; i++){
var boxVal = values[i];
if(boxVal == $(this).attr('value')){
$(this).parent().parent().children().eq(1).click();
}
}
});
}
function clearSelectManyCheckboxVal(name){
var nameStr = "[name='" + name + "']";
$(nameStr).each(function(){
if($(this).attr('checked') == "checked"){
$(this).parent().parent().children().eq(1).click();
}
});
}
http://stackoverflow.com/questions/20213248/render-pselectmanycheckbox-with-10-columns
public void initType() {
JSONArray types = new JSONArray();
for (Type type : Type.values()) {
JSONObject typeElement = new JSONObject();
try {
typeElement.put(type.toString(), type.getName());
types.put(typeElement);
} catch (JSONException e) {
e.printStackTrace();
}
}
putViewScope("types", types.toString());
}
MessageUtils.showFailedMessage("student.codeIsExist", FacesMessage.SEVERITY_ERROR);
RequestContextUtils.execute("_tutorialStudentInfoDlgForm_tutorialStudentInfoDlg_dialog.show();");
RequestContextUtils.execute("tutorialStudentInfoDlgCode.jq.addClass('ui-state-error')");
value="#{element.skipped == true ? msg['dms']['yes']: msg['dms']['no']}" />
<p:column headerText="#{msg['dms']['substitutionUser']}">
<ui:repeat var="user" varStatus="userStatus"
value="#{element.users}">
<p:outputPanel>
<h:outputText value="#{user.username}" rendered="#{userStatus.index==0}" />
<h:outputText value=" , #{user.username}" rendered="#{userStatus.index!=0}" />
p:outputPanel>
ui:repeat>
p:column>
或
<p:column headerText="#{msg['dms']['substitutionUser']}">
<c:forEach var="user" items="#{element.users}" varStatus="userStatus">
<h:outputText rendered="#{userStatus.index==0}"
value="#{user.username}" />
<h:outputText rendered="#{userStatus.index!=0}"
value=" , #{user.username}" />
c:forEach>
p:column>
style="display:#{(userStatus.index!=0) ? 'block' : 'none'};"
RequestContextUtils.execute("showOrgChart();");
后台操作更新前台
RequestContextUtils.update("pageTemplateListForm");
HolidayTable[] selectHolidayTables = new HolidayTable[1];
selectHolidayTables[0] = holidayTable;
substitutionTableChkIsSelect.check()
substitutionTableChkIsSelect.uncheck();
substitutionVar.checkSelection();
putViewScope("selectTutorialStudents",
new TutorialStudent[] { tutorialStudent });
value="#{viewScope.hasOtherRelationship}">
event="change"
update=":tutorialStudentInfoDlgForm:tutorialStudentInfoDlg:contentPanel"
listener="#{controller.otherRelationshipChange}" />
接收方法:
public void otherRelationshipChange(AjaxBehaviorEvent event){
Boolean value = ((SelectBooleanCheckbox)event.getSource()).isSelected();
System.out.println("value:" + value);
}
set var="search" value='"' />
set var="replace" value='\\"' />
out value="${fn:replace(userName, search, replace)}"/>
參考自:http://stackoverflow.com/questions/8898815/how-to-use-both-single-and-double-quotes-inside-jstl-el-expression
xmlns:fn="http://java.sun.com/jsp/jstl/functions"
set JAVA_OPTS=-Xms512m -Xmx1256m -XX:PermSize=128m -XX:MaxPermSize=256m
参考链接:https://www.mkyong.com/jsf2/4-ways-to-pass-parameter-from-jsf-page-to-backing-bean/
public void courseClassDatesDlgShow(ActionEvent event) {
Course course = (Course) event.getComponent().getAttributes()
.get("course");
}
value="#{msg['course']['showDate']}"
actionListener="#{controller.courseClassDatesDlgShow}"
update=":courseClassDatesForm"
oncomplete="courseClassDatesDlg.show()"
styleClass="table-toolbar-button" immediate="true">
"course" value="#{viewScope.course}" />
function datatableIsSelected(widgetVar) {
getDatatableSelectRow(widgetVar);
var status = widgetVar.checkSelection();
if (!status) {
alert("#{msg['framework']['selectRecordFirst']}!");
}
return status;
}
function datatableCheckDelete(widgetVar) {
var selected = datatableIsSelected(widgetVar);
if (selected){
return confirm("#{msg['framework']['confirmDelete']}?");
}
return selected;
}
function datatableOnlySelectOne(widgetVar) {
if(!datatableIsSelected(widgetVar)){
return false;
}
if(getDatatableSelectRow(widgetVar) != 1){
alert("#{msg['common']['canOnlySelectOneRecordOperation']}");
return false;
}
return true;
}
function getDatatableSelectRow(widgetVar) {
var chkboxSelectCount = 0;
var $This = widgetVar.jq;
$This.find(".ui-selection-column").each(function(){
var $uiChkbox = $(this).find(".ui-chkbox");
var isUiChkboxAll = $(this).find(".ui-chkbox").hasClass("ui-chkbox-all");
if(!isUiChkboxAll) {
if($uiChkbox.find(".ui-chkbox-box").hasClass("ui-state-active")){
chkboxSelectCount++;
}
}
});
return chkboxSelectCount;
}
"header">
value="#{msg['student']['poorSubjectSort']}" />
set var="search" value='"' />
set var="replace" value='' />
value="#{fn:replace(element.subject, search, replace)}" />
//
function showMessage(severity, content) {
var html = ';
$( '"#tutorialStudentInfoDlgForm\\:tutorialStudentInfoDlg\\:tutorialMessages").html(html);
}
//]]>
"tutorialMessages" showDetail="true" showSummary="false" />