Dear Vasanth,
if you filter type page and only allow to choose from contentstore you won't be able to choose anything. Try it out by manually choosing from your 'page' component.
One example of how to store type page,pageref or content2 would be the following:
Template-Code:
<FS_REFERENCE name="page" hFill="yes" sections="no" useLanguages="no">
<FILTER>
<ALLOW type="page"/>
<ALLOW type="content2"/>
<ALLOW type="pageref"/>
</FILTER>
<LANGINFOS>
<LANGINFO lang="*" label="XXX"/>
</LANGINFOS>
<PROJECTS>
<LOCAL name=".">
<SOURCES>
<FOLDER name="root" store="contentstore"/>
<FOLDER name="root" store="pagestore"/>
<FOLDER name="root" store="sitestore"/>
</SOURCES>
</LOCAL>
</PROJECTS>
</FS_REFERENCE>
Java-Code (without imports):
UserService us2 = context.getUserService();
PageStoreRoot pageStore = (PageStoreRoot) us2.getStore(
Store.Type.PAGESTORE, false);
ContentStoreRoot contentStore = (ContentStoreRoot) us2.getStore(
Store.Type.CONTENTSTORE, false);
SiteStoreRoot siteStore = (SiteStoreRoot) us2.getStore(
Store.Type.SITESTORE, false);
//The page containing your FS_REFERENCE
Page page = (Page) pageStore.getStoreElement("mithras_home",
UidType.PAGESTORE);
FormData data = page.getFormData();
//Getting FS_REFERENCE called 'page'
FormField field = data
.get(us2.getProject().getMasterLanguage(), "page");
PageRef ref = (PageRef) siteStore.getStoreElement(
"productflash", UidType.SITESTORE_LEAF);
Page p = (Page) pageStore.getStoreElement("aboutus_2",
UidType.PAGESTORE);
Content2 cont = (Content2) contentStore.getStoreElement("jobs",
UidType.CONTENTSTORE);
TargetReference t = field.get();
page.setLock(true);
//t.set(ref); //store a pagereference
//t.set(p); //store a page
t.set(cont); // store content2
page.setFormData(data);
page.save();
page.setLock(false);
Yours sincerely
Ismail