FYI - the missing # from the actionListener in
<x:commandButton id="updateButton"
actionListener="{categoryAdmin.update}" value="Update"
rendered="#{categoryAdmin.updateMode}"/>
was corrected as I was typing in a hurry. The problem still persists.
Thanks for any help. And I am using MyFaces 1.0.9. Using the latest
nightly snapshot did not resolve this issue either.
Gregg
On 8/11/05, Gregg D Bolinger <[EMAIL PROTECTED]> wrote:
> I'm not sure if this is an issue with MyFaces or with how I am doing
> what I am doing or what. I have a very simple page with a a
> dataTable. I am wanting to edit the data in the dataTable inline.
> That is to say, not navigating to a seperate page. I have it setup
> with an edit button for each item and when that button is pressed I
> render inputText components and an update button for the associated
> row. This works.
>
> The problem is that the update button's actionListener method binding
> isn't working. When I press the update button, nothing happens. The
> update(ActionEvent event) method is never called. It doesn't matter
> if the bean is in the session or request. It just doesn't call the
> method. I have stripped the code down to the simplest working example
> that demonstrates this problem which I will post below. As it is
> right now, I am merely showing and hiding the update/edit buttons.
> When I press Edit the edit method is being called and the update
> button is rendered where the edit button is now not rendered. If I
> hit update button, the update method is never called and the edit
> button is displayed again, hiding the update button. I realize that
> with each button press a new request is being sent to the server.
> However, it JSF is supposed to save the state of the bean for
> actionListeners since it does not navigate from the page. However, I
> don't believe this is working correctly. Any ideas? Thanks.
>
> <f:view>
> <html>
> <head><title>Simple jsp page</title></head>
> <body>
> <jsp:include page="includes/admin_header.jsp"/>
> <h:form>
> <x:dataTable var="cat" binding="#{categoryAdmin.categoryData}"
> value="#{categoryAdmin.categoryList}" border="1"
> forceIdIndex="#{cat.categoryId}" >
> <h:column>
> <f:facet name="header">
> <h:outputText value="Description" />
> </f:facet>
> <h:outputText value="#{cat.description}"/>
> </h:column>
> <h:column>
> <f:facet name="header">
> <h:outputText value="Cost"/>
> </f:facet>
> <h:outputText value="#{cat.cost}"/>
>
> </h:column>
> <h:column>
> <x:commandButton id="editButton"
> actionListener="#{categoryAdmin.edit}" value="Edit" rendered="#{not
> categoryAdmin.updateMode}" />
> <x:commandButton id="updateButton"
> actionListener="{categoryAdmin.update}" value="Update"
> rendered="#{categoryAdmin.updateMode}"/>
> </h:column>
> <h:column>
> <x:commandButton actionListener="#{categoryAdmin.delete}"
> value="Delete"/>
> </h:column>
> </x:dataTable>
> <f:verbatim><br/></f:verbatim>
>
> <h:panelGrid columns="2" border="1">
> <h:outputText value="Description"/>
> <h:inputText value="#{categoryAdmin.category.description}" />
> <h:outputText value="Cost"/>
> <h:inputText value="#{categoryAdmin.category.cost}"/>
> <h:commandButton actionListener="#{categoryAdmin.add}" value="Save"/>
> <h:commandButton actionListener="#{categoryAdmin.cancel}"
> value="Cance"/>
> </h:panelGrid>
>
>
> </h:form>
> </body>
> </html>
> </f:view>
>
> public class CategoryAdmin extends BaseBean implements Serializable {
>
> private List categoryList;
> private UIData categoryData;
> private boolean updateMode = false;
>
> private Category category;
>
> public List getCategoryList() {
> CategoryService catService =
> (CategoryService)getAppContext().getBean("categoryService");
> categoryList = catService.getall();
> return categoryList;
> }
>
> public void setCategoryList(List categoryList) {
>
> this.categoryList = categoryList;
> }
>
> public UIData getCategoryData() {
>
>
> return categoryData;
> }
>
>
>
> public void setCategoryData(UIData categoryData) {
> this.categoryData = categoryData;
> }
>
> public boolean isUpdateMode() {
> return updateMode;
> }
>
> public void setUpdateMode(boolean updateMode) {
> this.updateMode = updateMode;
> }
>
> public Category getCategory() {
> if (category == null){
> category = new Category();
> }
> return category;
> }
>
> public void setCategory(Category category) {
> this.category = category;
> }
>
> public void edit(ActionEvent event){
> System.out.println("Edit");
> category = (Category)categoryData.getRowData();
> category.setEditable(true);
> setUpdateMode(true);
> }
>
> public void update(ActionEvent event){
> System.out.println("Updating");
> }
>
>
>
> public void delete(ActionEvent event){
>
>
> CategoryService catService =
> (CategoryService)getAppContext().getBean("categoryService");
> Category cat = (Category)categoryData.getRowData();
> catService.delete(cat);
> setCategoryList(catService.getall());
>
>
> }
>
> public void add(ActionEvent event){
> System.out.println("Adding");
>
> CategoryService catService =
> (CategoryService)getAppContext().getBean("categoryService");
> catService.insert(getCategory());
>
> }
>
> public void cancel(ActionEvent event){
>
> }
>
> public void changeAddMode(ActionEvent event){
> System.out.println("Changing Add Mode");
>
> }
> }
>