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]

Reply via email to