As the title above, I wish to get seperated data from logged in user only. For instance, in either simultaneously or non-simultaneously, user1 loads his/her own data while user2 loads his/her own data, which both users do not share the same data output.
The codes below are the solution for getting url parameter value and filtering user data.
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>