You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by cleverpig <gr...@gmail.com> on 2009/11/05 07:15:54 UTC

T5:formfragment miss data when post?

hi,buddies!
i met a trouble:formfragment miss post data when post to the page
which display result.

it's my page,including a radiogroup and 2 formFragment.user can switch
formfragment via check radio:
...
	<t:form t:id="form">
		<t:label for="category"/>
		<t:radiogroup t:id="category">
        	<t:radio t:id="numberCat"
        		t:value="numberCat"
        		t:mixins="triggerFragment"
        		t:fragment="sub01"/>
        	<t:label for="numberCat"/>
			<t:radio t:id="charCat"
				t:value="charCat"
				t:mixins="triggerFragment"
        		t:fragment="sub02"/>
        	<t:label for="charCat"/>
		</t:radiogroup>

		<t:formFragment t:id="sub01" visable="select01">
			<t:label for="list01"/>
			<t:select t:id="list01"
				t:model="list01"
				t:value="val01"
				/>
		</t:formFragment>

		<t:formFragment t:id="sub02" visable="select02">
			<t:label for="list02"/>
			<t:select t:id="list02"
				t:model="list02"
				t:value="val02"
				/>
		</t:formFragment>

		<input t:type="submit"/>
	</t:form>
...
My page class is very easy now.it only send data to result page:
FormFragmentDemo.class:
public class FormFragmentDemo {
	@Property
	private List<String> list01;
	@Property
	private List<String> list02;
	@Property
	private String val01;
	@Property
	private String val02;
	@Property
	private int category;
	private boolean select01;
	private boolean select02;
	@InjectPage
	private FormFragmentResult resultPage;
	void onPrepare(){
		list01=new ArrayList<String>();
		list01.add("1");
		list01.add("2");
		list01.add("3");
		list02=new ArrayList<String>();
		list02.add("A");
		list02.add("B");
		list02.add("C");
	}
	public int getNumberCat() {
		return 1;
	}
	public int getCharCat() {
		return 2;
	}

	public boolean isSelect01() {
		return select01;
	}
	public void setSelect01(boolean select01) {
		this.select01 = select01;
	}
	public boolean isSelect02() {
		return select02;
	}
	public void setSelect02(boolean select02) {
		this.select02 = select02;
	}
	@OnEvent(component="form",value=EventConstants.SUBMIT)
	Object onFormSubmit(){
		log.debug(category+","+val01+","+val02+","+select01+","+select02);
		resultPage.set(category, val01, val02);
		return resultPage;
	}
}
FormFragmentResult:
public class FormFragmentResult {
	@Property
	@Persist(PersistenceConstants.FLASH)
	private int category;
	@Property
	@Persist(PersistenceConstants.FLASH)
	private String sub01Selected;
	@Property
	@Persist(PersistenceConstants.FLASH)
	private String sub02Selected;
	
	public void set(int cat,String sub01,String sub02){
		this.category=cat;
		this.sub01Selected=sub01;
		this.sub02Selected=sub02;
	}
}
-- 
cleverpig(Dan)
Location: Beijing
Address: Room 4018,No.A2 South Avenue Fuxingmen Beijing,P.R.China
Zipcode: 100031
MSN: great_liudan@hotmail.com
QQ: 149291732
Skype: cleverpigatmatrix
Facebook ID:cleverpig
Blog: www.cleverpig.name
Tags: del.icio.us/cleverpig
Twitter: twitter.com/cleverpig
新浪微博: t.sina.com.cn/cleverpig
Organization: www.beijing-open-party.org
Organ@Facebook: http://www.facebook.com/group.php?gid=8159558294

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


Re: T5:formfragment miss data when post?

Posted by cleverpig <gr...@gmail.com>.
hm,i found miss data happened whe i went back the demo page via click
brower's back button.
if i reload this page with click pagelink,it would be ok.
why? something happened when brower go back the page?

