You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Max Grigoriev <da...@mail.ru> on 2003/10/02 10:48:18 UTC

Dynamic components

Hello tapestry-user,

    I've got another problem with show and hide ome components.
  There's text field and Submit button on a page.
  Step 1.
  When user inputs data in the text field and presses submit, he can
  see list of organizations. Then he can click on organization and see
  the detail report about it organization.
  Step 2. He can input new data in
  text field and click submit button, then new list of organizations
  should be displayed and the detail report should be hidden.

  On the step 2 when user press submit there's an error:

     You have clicked on a stale link.
     Rewind of form Action/$Form expected 9 more form elements, starting with id '$TextField$0'.
     This is most likely the result of using your browser's back button, but can also be an application error.

 Here's html:

<span jwcid="$content$">
  <table border="0" width="100%" cellpadding="0" cellspacing="0">
    <tr>
      <td><input jwcid="@TextField" value="ognl:bean.orgName" type="text" size="20"/></td>
    </tr>
    <tr>
      <td><input jwcid="@ImageSubmit" listener="ognl:listeners.showOrganizations"
        image="ognl:assets.submitImage"/></td>
    </tr>
    <tr jwcid="@Foreach" source="ognl:bean.organizations" value="ognl:bean.selectedOrganization"
      element="tr">
      <td>
        <a jwcid="@ActionLink"
        listener="ognl:listeners.organizationClick">
          <span jwcid="@Insert" value="ognl:bean.selectedOrganization.name"/>
        </a>
      </td>
    </tr>
    <span jwcid="@Conditional" condition="ognl:bean.showAdd">
      <tr>
        <td><span jwcid="AddCompanyC"/></td>
      </tr>
    </span>
  </table>
</span>

Spec:

<component-specification class="com.clearview.feedback.web.component.admin.EditCompany"
  allow-body="yes" allow-informal-parameters="no">
  <description>edit organization component</description>
  <context-asset  name="submitImage" path="/images/hrform-bt-submit_en.gif"/>
  <component id="AddCompanyC" type="AddCompany">
    <binding name="organization" expression="bean.currOrganization"/>
    <binding name="companyEditMode" expression="true"/>
  </component>>
 </component-specification>

Java:
public class EditCompany extends BaseComponent {
  private EditCompanyBean bean;

  public void showOrganizations(IRequestCycle cycle) throws MiddleException {
    //reinit list fo organizations
    getBean().setOrganizations(OrganizationHome.
        getSimilarOrganization(getBean().getOrgName(),
            Language.DEFAULT_LANGUAGE, null));
    //don't show detail report
    getBean().setShowAdd(false);
  }

  public void organizationClick(IRequestCycle cycle) {
    //show detail report for CurrOrganization
    getBean().setShowAdd(true);
    getBean().setCurrOrganization(getBean().getSelectedOrganization());
  }

  public EditCompanyBean getBean() {
    if(bean == null)
      bean = new EditCompanyBean();
    return bean;
  }

  public void setBean(EditCompanyBean bean) {
    this.bean = bean;
  }
}

I don't understand how working with such components. Can somebody
explain it to me ?

Thank's

 
-- 
Best regards,
 Max                          mailto:darkit@mail.ru


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org