I have written a portlet that runs in a controller (don't they all?) and one of
the things I'd like to do is have some html <input> from the controller post to
the Action class (of the controller or the portlet?) which in turn will update
the button state and then show me something different in the table (both within
 the Model class behind the portlet).  Here's a diagram:

+-----------------------------------------+
|  controller                             |
| [button1]   [button2]  [button3}        |
|                                         |
|       +---------------------------+     |
|       | portlet                   |     |
|       |                           |     |
|       |   +-----------+           |     |
|       |   | table     |           |     |
|       |   |           |           |     |
|       |   +-----------+           |     |
|       +---------------------------+     |
+-----------------------------------------+

+----------------+
| model class    |
| [button state] |
| [table data]   |
+----------------+

These are my problems:
1. When the user presses a button, I want to change the button image.  I do that
by having the controller action class (extends MultiColumnControllerAction) put
the button value in velocity context, then invoke super.buildNormalContext. 
This works but the controller doesn't automatically refresh unless the user
hits Control-R on the browser (or leaves the tab and comes back).  Here's the
java code for my custom multicolumn controller and the velocity macro:

controller action class:
public class BVMultiColumnControllerAction extends MultiColumnControllerAction {
    protected void buildNormalContext(PortletController controller,
    Context context,
    RunData rundata) {
        if (session == null) {
            session =
(BVSessionModel)rundata.getUserFromSession().getTemp("bvsession");
        }
                                  // returns "all" "received" or "placed"
        context.put("subtopbutton", session.bvact.getViewMode());
        logger.info("updated subtopbutton in context");
        super.buildNormalContext(controller, context, rundata);
    }
}

velocity snippet to display the "View Calls Placed" button's on/off state:
#if ($subtopbutton == "placed")
<input type="image" src="images/nav_buttons/secondary/view_calls_placed_on.gif"
#else
<input type="image" src="images/nav_buttons/secondary/view_calls_placed_off.gif"
#end
#* name="eventSubmit_doSetactivityview" value="placed"
action="controllers.BVMultiColumnControllerAction" *#
name="eventSubmit_doSetview" value="viewplaced"
action="portlets.BVActivityAction"
width="147" height="28" border="0">

2. The above velocity macro only works when I point "action=" at the portlet's
button event handler, but not the controller's.  I put a logger.info()
statement in the button event handler method of the controller action class,
but it never gets invoked. However, Turbine has no problem finding the
controller action class to paint the controller form.  I believe that it would
work properly if the controller's action class was responsible for updating the
button.

Are there any methods for portlet/controller interaction?  Can a portlet ask its
controller to refresh itself when a button is pressed in the portlet?

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to