You are on page 1of 6

FeritewebdevelopmentTutorial:

1.1Myfirstpagewithferite LetsstarttoourprojectfromafolderassadDevinthepath/cention/htdocs/wf/Skeleton.app/Pages. NowcreatetwopagenamedMain.pageandMain.page.fe.Theexamplebelowshowsanareawith image&linktonavigatetootherpage. OpenMain.pageinthetexteditor.Intheblankdocumenttypeorpastethefollowingcode


<wf:BoxTextValue="IndexPage"> <tablealign="center"style="FontSize:30px"> <tr> <tdalign="right"> <imgsrc="/wf/Skeleton.app/Pages/assadDev/images/user_login_lock.png"alt="" width="30px"height="30px"/> </td> <td> <ahref="Login">AdminLogin</a> </td> </tr> <tr> <tdalign="right"> <imgsrc="/wf/Skeleton.app/Pages/assadDev/images/user2.png"alt="" width="30px"height="30px"/> </td> <td> <ahref="Login">AdminPanel</a> </td> </tr> </table> </wf:Box>

andintheMain.page.fepagetypeorpastethecodebelow.
classMainPageextendsGUIKit.Page { functioninitialiseComponents(){ } } returnMainPage;

now,trytovisitthepagewithabrowserwiththelinkhttp://localhost/wf/Skeleton/assadDev/Main,the linkwillnotworkandwillshowthefollowingerrormessageApplicationerrorunabletoinvoke handlerforactionassadDev/Main.

Tosolvetheerror,youhavetoeditafilenameSkeleton.feandaddthefollowinglinesthere.
self.generalPageList=[ //Errandsmenupages 'assadDev/Main', 'outbound/email/list'

];

nowifyoutestthelinkinthebrowser,youwillsee

1.2Workingwithothersobjects Herewe'llworkwithButton,textfield,passwordfield,fileuploader,gridviewcomponents. Customer.page


<wf:BoxTextValue="AddNewCustomer"> <table> <tr> <td>CustomerName</td> <td><wf:TextFieldID="customerName"/></td> </tr> <tr> <td>CustomerAddress</td> <td><wf:TextFieldID="customerAddress"/></td> </tr> <tr> <td>CustomerPassword</td> <td><wf:PasswordFieldID="customerPassword"/></td> </tr> <tr> <td>AttachFile</td> <td><wf:FileLoaderID="fileUpLoader"/></td> <td><wf:ButtonID="fileUpLoaderButton"TextValue="Upaload"/></td> <td><wf:LabelID="lblUploadFile"/></td> </tr> <tr> <td></td> <td><wf:ButtonID="buttonSave"TextValue="Save"/> <wf:ButtonID="buttonClear"TextValue="Clear"/> </td> </tr> </table>

</wf:Box> <wf:BoxTextValue="CustomerList"> <wf:GenGridViewID="genGridView"/> </wf:Box>

Customer.page.fe

classCustomerPageextendsGUIKit.Page { [componentcustomerName,customerAddress,customerPassword]; [componentfileUpLoaderButton,buttonSave,buttonClear,lblUploadFile,fileUpLoader,genGridView]; functioninitialiseComponents() { .fileUpLoaderButton.registerEventHook(self,"fileUpLoaderButton_click",GUIKit.EvClick); . .buttonSave.registerEventHook(self,"buttonSave_click",GUIKit.EvClick); . .buttonClear.registerEventHook(self,"buttonClear_click",GUIKit.EvClick); } functionfileUpLoaderButton_click(objecto,strings) { } functionbuttonSave_click(objecto,strings) { } functionbuttonClear_click(objecto,strings) { } } returnCustomerPage;

1.3WorkingwithFileUploader,codetouploadafile.
functionfileUpLoaderButton_click(objecto,strings) { stringfileDirectoryPath; stringfileDirectoryURI; objectuploadedFile; s stringfileUploadID; fileUploadID=''+Date.date(Date.now()).time()+''+Math.randomNumber(100,999);

fileDirectoryPath=pathForDataItem('')+'Outbound/Templates/'+fileUploadID; fileDirectoryURI='http://'+(Config.Domain?Config.Domain:Network.getHostname()) +'/'+uriForDataItem('') +'Outbound/Templates/'+fileUploadID; u uploadedFile=.fileUpLoader.uploadedFile(); if(uploadedFile){ objectfileDirectory=Directory.open(fileDirectoryPath); if(notfileDirectory){ Directory.build(fileDirectoryPath); fileDirectory=Directory.open(fileDirectoryPath); } if(fileDirectory){ stringuploadedFileName= uploadedFile.filename.preTrim('"').postTrim('"'); //println(fileDirectory);//+"/"+uploadedFileName . .lblUploadFile.setTextValue(uploadedFileName); } } }

1.4WorkingwithGridView,howtopopulate Populatingagridviewisabitcomplextask.Pleasefollowthefollowingstepsforthetask.
functionpageLoaded() { super.pageLoaded(); self.genGridView.setHeaderList(I('id'),I('Name'),I('Address'), '<imgsrc="/wf/Skeleton.app/Resources/Templates/Master.template/Images/attached_file.gif"/>'); self.genGridView.setEmptyMsg(I('ThisListisempty')); s self.genGridView.setHeaderParam(['hp_id','hp_name','hp_address','']); if(.firstLoad) { .showCustomerList(); }

} functionshowCustomerList() { monitor { arraycustomers=.getCustomerList(); self.genGridView.setDataSource(customers); } handle { print(err.str); } } functiongetCustomerList() { arraycamps=[]; stringtemp_file=""; monitor { arrayCustObjs=.getCustomerObjects(); CustObjs.each()using(comp) { arrayr; r['ss']="0"; r['hp_id']=comp.id; r['hp_name']=comp.name; r['hp_address']=comp.address; temp_file="<ahref=\""+uriForApplicationAction("/wf/Skeleton/assadTest/") +comp.uploaded_file+"\">" +comp.uploaded_file+"</a>"; if(comp.can_download=="Y") { r['cdownload']=temp_file; } else { r['cdownload']="Pleaselogintodownload"; } camps[]=r;

} handle { }

}; returncamps;

print("getCampaignList"+err.str);

} functiongetCustomerObjects(){ arrayclist=[]; clist=ObjRunObject.rawQuery("selectid,name,address,can_download, uploaded_filefromworkflow_customertest"); returnclist; }

You might also like