title: Confirmation dialog in a portlet
body: <p>I am trying to implement a confirmation dialog in a Liferay portlet which shall be shown when user clicks on a link triggering <strong>actionRequest</strong>.</p>
  
  <p>However, it seems that the portlet container does not have GUI, so I am getting <code>java.awt.HeadlessException</code></p>
  
  <p>This is the part relevant to my <strong>JSP</strong> page:</p>
  
  <pre><code>&lt;li&gt;&lt;a href="&lt;%=deleteDatabase%&gt;"&gt;Delete messages from database&lt;/a&gt;&lt;/li&gt;
  
  &lt;portlet:actionURL var="deleteDatabase" name="deleteDatabase"&gt;
      &lt;/portlet:actionURL&gt;
  </code></pre>
  
  <p><strong>Java</strong> portlet class:</p>
  
  <pre><code>public void deleteDatabase(final ActionRequest actionRequest,
              final ActionResponse actionResponse) throws IOException,
              PortletException {
  
          int dialogResult = JOptionPane.showConfirmDialog(null,
                  "Would You Like to delete all messages?", "Warning",
                  JOptionPane.YES_NO_OPTION);
          if (dialogResult == JOptionPane.YES_OPTION) {
              // do some stuff here
          }
  
      }
  </code></pre>
  
  <p>Perhaps I shoulw not try to implement the dialog inside java but move it to the JSP and use javascript or I should do it some other way... Could be please give me a hint how to solve this exception in Java or show me an example code that would work with the actionURL? Thanks a lot for any help!</p>