Korrektur für ein Problem mit dem ItemSearchWidget und dem persitenten Status von Bebop
git-svn-id: https://svn.libreccm.org/ccm/trunk@2367 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
26670344e3
commit
8f32e2fa15
|
|
@ -31,6 +31,7 @@ import com.arsdigita.bebop.table.TableColumn;
|
|||
import com.arsdigita.bebop.table.TableColumnModel;
|
||||
import com.arsdigita.bebop.table.TableModel;
|
||||
import com.arsdigita.bebop.table.TableModelBuilder;
|
||||
import com.arsdigita.cms.CMS;
|
||||
import com.arsdigita.cms.ContentSection;
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.RelationAttributeCollection;
|
||||
|
|
@ -70,7 +71,7 @@ public class GenericOrganizationalUnitPersonsTable extends Table implements
|
|||
this.personSelector = personSelector;
|
||||
|
||||
setEmptyView(new Label(ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.genericorgaunit.persons.none")));
|
||||
"cms.contenttypes.ui.genericorgaunit.persons.none")));
|
||||
TableColumnModel tabModel = getColumnModel();
|
||||
|
||||
tabModel.add(new TableColumn(
|
||||
|
|
@ -84,21 +85,21 @@ public class GenericOrganizationalUnitPersonsTable extends Table implements
|
|||
"cms.contenttypes.ui.genericorgaunit.persons.role")));
|
||||
tabModel.add(
|
||||
new TableColumn(
|
||||
2,
|
||||
ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.genericorgaunit.persons.status")));
|
||||
2,
|
||||
ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.genericorgaunit.persons.status")));
|
||||
tabModel.add(
|
||||
new TableColumn(
|
||||
3,
|
||||
ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.genericorganunit.persons.edit"),
|
||||
TABLE_COL_EDIT_LINK));
|
||||
3,
|
||||
ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.genericorganunit.persons.edit"),
|
||||
TABLE_COL_EDIT_LINK));
|
||||
tabModel.add(
|
||||
new TableColumn(
|
||||
4,
|
||||
ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.genericorgaunit.persons.delete"),
|
||||
TABLE_COL_DEL));
|
||||
4,
|
||||
ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.genericorgaunit.persons.delete"),
|
||||
TABLE_COL_DEL));
|
||||
|
||||
setModelBuilder(
|
||||
new GenericOrganizationalUnitTableModelBuilder(itemModel));
|
||||
|
|
@ -123,13 +124,13 @@ public class GenericOrganizationalUnitPersonsTable extends Table implements
|
|||
|
||||
public TableModel makeModel(Table table, PageState state) {
|
||||
table.getRowSelectionModel().clearSelection(state);
|
||||
GenericOrganizationalUnit orgaunit =
|
||||
(GenericOrganizationalUnit) m_itemModel.
|
||||
GenericOrganizationalUnit orgaunit = (GenericOrganizationalUnit) m_itemModel.
|
||||
getSelectedObject(state);
|
||||
return new GenericOrganizationalUnitTableModel(table,
|
||||
state,
|
||||
orgaunit);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class GenericOrganizationalUnitTableModel implements TableModel {
|
||||
|
|
@ -210,6 +211,7 @@ public class GenericOrganizationalUnitPersonsTable extends Table implements
|
|||
public Object getKeyAt(int columnIndex) {
|
||||
return m_person.getID();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class EditCellRenderer extends LockableImpl implements
|
||||
|
|
@ -223,11 +225,10 @@ public class GenericOrganizationalUnitPersonsTable extends Table implements
|
|||
Object key,
|
||||
int row,
|
||||
int col) {
|
||||
com.arsdigita.cms.SecurityManager securityManager = Utilities.
|
||||
getSecurityManager(state);
|
||||
com.arsdigita.cms.SecurityManager securityManager = CMS.getSecurityManager(state);
|
||||
GenericOrganizationalUnit orgaunit = (GenericOrganizationalUnit) m_itemModel.
|
||||
getSelectedObject(
|
||||
state);
|
||||
state);
|
||||
|
||||
boolean canEdit = securityManager.canAccess(state.getRequest(),
|
||||
com.arsdigita.cms.SecurityManager.EDIT_ITEM,
|
||||
|
|
@ -244,17 +245,16 @@ public class GenericOrganizationalUnitPersonsTable extends Table implements
|
|||
}
|
||||
ContentSection section = person.getContentSection();//CMS.getContext().getContentSection();
|
||||
ItemResolver resolver = section.getItemResolver();
|
||||
Link link =
|
||||
new Link(String.format("%s",
|
||||
value.toString()),
|
||||
resolver.generateItemURL(state,
|
||||
person,
|
||||
section,
|
||||
person.getVersion()));
|
||||
Link link = new Link(String.format("%s",
|
||||
value.toString()),
|
||||
resolver.generateItemURL(state,
|
||||
person,
|
||||
section,
|
||||
person.getVersion()));
|
||||
|
||||
return link;
|
||||
} else {
|
||||
GenericPerson person;
|
||||
GenericPerson person;
|
||||
try {
|
||||
person = new GenericPerson((BigDecimal) key);
|
||||
} catch (DataObjectNotFoundException ex) {
|
||||
|
|
@ -271,6 +271,7 @@ public class GenericOrganizationalUnitPersonsTable extends Table implements
|
|||
return label;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class EditLinkCellRenderer
|
||||
|
|
@ -284,8 +285,7 @@ public class GenericOrganizationalUnitPersonsTable extends Table implements
|
|||
Object key,
|
||||
int row,
|
||||
int column) {
|
||||
SecurityManager securityManager =
|
||||
Utilities.getSecurityManager(state);
|
||||
SecurityManager securityManager = CMS.getSecurityManager(state);
|
||||
GenericOrganizationalUnit orgaUnit = (GenericOrganizationalUnit) m_itemModel.
|
||||
getSelectedObject(state);
|
||||
|
||||
|
|
@ -301,6 +301,7 @@ public class GenericOrganizationalUnitPersonsTable extends Table implements
|
|||
return label;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class DeleteCellRenderer extends LockableImpl implements
|
||||
|
|
@ -314,11 +315,10 @@ public class GenericOrganizationalUnitPersonsTable extends Table implements
|
|||
Object key,
|
||||
int row,
|
||||
int col) {
|
||||
SecurityManager securityManager =
|
||||
Utilities.getSecurityManager(state);
|
||||
SecurityManager securityManager = Utilities.getSecurityManager(state);
|
||||
GenericOrganizationalUnit orgaunit = (GenericOrganizationalUnit) m_itemModel.
|
||||
getSelectedObject(
|
||||
state);
|
||||
state);
|
||||
|
||||
boolean canEdit = securityManager.canAccess(state.getRequest(),
|
||||
SecurityManager.DELETE_ITEM,
|
||||
|
|
@ -327,13 +327,14 @@ public class GenericOrganizationalUnitPersonsTable extends Table implements
|
|||
ControlLink link = new ControlLink(value.toString());
|
||||
link.setConfirmation((String) ContenttypesGlobalizationUtil.
|
||||
globalize(
|
||||
"cms.contenttypes.ui.genericorgaunit.persons.confirm_delete").
|
||||
"cms.contenttypes.ui.genericorgaunit.persons.confirm_delete").
|
||||
localize());
|
||||
return link;
|
||||
} else {
|
||||
return new Label(value.toString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -380,7 +381,6 @@ public class GenericOrganizationalUnitPersonsTable extends Table implements
|
|||
public void headSelected(TableActionEvent event) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected String getRoleAttributeName() {
|
||||
|
|
@ -390,4 +390,5 @@ public class GenericOrganizationalUnitPersonsTable extends Table implements
|
|||
protected String getStatusAttributeName() {
|
||||
return "GenericOrganizationalUnitMemberStatus";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,7 +58,8 @@ public class ItemSearchFlatBrowsePane extends SimpleContainer {
|
|||
private final Table resultsTable;
|
||||
private final Paginator paginator;
|
||||
private final StringParameter queryParam;
|
||||
private final List<String> queryFields = new ArrayList<String>();
|
||||
private final QueryFieldsRequestLocal queryFields = new QueryFieldsRequestLocal();
|
||||
//private final List<String> queryFields = new ArrayList<String>();
|
||||
//private final Submit submit;
|
||||
private final static CMSConfig CMS_CONFIG = CMSConfig.getInstance();
|
||||
|
||||
|
|
@ -130,7 +131,11 @@ public class ItemSearchFlatBrowsePane extends SimpleContainer {
|
|||
// }
|
||||
|
||||
public void addQueryField(final String queryField) {
|
||||
queryFields.add(queryField);
|
||||
queryFields.addQueryField(queryField);
|
||||
}
|
||||
|
||||
void resetQueryFields() {
|
||||
queryFields.reset();
|
||||
}
|
||||
|
||||
private class ResultsTable extends Table {
|
||||
|
|
@ -216,7 +221,7 @@ public class ItemSearchFlatBrowsePane extends SimpleContainer {
|
|||
"((lower(%s) like lower('%%%s%%')) or (lower(%s) like lower('%%%s%%'))",
|
||||
ContentItem.NAME, query,
|
||||
ContentPage.TITLE, query));
|
||||
for (String field : queryFields) {
|
||||
for (String field : queryFields.getQueryFields()) {
|
||||
buffer.append(String.
|
||||
format(" or (lower(%s) like lower('%%%s%%'))", field, query));
|
||||
}
|
||||
|
|
@ -395,4 +400,30 @@ public class ItemSearchFlatBrowsePane extends SimpleContainer {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
private class QueryFieldsRequestLocal extends RequestLocal {
|
||||
|
||||
private List<String> queryFields = new ArrayList<String>();
|
||||
|
||||
@Override
|
||||
protected Object initialValue(final PageState state) {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
|
||||
public List<String> getQueryFields() {
|
||||
return queryFields;
|
||||
}
|
||||
|
||||
public void setQueryFields(final List<String> queryFields) {
|
||||
this.queryFields = queryFields;
|
||||
}
|
||||
|
||||
public void addQueryField(final String queryField) {
|
||||
queryFields.add(queryField);
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
queryFields = new ArrayList<String>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -137,7 +137,10 @@ public class ItemSearchPage extends CMSPage {
|
|||
m_create.setEditAfterCreate((Boolean) state.getValue(new BooleanParameter("editAfterCreate")));
|
||||
}
|
||||
|
||||
if (state.getValue(new StringParameter("queryField")) != null) {
|
||||
if (state.getValue(new StringParameter("queryField")) == null) {
|
||||
//Because of Bebops silly stateful behaviour we have to do this...
|
||||
m_flatBrowse.resetQueryFields();
|
||||
}else {
|
||||
m_flatBrowse.addQueryField((String) state.getValue(new StringParameter("queryField")));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue