This should work now. I'm not entirely certain it was being handled
correctly at the time you originally wrote this message but it works
now. An example to look at might be

http://opencomponentry.com:8080/timetracker/LocaleList.htm

On 11/24/06, Ron Piterman <[EMAIL PROTECTED]> wrote:
Hi all,
I have a simple For loop which iterates over some object.
the objects are all rendered to DirectLinks.
When a DirectLink-listener is called, the clicked Item should change to
"edit view" and render a Form instead of the Link.
When the form is submitted, the item should render again to the Link (
"view mode").

Now the question is, how to change the code below, to do the trick with
ajax.

When using normal http requests the page looks like this:

<html jwcid="@Shell" title="test">
  <body jwcid="@Body">
   <h1> try ajax with list </h1>
     <ul>
      <div
        jwcid="[EMAIL PROTECTED]" source="ognl:objects"
        value="ognl:currentObject">

        <li jwcid="[EMAIL PROTECTED]" element="li">
          <span jwcid="@If" condition="ognl:editMode">
            <form jwcid="@Form">
              <input jwcid="@TextField" value="ognl:editObject.name"/>
              <input jwcid="[EMAIL PROTECTED]" listener="listener:doSubmit"/>
              <input jwcid="[EMAIL PROTECTED]" listener="listener:doCancel"/>
            </form>
         </span>
         <span jwcid="@Else">
          <a jwcid="@DirectLink" listener="listener:edit"
                parameters="ognl:currentObject.id"
                >
            <span jwcid="@Insert" value="ognl:currentObject.name"></span>
          </a>
         </span>
        </li>
     </div>
    </ul>
  </body>
</html>

and the class:

public abstract class Home extends BasePage
{
     public Object getObjects() {
         // return the list of obejcts
     }

     /** the value of the current iteration */
     public abstract Value getCurrentObject();

     @Persist
     public abstract Value getEditObject();
     public abstract void setEditObject( Value v );

     public boolean isEditMode() {
         return getEditObject() != null &&
             getEditObject().equals( getCurrentObject() );
     }

     public void edit( Long id ) {
         setEditObject( getObject( id ) );
     }

     public void doSubmit() {
         // ... save ... and then
         this.setEditObject ( null );
     }

     public void doCancel() {
         this.setEditObject( null );
     }

     private Value getObject( Long id ) {
       // ... return the value for the given id
     }

}


Thanx in advance,
Cheers,
Ron


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--
Jesse Kuhnert
Tapestry/Dojo/(and a dash of TestNG), team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to