Hello all,
I'm having serious client side persistence problems. I have a border
component which has a property selection component. From there I can
select which page I want to goto, by default the home page is shown.

If I select a new page then the property selection does not show the
new page, but the main body of the page shows the selected page.

Obviously there is something I don't understand regarding client side
persistence.
I have included the source for a test web application I wrote. Does
any body have any suggestions?

--
Thanks

Jabbar Azam

//-- start of source code
---------------------------------------------------------------------------------------------------

Border.java
----------------
package com.technolog.page;

import org.apache.tapestry.BaseComponent;
import org.apache.tapestry.IRequestCycle;
import org.apache.tapestry.annotations.Persist;
import org.apache.tapestry.event.PageBeginRenderListener;
import org.apache.tapestry.event.PageEvent;

import com.technolog.model.PageSelectionModel;

/**
 * This the parent component of all the other web pages.  Every web
page is placed
 * within this page.  This allows the header, footer and navigation to
be modified
 * without changing every page.
 *
 * @author Jabbar Azam
 *
 */
public abstract class Border extends BaseComponent implements
PageBeginRenderListener{

    @Persist("client:app")
    public abstract String getPerSelectedPage();
    public abstract void setPerSelectedPage(String page);

    public abstract String getSelectedPage();
    public abstract void setSelectedPage(String page);

    public void selectedPage(IRequestCycle cycle) {
        setPerSelectedPage(getSelectedPage());
        cycle.activate(getSelectedPage());
    }

    public PageSelectionModel getPageSelectionModel() {

        return new PageSelectionModel();
    }

    public void pageBeginRender(PageEvent event) {
        if (!event.getRequestCycle().isRewinding()) {
            setSelectedPage(getPerSelectedPage());
        }
    }

}

---------------------------------------------------------------------------------------
PageSelectionModel.java
------------------------------------

package com.technolog.model;

import java.io.Serializable;
import java.util.List;
import java.util.Vector;

import org.apache.tapestry.form.IPropertySelectionModel;


public class PageSelectionModel implements IPropertySelectionModel,
Serializable {

    /**
     *
     */
    private static final long serialVersionUID = 5195300859295677036L;
    protected List<String> pageList = new Vector<String>();

    /**
     *
     * @param siteListDAO
     * @param user
     */
    public PageSelectionModel() {

      pageList.add("Home");
      pageList.add("Page1");
      pageList.add("Page2");
      pageList.add("Page3");


    }
    /**
     *
     */
    public int getOptionCount() {
        return pageList.size();
    }
    /**
     *
     */
    public Object getOption(int idx) {
        return pageList.get(idx);
    }

    /**
     *
     */
    public String getValue(int idx) {
        return Integer.toString(idx);
    }

    /**
     *
     */
    public Object translateValue(String idx) {
        return getOption(Integer.parseInt(idx));
    }

    public String getLabel(int idx) {
        return (String)getOption(idx);
    }

}


--------------------------------------------------------------------------------------------------------

Border.html
-----------------
<html>
<head jwcid="@Shell" title="test">
<title>Test</title>
</head>

<body jwcid="@Body">

  <table>
  <form jwcid="@Form" listener="listener:selectedPage"><tr><td><span
jwcid="pageSelection"/></td></tr></form>
  <tr><td><span jwcid="@RenderBody"/></td></tr>

  </table>

</body>
</html>

--------------------------------------------------------------------------------------------------------------

Border.jwc
---------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE component-specification
      PUBLIC "-//Apache Software Foundation//Tapestry Specification 4.0//EN"
      "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd";>
<!-- generated by Spindle, http://spindle.sourceforge.net -->

<component-specification class="com.technolog.page.Border"
allow-informal-parameters="no">
        
        <component id="pageSelection" type="PropertySelection">
                <binding name="model" value="pageSelectionModel"/>
                <binding name="value" value="selectedPage"/>
                <binding name="submitOnChange" value="literal:yes"/>
        </component>    
</component-specification>

-------------------------------------------------------------------------------------------------------------

Home.html
----------------
<span jwcid="$content$">
<span jwcid="@Border">
<h1>Home Page</h1>
</span>
</span>
--------------------------------------------------------------------------------------------------------------

Page1.html
-----------------
<span jwcid="$content$">
<span jwcid="@Border">
<h1>Page 1</h1>
</span>
</span>

-------------------------------------------------------------------------------------------------------------

Page 2.html
------------------
<span jwcid="$content$">
<span jwcid="@Border">
<h1>Page 2</h1>
</span>
</span>

-------------------------------------------------------------------------------------------------------------

Page3.html
-----------------
<span jwcid="$content$">
<span jwcid="@Border">
<h1>Page 3</h1>
</span>
</span>

//end of source code

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

Reply via email to