I will try your code and give you a sample later. I have similar stuff instead my first form is using onchange event when selection changes (there is no submit button), it works perfectly.
You can go back to the requesting view by using action and just return null. Emily -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Craig McClanahan Sent: Monday, February 06, 2006 6:44 PM To: Struts Users Mailing List Subject: Re: [Shale] a command btn within a conditionally "rendered" form not getting actionListener. On 2/6/06, Jason Vincent <[EMAIL PROTECTED]> wrote: > > hmm... ok I tried your suggestion, but it still no worky. I even just > had the action="home" and that didn't work either, instead of > evaluating some expression to call. > > It is my understanding that the only difference between actionListener > and action is that an action call will make use of the navigation > mapping, while the actionListener will just go back to the requesting > view. The action listener also receives an ActionEvent, but you're correct that it cannot feed an outcome directly into the navigation system. You can, however, fake it by doing something like this: NavigationHandler nh = context.getApplication().getNavigationHandler(); String outcome = "..."; // Some outcome string to pretend occurred String action = "#{...}"; // Some action to pretend was called (this would // normally be the expression for the "action" attribute nh.handleNavigation(context, action, outcome); context.renderResponse(); Could the "rendered" attribute be throwing something off? If the button is not rendered (rendered="false") then it won't be able to fire any actions, but that doesn't appear to be the case in your sample code. Just out of curiousity, is there a particular reason you want to use an actionListener instead of an action? The latter is generally easier to deal with. Is there a way for me to see the phases that the JSF lifecycle is > going through? Perhaps that can point to the problem area. One way would be to create a simple phase listener class that listens to all phases, and logs the "before" and "after" events: public class DebugPhaseListener implements PhaseListener { public static final Log LOGGER = LogFactory.getLog(DebugPhaseListener.class); public PhaseId getPhaseId() { return PhaseId.ANY_PHASE; } public void beforePhase(PhaseEvent event) { LOGGER.debug("beforePhase(" + event.getPhaseId() + ")"); } public void afterPhase(PhaseEvent event) { LOGGER.debug("afterPhase(" + event.getPhaseId() + ")"); } } Register this in a faces-config.xml file like this: <lifecycle> <phase-listener>com.mycompany.mypackage.DebugPhaseListener </phase-listener> </lifecycle> The clue you are looking for is if Invoke Application is reached. That's where actions are invoked (assuming immediate is not set). If that phase is being skipped, it'll likely be: * A validation error * An exception during update model values * Some other code that called FacesContext.renderResponse() to proceed directly to the rendering phase Craig The scopes of all my objects are request, and the Faces Context is > stored on the Server. > > Thanks a bunch, > Jason > > > > On 2/6/06, Emily Gu (egu) <[EMAIL PROTECTED]> wrote: > > Don't use actionListener but just simply use action. All you want > > should be working as expected. > > > > <h:commandButton > > action="#{pulldownTest.handleChangeItem}" value="Submit"/> > > > > public String handleChangeItem() { > > LOGGER.debug("handleChangeItem()"); > > return "success"; > > } > > > > Emily > > > > > > -----Original Message----- > > From: Jason Vincent [mailto:[EMAIL PROTECTED] > > Sent: Monday, February 06, 2006 4:14 PM > > To: Struts Users Mailing List > > Subject: Re: [Shale] a command btn within a conditionally "rendered" > > form not getting actionListener. > > > > I put the messages tag in there, but I'm getting nothing from that tag. > > > > I've witnessed JSF swallowing exceptions before. Is there a way to > > get JSF to log the stacktraces to my logger? > > > > I've really simplified my test case and I'm still seeing the problem. > > I have a pull down at the top with a submit btn. > > When the submit button is clicked, it called the actionListener as > > expected. The page is rerendered with the second part of the page > > showing the item selected with another button. When the 2nd button > > is clicked, no actionListener is called. > > > > Here is the sample code: > > > > public class PulldownTest { > > private static final Log LOGGER = > > LogFactory.getLog(PulldownTest.class); > > > > private String selectedFilterValue; > > > > public SelectItem[] getFilterPulldown() { > > SelectItem[] items = new SelectItem[3]; > > items[0] = new SelectItem("",""); > > items[1] = new SelectItem("1","1"); > > items[2] = new SelectItem("2","2"); > > return items; > > } > > > > > > public String getSelectedFilterValue() { > > return selectedFilterValue; > > } > > > > public void setSelectedFilterValue(String selectedFilterValue) { > > this.selectedFilterValue = selectedFilterValue; > > } > > > > public boolean isItemSelected() { > > boolean isItemSelected = null != selectedFilterValue && > > !"".equals(selectedFilterValue); > > LOGGER.debug("isItemSelected="+isItemSelected); > > return isItemSelected; > > } > > > > public void handleSelectItem(ActionEvent event) { > > LOGGER.debug("handleSelectItem()"); > > } > > > > public void handleChangeItem(ActionEvent event) { > > LOGGER.debug("handleChangeItem()"); > > } > > > > > > > > } > > > > > > Here is the JSP: > > > > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" > > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> > > <%@ page contentType="text/html;charset=UTF-8" language="java" %> > > <%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %> <%@ > > taglib prefix="h" uri="http://java.sun.com/jsf/html" %> > > > > <f:loadBundle var="messages" basename="Messages"/> <META > > HTTP-EQUIV="Pragma" CONTENT="no-cache"/> <META HTTP-EQUIV="Expires" > > CONTENT="-1"/> <f:view> > > <html xmlns="http://www.w3.org/1999/xhtml"> > > <body> > > <h:form> > > <h:messages/> > > <h:outputText value="Choose Item:"/> > > <h:selectOneMenu id="spPlat" > > value="#{pulldownTest.selectedFilterValue}"> > > <f:selectItems > > value="#{pulldownTest.filterPulldown}"/> > > </h:selectOneMenu> > > <h:commandButton > > actionListener="#{pulldownTest.handleSelectItem}" value="Submit"/> > > <h:panelGrid columns="1" > > rendered="#{pulldownTest.itemSelected}"> > > <h:outputText value="Item Selected = > > #{pulldownTest.selectedFilterValue}"/> > > <h:commandButton > > actionListener="#{pulldownTest.handleChangeItem}" value="Submit"/> > > </h:panelGrid> > > > > </h:form> > > </body> > > </html> > > </f:view> > > > > > > Any futher help is greatly appreciated. > > Jason > > > > > > > > > > > > On 2/5/06, Craig McClanahan <[EMAIL PROTECTED]> wrote: > > > On 2/5/06, Jason Vincent <[EMAIL PROTECTED]> wrote: > > > > > > > > Hi all, > > > > > > > > For some reason a cmd btn of mine isn't calling its > > > > actionListener method when it is clicked. > > > > > > > > Here is the situation. I have a pull down at the top of my page > > > > which chooses the item that I want to edit below. I hit the > > > > submit button next to the pulldown, and the second half of the > > > > page is rendered. I used the rendered attribute on the table > > > > containing the > > > > > > rest of the form. > > > > > > > > So when I change a few items in the second half, I hit an update > > > > submit button to save the changes and POOF... nothing - the page > > > > just refreshes. the actionListener is never called. Infact no > > > > action or action listener. > > > > > > > > Why isn't the action listener called? > > > > > > > > I've also tried having two forms on the page, where the second > > > > form had a hidden field of the selected item of the first form. > > > > This would help the situation where the user changes the > > > > selected item in > > > > > > the filter form, but also has made changes to the previously > > > > viewed > > item. > > > > I'd want to make sure the changes goto the right item. When I > > > > tried > > > > > > this, for some reason the getter methods to retrieve the items > > > > data was called before the set method for the hidden field was > > > > called which gave me NPE's since the item to get the data from > > > > hadn't been loaded yet - which is what the set method of the > > > > hidden field would have done. > > > > > > > > Is there a way to control the ordering of which UI objects are > > > > processed first? I tried the immediate attribute of the hidden > > > > field to get that to go first, but it did nothing. > > > > > > > > BTW, for the 2 form scenario, when I got the NPE's I would hit > > > > the back button to go back to the form, it is then that I would > > > > notice that it would call my update Information eventListener method. arg. > > > > > > > > What is going on here? > > > > > > > > > Roughly 99% of the time :-), this sort of thing is caused by a > > > validation error occurring, which causes the call to your action > > > to be > > > > > skipped and the page rerendered. Stick a <h:messages> component > > > on the page and any such messages should show up. > > > > > > Thanks, > > > > Jason > > > > > > > > > Craig > > > > > > > > > > -------------------------------------------------------------------- > > - To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > -------------------------------------------------------------------- > > - To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]