I've been wrestling with the Dialog component all day with no useful 
results yet...

I have a For component iterating over some beans and I want an "Edit" 
button that pops up a dialog to edit the properties of that bean and then 
save and close the dialog. All the examples of Dialog I've seen on the 
site show the dialog initially visible, while I want it hidden, then shown 
and updated only when I click the "Edit" button.

The page loads fine with the dialog invisible, and when I first click on 
an edit link the dialog is displayed and the bean data loaded. Clicking 
the AjaxSubmit button in the dialog saves the data and hides the dialog; 
so far so good. However, if I now click on another edit button in the For 
loop I get the same dialog as I got before instead of getting a dialog 
with the new bean data in the fields.

More worryingly, bringing up a @DebugConsole shows me that the edit link 
DOES return the dialog with the second bean loaded, but I still get shown 
the initial dialog. I used Firefox's Web Developer Extension's "View 
Generated Source" feature and saw that the new dialog just gets appended 
to the document tree instead of replacing the previous one; it seems I get 
two elements with the same id now and dojo/tacos is showing the first one 
it finds, i.e. the initial one.

Is this a bug? Is there some way around it? When I submit a dialog, how 
can I get rid of it completely from the document tree? Am I going about 
this the right way?

My code, in a pinch:

<tr jwcid="@For" source="ognl:items"
        value="ognl:thisItem" index="ognl:thisItemIndex" element="tr">
        ...
        <span jwcid="@tacos:AjaxDirectLink"
                listener="listener:doEditItem"
                parameters="ognl:thisItemIndex"
                updateComponents="ognl:{'dialogEditItem'}">
                <img src="images/edit.gif"/>
        </span>
        ...
</tr>

and further down:

<div jwcid="[EMAIL PROTECTED]:Dialog" hidden=
"ognl:dialogEditItemHidden">
<div jwcid="@If" condition="ognl:editItemIndex != -1">
<form jwcid="@tacos:AjaxForm" listener="listener:doSaveItem" 
updateComponents="ognl:{'dialogEditItem'}" >
<input jwcid="@TextField" value="ognl:items[editItemIndex].instrumentId" 
/>
<input jwcid="@tacos:AjaxSubmit" value="Save Changes" />
</form>
</div>
</div>

In my page class:

        @Persist
        @InitialValue("ognl:-1")
        public abstract int getEditItemIndex();
        public abstract void setEditItemIndex(int index);
 
        @Persist
        @InitialValue("ognl:true")
        public abstract boolean getDialogEditItemHidden();
        public abstract void setDialogEditItemHidden(boolean hidden);

        public void doEditItem(int index) {
                setEditItemIndex(index);
                ((Dialog)getComponent("dialogEditItem")).show();
        }

        public void doSaveItem() {
                setEditItemIndex(-1);
                ((Dialog)getComponent("dialogEditItem")).hide();
        }


---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Tacos-devel mailing list
Tacos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tacos-devel

Reply via email to