cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple Actions?

mchernecki
Champ in-the-making
Champ in-the-making
Is it possible to configure multiple actions for a single action menu item? Currently, I have an href configured, but … A new requirement arose where I need to create a tmp xml file prior to launch my url in the href. Is it possible to run my java class or javascript prior to launch this URL? If I can't specifiy multiple actions, is it possible embed my current href action in a java class, allowing my to cretae my tmp xml file?


<config>
   <actions>
   <!– Launch Test Javascript Dialog –>
      <action id="test">
         <label>eReview Document</label>
         <image>/images/icons/ereview.gif</image>
            <tooltip>Launch in eReview</tooltip>
         <!– action>dialog:test</action –>
         <!– action-listener>#{BrowseBean.setupContentAction}</action-listener –>
            <href>http://127.0.0.1:8080/alfresco/template/workspace/SpacesStore/#{actionContext.id}/workspace/SpacesSt...</href>
            <target>new</target>
      </action>
      <!– Add action to more actions menu for each space –>
      <action-group id="document_browse_menu">
         <action idref="test" />
      </action-group>

   </actions>
</config>
4 REPLIES 4

frederick
Champ in-the-making
Champ in-the-making
You can't combine a HREF action with a regular action or an actionlistener, since these require the form to be submitted. A href is a request to a new page, so the form never gets submitted to the old page.

To achieve both, I suggest you use an actionlistener which does the required logic, then forwards to the external url using something like this:

//create temp xml

HttpServletResponse response = (HttpServletResponse)
  facesContext.getExternalContext().getResponse();
response.sendRedirect (url);
facesContext.responseComplete();

mchernecki
Champ in-the-making
Champ in-the-making
This may work, but I need to target a new window with my redirect. How can I target a new window HttpServletResponse?

frederick
Champ in-the-making
Champ in-the-making
Opening new windows is done by the browser on client side, eg. using Javascript. The HttpServletResponse object cannot do that.

Assuming your temp file must be created on the server side, you could consider adding an onclick script (<onclick>javascript:myhandler</onclick>) to the action that sends an AJAX request to the server to do the temp file creation.
Make the request synchronous so that the url is opened (in a new window) only when the request is complete.

But all this is getting rather complicated, just to get the page in a new window.

mchernecki
Champ in-the-making
Champ in-the-making
Thanks for the input Frederick. Although I didn't implement your suggestion, it made me think of this differently.  In the end I used only javascript, creating my xml files, then built my html template as a string and passing it as the return value of javascript. Then calling my javascript through the script command servlet on the current node.