Hi. I have a module that loads a list of customers that have NOT been invoiced. This is the default tab defined for the Customer entity (the base condition for this tab returns records where invoiced=0). I have a controller for this module defined called "invoiced", which displays an "Invoiced" button at the bottom of the list view. When the "Invoiced" button is clicked, the defined action reloads the same module and sets the Tab to an "Invoiced" tab I have defined in the Customer entity with a base condition filters the list to show only invoiced customers (invoiced=1). This works fine, but what I would like to do is change the controller for this invoiced view to have a button that says "Non-Invoiced" which will execute an action to return the user back to the default view that shows non-invoiced customers. Below is the code for the Action that executes when the "Invoiced" button is clicked. This works fine after the initial loading of the module with non-invoiced customers. When the user clicks the "Invoiced" button, the module reloads displaying only invoiced customers. I need to add a controller that I can use to switch back to the default.
public class InvoicedCustomersAction extends BaseAction
implements IChangeModuleAction,
IModuleContextAction {
@Inject
private Tab tab;
private ModuleContext context;
public void execute() throws Exception {
Tab customerTab = (tab);
context.get("Customers",getNextModule(),"xava_tab");
customerTab.setTabName("Invoiced");
customerTab.setBaseCondition("${invoiced}=1");
}
public Tab getTab() {
return tab;
}
public void setTab(Tab tab) {
this.tab = tab;
}
public ModuleContext getContext() {
return context;
}
public void setContext(ModuleContext context) {
this.context = context;
}
@Override
public String getNextModule() {
return null;
}
@Override
public boolean hasReinitNextModule() {
return false;
}
}
I have been following the OpenXava book, Chapter 10, section 10.4 and the Calling Another Module section on the wiki.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I realize a simple work-around is to just have two actions for the Customer module's controller, with one button to display "invoiced" customers and a second to display "non-invoiced." I was hoping to have just one button displayed that toggles between "invoiced" and "non-invoiced", but having the two buttons is fine.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi. I have a module that loads a list of customers that have NOT been invoiced. This is the default tab defined for the Customer entity (the base condition for this tab returns records where invoiced=0). I have a controller for this module defined called "invoiced", which displays an "Invoiced" button at the bottom of the list view. When the "Invoiced" button is clicked, the defined action reloads the same module and sets the Tab to an "Invoiced" tab I have defined in the Customer entity with a base condition filters the list to show only invoiced customers (invoiced=1). This works fine, but what I would like to do is change the controller for this invoiced view to have a button that says "Non-Invoiced" which will execute an action to return the user back to the default view that shows non-invoiced customers. Below is the code for the Action that executes when the "Invoiced" button is clicked. This works fine after the initial loading of the module with non-invoiced customers. When the user clicks the "Invoiced" button, the module reloads displaying only invoiced customers. I need to add a controller that I can use to switch back to the default.
I have been following the OpenXava book, Chapter 10, section 10.4 and the Calling Another Module section on the wiki.
I realize a simple work-around is to just have two actions for the Customer module's controller, with one button to display "invoiced" customers and a second to display "non-invoiced." I was hoping to have just one button displayed that toggles between "invoiced" and "non-invoiced", but having the two buttons is fine.
Hi Sean,
from your action code you can remove and add action programatically. In this way:
Help others in this forum as I help you.