cancel
Showing results for 
Search instead for 
Did you mean: 

commandButton on dialog

nyronian
Champ in-the-making
Champ in-the-making
I am building a new dialog screen thad uses the Dialog Framework.  Everything is going great untill I try to put on a commandButton or an actionLink.

If I do a command Button:

<h:commandButton id="addNewKeyword"  action="#{DialogManager.bean.addNewKeyword}" value="Create New"></h:commandButton>
I get the following html generated:

<input type="submit" onclick="if(typeof window.clearFormHiddenParams_dialog!='undefined'){clearFormHiddenParams_dialog('dialog');}" value="Add Existing" name="dialog:dialog-body:addExistingKeyword" id="dialog:dialog-body:addExistingKeyword"/>
If I create a new action Link:

<a:actionLink value="Remove Association" actionListener="#{DialogManager.bean.removeKeyword}"  >
   <f:param name="id" value="#{r.id }" />
</a:actionLink>

I get the following HTML generated:

<a id="_idJsp33" onclick="document.forms['dialog']['dialog:act'].value='dialog:dialog-body:_idJsp33';document.forms['dialog']['id'].value='e315ee20-b93c-102a-917a-00137266e2e6';document.forms['dialog'].submit();return false;" href="#">Remove Association</a>

When I click either, it does not call my assocated action.

any ideas?  How do I put a commandButton or actionLink on my Dialog page?  I searched through the framework documentation and it does not mention it.

Any help would be appreciated.

FYI:  I had to manually put in the code tags…the button on the editor seemed to do nothing.
7 REPLIES 7

gavinc
Champ in-the-making
Champ in-the-making
What does you dialog bean look like?

Are there any errors in the alfresco.log file?

nyronian
Champ in-the-making
Champ in-the-making
I have 2 buttons and 1 actionLink.  I will focus on 1 button since none of the 3 work.

I look like an idiot here because I have been 6 hours now trying to get a button to fire.

<h:commandButton id="addNewK"  actionListener="#{DialogManager.bean.addNewKeyword}" value="Create New"></h:commandButton> 

public class SiteTagManageBean extends BaseDialogBean implements IContextListener {
…   
public void addNewKeyword(final ActionEvent evt){
   logger.debug("addNewKeyword: "+newKeyword);
}

}


All the other binding are working.  I have several inputText, InputTextArea and a:RichList…all reading, fireing changes in the input, and reading again.  When the button is pushed, all the other binding fire and occur on the same Bean but no events.  I have researched tracing routines (FacesTrace v0.8.1) and phase listeners.  I can't find anything that will help me figure out why the events won't fire.  Also, the <a:sortLink on the richlist doesn't seem to work either…but that is the least of my worries.

What is also odd is the Ok and Cancel button provided by Dialog Framwork fire just fine.  I did an override on finish() and cancel() and they fire when those buttons are pushed. 

There are no errors on the console or in alfresco.log.  Everything looks normal.  Is there some tracing or debugging routine that will help me figure this out?  None of it makes sense.

I'm about to go into the looney bin….

nyronian
Champ in-the-making
Champ in-the-making
ok…i have spent some more time on this and found that I have other problems that could be related.  I have narrowed it down to a simple of modification creating bad (or no) behavior.

I have modified the space details navigation with the following in my web-client-config-custom.xml

  <config evaluator="node-type" condition="webc:website">
         <navigation>
            <override from-view-id="/jsp/dialog/space-details.jsp" to-view-id="/jsp/dialog/website-space-details.jsp" />
            <override from-outcome="showSpaceDetails" to-view-id="/jsp/dialog/website-space-details.jsp" />
            <override from-outcome="cancelEdit" to-view-id="/jsp/dialog/website-space-details.jsp" />
            <override from-outcome="finishEdit" to-view-id="/jsp/dialog/website-space-details.jsp" />
         </navigation>
      </config>

I created a new page that is an exact replicate of the current space-details.jsp and named it website-space-details.jsp and even placed it in the same jsp directory.