2009/11/5 cleverpig <gr...@gmail.com>:
> hi,buddies!
> i met a trouble:formfragment miss post data when post to the page
> which display result.
>
> it's my page,including a radiogroup and 2 formFragment.user can switch
> formfragment via check radio:
> ...
>        <t:form t:id="form">
>                <t:label for="category"/>
>                <t:radiogroup t:id="category">
>                <t:radio t:id="numberCat"
>                        t:value="numberCat"
>                        t:mixins="triggerFragment"
>                        t:fragment="sub01"/>
>                <t:label for="numberCat"/>
>                        <t:radio t:id="charCat"
>                                t:value="charCat"
>                                t:mixins="triggerFragment"
>                        t:fragment="sub02"/>
>                <t:label for="charCat"/>
>                </t:radiogroup>
>
>                <t:formFragment t:id="sub01" visable="select01">
>                        <t:label for="list01"/>
>                        <t:select t:id="list01"
>                                t:model="list01"
>                                t:value="val01"
>                                />
>                </t:formFragment>
>
>                <t:formFragment t:id="sub02" visable="select02">
>                        <t:label for="list02"/>
>                        <t:select t:id="list02"
>                                t:model="list02"
>                                t:value="val02"
>                                />
>                </t:formFragment>
>
>                <input t:type="submit"/>
>        </t:form>
> ...
> My page class is very easy now.it only send data to result page:
> FormFragmentDemo.class:
> public class FormFragmentDemo {
>        @Property
>        private List<String> list01;
>        @Property
>        private List<String> list02;
>        @Property
>        private String val01;
>        @Property
>        private String val02;
>        @Property
>        private int category;
>        private boolean select01;
>        private boolean select02;
>        @InjectPage
>        private FormFragmentResult resultPage;
>        void onPrepare(){
>                list01=new ArrayList<String>();
>                list01.add("1");
>                list01.add("2");
>                list01.add("3");
>                list02=new ArrayList<String>();
>                list02.add("A");
>                list02.add("B");
>                list02.add("C");
>        }
>        public int getNumberCat() {
>                return 1;
>        }
>        public int getCharCat() {
>                return 2;
>        }
>
>        public boolean isSelect01() {
>                return select01;
>        }
>        public void setSelect01(boolean select01) {
>                this.select01 = select01;
>        }
>        public boolean isSelect02() {
>                return select02;
>        }
>        public void setSelect02(boolean select02) {
>                this.select02 = select02;
>        }
>        @OnEvent(component="form",value=EventConstants.SUBMIT)
>        Object onFormSubmit(){
>                log.debug(category+","+val01+","+val02+","+select01+","+select02);
>                resultPage.set(category, val01, val02);
>                return resultPage;
>        }
> }
> FormFragmentResult:
> public class FormFragmentResult {
>        @Property
>        @Persist(PersistenceConstants.FLASH)
>        private int category;
>        @Property
>        @Persist(PersistenceConstants.FLASH)
>        private String sub01Selected;
>        @Property
>        @Persist(PersistenceConstants.FLASH)
>        private String sub02Selected;
>
>        public void set(int cat,String sub01,String sub02){
>                this.category=cat;
>                this.sub01Selected=sub01;
>                this.sub02Selected=sub02;
>        }
> }
> --
> cleverpig(Dan)
> Location: Beijing
> Address: Room 4018,No.A2 South Avenue Fuxingmen Beijing,P.R.China
> Zipcode: 100031
> MSN: great_liudan@hotmail.com
> QQ: 149291732
> Skype: cleverpigatmatrix
> Facebook ID:cleverpig
> Blog: www.cleverpig.name
> Tags: del.icio.us/cleverpig
> Twitter: twitter.com/cleverpig
> 新浪微博: t.sina.com.cn/cleverpig
> Organization: www.beijing-open-party.org
> Organ@Facebook: http://www.facebook.com/group.php?gid=8159558294
>



-- 
cleverpig(Dan)
Location: Beijing
Address: Room 4018,No.A2 South Avenue Fuxingmen Beijing,P.R.China
Zipcode: 100031
MSN: great_liudan@hotmail.com
QQ: 149291732
Skype: cleverpigatmatrix
Facebook ID:cleverpig
Blog: www.cleverpig.name
Tags: del.icio.us/cleverpig
Twitter: twitter.com/cleverpig
新浪微博: t.sina.com.cn/cleverpig
Organization: www.beijing-open-party.org
Organ@Facebook: http://www.facebook.com/group.php?gid=8159558294

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