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/09/05 07:52:29 UTC

Re[2]: How solve such problem?

Hello Harish,

Because pageBeginRender isn't invoked in such case:

 public void homeFormSubmit(IRequestCycle cycle) {
    final String orgName = ((Visit) getVisit()).getOrganization().getName();
    log.info("Organization name: " + orgName);
    if (orgName != null && orgName.trim().compareTo("") != 0) {
      // go to page with list of similar organization
      cycle.activate(CompanySelection.PAGE_NAME);
    }
  }

  and also it's invoked before any setXXX methods have done.

Thursday, September 4, 2003, 7:54:42 PM, you wrote:

HK> Why can't you use PageRenderListener.pageBeginRender() in addition with
HK> IRequestCycle.isRewinding()? I think you can do the 
HK> initSilimiarCompanies() from within pageBeginRender() and then you will
HK> have control over when you want to initSimilarCompanies(). Hope I did
HK> not misunderstand your question.

HK> -Harish

HK> Max Grigoriev wrote:

>>Hello tapestry-user,
>>
>>  I have a Visit object with Organization:
>>
>>public class Visit implements Serializable {
>>  private Organization organization;
>>  public Organization getOrganization() {
>>    return organization;
>>  }
>>  public void setOrganization(Organization organization) {
>>    this.organization = organization;
>>  }
>>}
>>
>>And I have a page CompanySelection which displays similar companies.
>>I do such thing:
>>public class CompanySelection extends BasePage {
>>
>>private List similarOrgs; //set and get
>>private Organization value; //set and get
>>
>>public void attach(IEngine iEngine) {
>>    super.attach(iEngine);
>>    initSimilarCompanies();
>>  }
>>
>>  private void initSimilarCompanies() {
>>    try {
>>      final String orgName = ((Visit)
>> getVisit()).getOrganization().getName();
>>      setExist(false);
>>      if (orgName != null && orgName.trim().compareTo("") != 0) {
>>       
>> setSimilarOrgs(OrganizationHome.getSimilarOrganization(orgName,
>> null, null));
>>      } else {
>>        setSimilarOrgs(new ArrayList());
>>      }
>>    } catch (MiddleException e) {
>>      e.printStackTrace();
>>    }
>>  }
>>}
>>
>>and this page html
>>
>>
>><span jwcid="@RadioGroup" selected='ognl:visit.organization'>
>>  <tr jwcid="@Foreach" source="ognl:similarOrgs"
>> value="ognl:value" element="tr">
>>      <td align="left" valign="middle"
>> class="fbFndTableRaw1"><input type="radio" jwcid="@Radio"
>> name="radiobutton" value="ognl:value" />
>>      </td>
>>      <td width="100%" align="left" valign="middle"
>> class="fbFndTableRaw1"><span class="fbTextG"><strong>
>>          <span jwcid="@Insert"
>> value="ognl:value.name"/></strong></span></td>
>>      </tr>
>></span>
>><input jwcid="@ImageSubmit" image="ognl:assets.selectImage" />
>>
>>And when i input name on Home page and then go to this page,
>>everything's OK.
>>
>>But when i select similer company and click ImageSubmit I get thing
>>wich i don't want:
>>
>>Because atach is invoked first, then Organization in Visit didn't set
>>into selected Organization and i get old similarList. Then excuted
>>setXXX methods and organization in Visit is changed, so i have to
>>re-init similarOrgs. I don't like that i have to go to database twice.
>>
>>Can anyone says what i should do to solve this problem.
>>Thank's
>>
>>  
>>


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




-- 
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


Re: How solve such problem?

Posted by Harish Krishnaswamy <hk...@comcast.net>.
pageBeginRender() is invoked twice in a request cycle, once after the 
Page is submitted (during rewind) and again just before the Page is 
rendered. The second invocation is after all the setXs have been 
invoked. You may distinguish the two invocations by calling the 
IRequestCycle.isRewinding() method. Hope this helps.

-Harish

Max Grigoriev wrote:

