a_cmslistdialog.java
来自「找了很久才找到到源代码」· Java 代码 · 共 1,116 行 · 第 1/3 页
JAVA
1,116 行
if ((getList() != null) && getList().getAllContent().isEmpty()) {
// TODO: check the need for this
refreshList();
}
StringBuffer result = new StringBuffer(2048);
result.append(defaultActionHtmlStart());
result.append(customHtmlStart());
result.append(defaultActionHtmlContent());
result.append(customHtmlEnd());
result.append(defaultActionHtmlEnd());
return result.toString();
}
/**
* Performs the dialog actions depending on the initialized action and displays the dialog form.<p>
*
* @throws JspException if dialog actions fail
* @throws IOException if writing to the JSP out fails, or in case of errros forwarding to the required result page
* @throws ServletException in case of errros forwarding to the required result page
*/
public void displayDialog() throws JspException, IOException, ServletException {
displayDialog(false);
}
/**
* Performs the dialog actions depending on the initialized action and displays the dialog form if needed.<p>
*
* @param writeLater if <code>true</code> no output is written,
* you have to call manually the <code>{@link #defaultActionHtml()}</code> method.
*
* @throws JspException if dialog actions fail
* @throws IOException if writing to the JSP out fails, or in case of errros forwarding to the required result page
* @throws ServletException in case of errros forwarding to the required result page
*/
public void displayDialog(boolean writeLater) throws JspException, IOException, ServletException {
actionDialog();
if (writeLater) {
return;
}
writeDialog();
}
/**
* This method execute the default actions for searching, sorting and paging.<p>
*/
public void executeDefaultActions() {
switch (getAction()) {
case ACTION_LIST_SEARCH:
executeSearch();
break;
case ACTION_LIST_SORT:
executeSort();
break;
case ACTION_LIST_SELECT_PAGE:
executeSelectPage();
break;
default:
//noop
}
listSave();
}
/**
* This method should handle the default list independent actions,
* by comparing <code>{@link #getParamListAction()}</code> with the id
* of the action to execute.<p>
*
* if you want to handle additional independent actions, override this method,
* handling your actions and FINALLY calling <code>super.executeListIndepActions();</code>.<p>
*/
public void executeListIndepActions() {
if (getList().getMetadata().getItemDetailDefinition(getParamListAction()) != null) {
// toogle item details
getList().getMetadata().toogleDetailState(getParamListAction());
// lazzy initialization
initializeDetail(getParamListAction());
}
listSave();
}
/**
* This method should handle every defined list multi action,
* by comparing <code>{@link #getParamListAction()}</code> with the id
* of the action to execute.<p>
*
* @throws IOException in case of errors when including a required sub-element
* @throws ServletException in case of errors when including a required sub-element
* @throws CmsRuntimeException to signal that an action is not supported
*/
public abstract void executeListMultiActions() throws IOException, ServletException, CmsRuntimeException;
/**
* This method should handle every defined list single action,
* by comparing <code>{@link #getParamListAction()}</code> with the id
* of the action to execute.<p>
*
* @throws IOException in case of errors when including a required sub-element
* @throws ServletException in case of errors when including a required sub-element
* @throws CmsRuntimeException to signal that an action is not supported
*/
public abstract void executeListSingleActions() throws IOException, ServletException, CmsRuntimeException;
/**
* Returns the list.<p>
*
* @return the list
*/
public CmsHtmlList getList() {
if ((m_list != null) && (m_list.getMetadata() == null)) {
m_list.setMetadata(getMetadata(getClass().getName(), m_list.getId()));
}
return m_list;
}
/**
* Returns the Id of the list.<p>
*
* @return the list Id
*/
public final String getListId() {
return m_listId;
}
/**
* Returns the form name.<p>
*
* @return the form name
*/
public String getParamFormName() {
return m_paramFormName;
}
/**
* Returns the List Action.<p>
*
* @return the List Action
*/
public String getParamListAction() {
return m_paramListAction;
}
/**
* Returns the current Page.<p>
*
* @return the current Page
*/
public String getParamPage() {
return m_paramPage;
}
/**
* Returns the Search Filter.<p>
*
* @return the Search Filter
*/
public String getParamSearchFilter() {
return m_paramSearchFilter;
}
/**
* Returns the Selected Items.<p>
*
* @return the Selelected Items
*/
public String getParamSelItems() {
return m_paramSelItems;
}
/**
* Returns the sorted Column.<p>
*
* @return the sorted Column
*/
public String getParamSortCol() {
return m_paramSortCol;
}
/**
* Returns the current selected item.<p>
*
* @return the current selected item
*/
public CmsListItem getSelectedItem() {
try {
return getList().getItem(
CmsStringUtil.splitAsArray(getParamSelItems(), CmsHtmlList.ITEM_SEPARATOR)[0].trim());
} catch (Exception e) {
try {
return getList().getItem("");
} catch (Exception e1) {
return null;
}
}
}
/**
* Returns a list of current selected items.<p>
*
* @return a list of current selected items
*/
public List getSelectedItems() {
Iterator it = CmsStringUtil.splitAsList(getParamSelItems(), CmsHtmlList.ITEM_SEPARATOR, true).iterator();
List items = new ArrayList();
while (it.hasNext()) {
String id = (String)it.next();
items.add(getList().getItem(id));
}
return items;
}
/**
* Returns the activation flag.<p>
*
* Useful for dialogs with several lists.<p>
*
* Is <code></code> if the original <code>formname</code> parameter
* is equals to <code>${listId}-form</code>.<p>
*
* @return the activation flag
*/
public boolean isActive() {
return m_active;
}
/**
* This method re-read the rows of the list, the user should call this method after executing an action
* that add or remove rows to the list.
*/
public synchronized void refreshList() {
if (getList() == null) {
return;
}
if (LOG.isDebugEnabled()) {
LOG.debug(Messages.get().getBundle().key(Messages.LOG_START_REFRESH_LIST_1, getListId()));
}
m_listState = getList().getState();
getList().clear();
fillList();
getList().setState(m_listState);
m_listState = null;
listSave();
if (LOG.isDebugEnabled()) {
LOG.debug(Messages.get().getBundle().key(Messages.LOG_END_REFRESH_LIST_1, getListId()));
}
}
/**
* Removes the list from the workplace settings.<p>
*
* Next time the list is displayed the list will be reloaded.<p>
*/
public void removeList() {
setList(null);
listSave();
}
/**
* Sets the list.<p>
*
* @param list the list to set
*/
public void setList(CmsHtmlList list) {
m_list = list;
}
/**
* Stores the given object as "list object" for the given list dialog in the current users session.<p>
*
* @param listDialog the list dialog class
* @param listObject the list to store
*/
public void setListObject(Class listDialog, CmsHtmlList listObject) {
if (listObject == null) {
// null object: remove the entry from the map
getListObjectMap(getSettings()).remove(listDialog.getName());
} else {
if ((listObject.getMetadata() != null) && listObject.getMetadata().isVolatile()) {
listObject.setMetadata(null);
}
getListObjectMap(getSettings()).put(listDialog.getName(), listObject);
}
}
/**
* Sets the form name.<p>
*
* @param formName the form name to set
*/
public void setParamFormName(String formName) {
m_paramFormName = formName;
}
/**
* Sets the List Action.<p>
*
* @param listAction the list Action to set
*/
public void setParamListAction(String listAction) {
m_paramListAction = listAction;
}
/**
* Sets the current Page.<p>
*
* @param page the current Page to set
*/
public void setParamPage(String page) {
m_paramPage = page;
}
/**
* Sets the Search Filter.<p>
*
* @param searchFilter the Search Filter to set
*/
public void setParamSearchFilter(String searchFilter) {
m_paramSearchFilter = searchFilter;
}
/**
* Sets the Selelected Items.<p>
*
* @param paramSelItems the Selelected Items to set
*/
public void setParamSelItems(String paramSelItems) {
m_paramSelItems = paramSelItems;
}
/**
* Sets the sorted Column.<p>
*
* @param sortCol the sorted Column to set
*/
public void setParamSortCol(String sortCol) {
m_paramSortCol = sortCol;
}
/**
* Writes the dialog html code, only if the <code>{@link #ACTION_DEFAULT}</code> is set.<p>
*
* @throws IOException if writing to the JSP out fails, or in case of errros forwarding to the required result page
*/
public void writeDialog() throws IOException {
if (isForwarded()) {
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?