When I go to a node of type webc:website the proper page is pulled but some of the links do not work.  actually, to be simple, the only link button that works (not including the menu on the right, I didn't check those) is the Properties "Modify" icon.  The workflow, "Allow Categorization", rules, Custom View etc. do not work.  I just click and it seems to submit the page and come right back to it.  (Just like the problem I am having described above on a different dialog page.)

What am I doing wrong?  I should be able to modify have it navigate to my own spaces jsp right?  When I do, it simply breaks the page though…even though the page is an exact replica.  Can you duplicate the same problem?

gavinc
Champ in-the-making
Champ in-the-making
I think the problem with your button is your method signature, you have used the 'action' attribute which looks for a no-argument method, the 'actionListener' attribute looks for methods with the ActionEvent parameter. So, in your case your bean should be:


public class SiteTagManageBean extends BaseDialogBean implements IContextListener {
…  
public void addNewKeyword(){
   logger.debug("addNewKeyword: "+newKeyword);
}

}

As for the other problem you face, what version of Alfresco are you using? If it is not the latest 2.9x release then your problem is probably caused by navigation rules. If you look in faces-config-navigation.xml you'll see some references to space-details.jsp, all all likelihood you'll need to add some identical rules but for your custom page.

Hope that helps.

nyronian
Champ in-the-making
Champ in-the-making
Thank you for your reply Gavin.  The issue with the navigation on the space-details.jsp makes perfect sense.  I am on version 2.2.

The issue with the commandButton and the commandLink on my dialog, I have tried all such combinations.  What is odd is, if I misspell the method in my jsp tag, it throws an exception saying it can't find the method.  If I spell it right, it throws no exception but doesn't call the method.  What I understand is:

any element tied to action="xyz" should have a signiture
public String xyz(){ … }

any element tied to actionListener="xyz" should have a signiture
public void xyz(ActionEvent evt){ … }

I have tried both commandLinks and commandButtons.  This is a simple dialog page from the space-details.jsp.  I put a few buttons to call methods on my backing bean.  Again, the rest of the input fields on the page talk to the backing bean just fine.

Do I need to put in navigation rules for buttons on my dialog page?  Could that be why they don't fire at all?  Because the ok and cancel button fires (that are in the right hand side).  The buttons are not to navigate anywhere…just need them to call.  I must be missing something. 

I went ahead and put the following in my web-client-config under the <alfresco-config> tag but it did not change the behavior.

<alfresco-config>

   <navigation-rule>
         <from-view-id>/jsp/tlhc/wc/dialog/website-tags-dialog.jsp</from-view-id>
         <navigation-case>
            <from-outcome>cancel</from-outcome>
            <to-view-id>/jsp/tlhc/wc/dialog/website-space-details.jsp</to-view-id>
         </navigation-case>
         <navigation-case>
            <from-outcome>finish</from-outcome>
            <to-view-id>/jsp/tlhc/wc/dialog/website-space-details.jsp</to-view-id>
         </navigation-case>
      </navigation-rule>

<alfresco-config>

nyronian
Champ in-the-making
Champ in-the-making
Oh my #$&*(@#@#$*()  I figured out what was wrong….

I had the jsp tag within an <f:verbatim> tag.  I did not close the verbatim tag before starting the jsp tag.  I am still stumped why the behavior was as it was but once I closed the verbatim tag everything worked….I guess now I know. 

I would expect different behavior of a jsp tag within a verbatim tag.  It's so odd to me that it would render the tag, recognize when the action or actionListener was trying to call the wrong method (meaning a method that doesn't exist) but do nothing for the right method name.  Maybe someone out there can explain why I was getting this behavior. 

Thanks again for your time.

gavinc
Champ in-the-making
Champ in-the-making
I'm glad you got it working.

Unfortunately this is one of the problems with JSF when you do things wrong it's not obvious what or why!

I'm guessing that as the jsp tag was within the verbatim tag it was rendered to the client but the component for the link or button would not have been added to the server side component tree. Thus when the link was clicked JSF would not have found the component in the tree, in these sort of scenarios JSF just refreshes the same page, which sometimes gives the appearance that it's actually working!

Just to confirm, your thinking about the signatures relating to 'action' and 'actionListener' are correct.