>Hello Harish,
>
>Because pageBeginRender isn't invoked in such case:
>
> public void homeFormSubmit(IRequestCycle cycle) {
>    final String orgName = ((Visit) getVisit()).getOrganization().getName();
>    log.info("Organization name: " + orgName);
>    if (orgName != null && orgName.trim().compareTo("") != 0) {
>      // go to page with list of similar organization
>      cycle.activate(CompanySelection.PAGE_NAME);
>    }
>  }
>
>  and also it's invoked before any setXXX methods have done.
>
>Thursday, September 4, 2003, 7:54:42 PM, you wrote:
>
>HK> Why can't you use PageRenderListener.pageBeginRender() in addition with
>HK> IRequestCycle.isRewinding()? I think you can do the 
>HK> initSilimiarCompanies() from within pageBeginRender() and then you will
>HK> have control over when you want to initSimilarCompanies(). Hope I did
>HK> not misunderstand your question.
>
>HK> -Harish
>
>HK> Max Grigoriev wrote:
>
>  
>
>>>Hello tapestry-user,
>>>
>>> I have a Visit object with Organization:
>>>
>>>public class Visit implements Serializable {
>>> private Organization organization;
>>> public Organization getOrganization() {
>>>   return organization;
>>> }
>>> public void setOrganization(Organization organization) {
>>>   this.organization = organization;
>>> }
>>>}
>>>
>>>And I have a page CompanySelection which displays similar companies.
>>>I do such thing:
>>>public class CompanySelection extends BasePage {
>>>
>>>private List similarOrgs; //set and get
>>>private Organization value; //set and get
>>>
>>>public void attach(IEngine iEngine) {
>>>   super.attach(iEngine);
>>>   initSimilarCompanies();
>>> }
>>>
>>> private void initSimilarCompanies() {
>>>   try {
>>>     final String orgName = ((Visit)
>>>getVisit()).getOrganization().getName();
>>>     setExist(false);
>>>     if (orgName != null && orgName.trim().compareTo("") != 0) {
>>>      
>>>setSimilarOrgs(OrganizationHome.getSimilarOrganization(orgName,
>>>null, null));
>>>     } else {
>>>       setSimilarOrgs(new ArrayList());
>>>     }
>>>   } catch (MiddleException e) {
>>>     e.printStackTrace();
>>>   }
>>> }
>>>}
>>>
>>>and this page html
>>>
>>>
>>><span jwcid="@RadioGroup" selected='ognl:visit.organization'>
>>> <tr jwcid="@Foreach" source="ognl:similarOrgs"
>>>value="ognl:value" element="tr">
>>>     <td align="left" valign="middle"
>>>class="fbFndTableRaw1"><input type="radio" jwcid="@Radio"
>>>name="radiobutton" value="ognl:value" />
>>>     </td>
>>>     <td width="100%" align="left" valign="middle"
>>>class="fbFndTableRaw1"><span class="fbTextG"><strong>
>>>         <span jwcid="@Insert"
>>>value="ognl:value.name"/></strong></span></td>
>>>     </tr>
>>></span>
>>><input jwcid="@ImageSubmit" image="ognl:assets.selectImage" />
>>>
>>>And when i input name on Home page and then go to this page,
>>>everything's OK.
>>>
>>>But when i select similer company and click ImageSubmit I get thing
>>>wich i don't want:
>>>
>>>Because atach is invoked first, then Organization in Visit didn't set
>>>into selected Organization and i get old similarList. Then excuted
>>>setXXX methods and organization in Visit is changed, so i have to
>>>re-init similarOrgs. I don't like that i have to go to database twice.
>>>
>>>Can anyone says what i should do to solve this problem.
>>>Thank's
>>>
>>> 
>>>
>>>      
>>>
>
>
>HK> ---------------------------------------------------------------------
>HK> To unsubscribe, e-mail:
>HK> tapestry-user-unsubscribe@jakarta.apache.org
>HK> For additional commands, e-mail:
>HK> tapestry-user-help@jakarta.apache.org
>
>
>
>
>  
>