0
作爲上述標題,我希望僅從登錄用戶獲取分離的數據。例如,同時或不同時,user1加載他/她自己的數據,而user2加載他/她自己的數據,這兩個用戶不共享相同的數據輸出。Openxava根據登錄用戶篩選數據
作爲上述標題,我希望僅從登錄用戶獲取分離的數據。例如,同時或不同時,user1加載他/她自己的數據,而user2加載他/她自己的數據,這兩個用戶不共享相同的數據輸出。Openxava根據登錄用戶篩選數據
下面的代碼是獲取url參數值和過濾用戶數據的解決方案。
Activity.java
...
@Hidden
@ReadOnly
@OnChange(GetParameterValueAction.class)
@Column(name="AKA_LOC_ID", length=10)
private String locId;
...
Getters and Setters
GetParameterValueAction.java
...
public class GetParameterValueAction extends OnChangePropertyBaseAction {
@Override
public void execute() throws Exception {
String locId = getRequest().getParameter("LocId");
getView().setValue("locId", locId);
}
}
OnEachRequestFilteredTabAction.java
...
public class OnEachRequestFilteredTabAction extends BaseAction{
@Inject @Named("application_locId")
private String locId;
@Inject
private Tab tab;
@Override
public void execute() throws Exception {
locId = getRequest().getParameter("LocId");
if (!Is.empty(locId)) tab.setBaseCondition("${locId}='" + locId + "'");
else tab.setBaseCondition("${locId}='ERROR'");
}
public String getLocId() {
return locId;
}
public void setLocId(String locId) {
this.locId = locId;
}
public Tab getTab() {
return tab;
}
public void setTab(Tab tab) {
this.tab = tab;
}
}
controllers.xml
<?xml version = "1.0" encoding = "ISO-8859-1"?>
<!DOCTYPE controllers SYSTEM "dtds/controllers.dtd">
<controllers>
<object name="application_locId" class="java.lang.String" scope="global"/>
<controller name="DataAccessControl">
<action name="initTab"
hidden="true"
on-each-request="true"
mode="list"
class="org.survey.actions.OnEachRequestFilteredTabAction" />
</controller>
</controllers>
application.xml
<?xml version = "1.0" encoding = "ISO-8859-1"?>
<!DOCTYPE application SYSTEM "dtds/application.dtd">
<application name="____"> //your application/folder name
<module name="Activity">
<model name="Activity"/>
<controller name="Activity"/>
<controller name="DataAccessControl"/>
</module>
</application>