new member question
Mon, 02/01/2010 - 13:11
hi all ....i'm new with qcubed. and actually i'm new with web technology and want to start with qcubed. after explore about generated code and reading example I have some question :
1.Override component generated with Qcubed. example actually Qtextbox to Qfckeditor. I Just try but it say some data cannot null.but if i change at base create it work charm.but when I do generated ,the change was gone.
2.how about override only form save button to Qserveraction from Qajaxaction?thanks all my friend.

Hi Dani1
I think I understand your question. Yes you must change the QAjaxaction to QServeraction in order to save the QFCKeditor data. If you re-generate you will need to make the change again. I think you can still set the "use Ajax" to False in the config file. (Not sure that is where) But if you do then other programs that do not use QFCKeditor will not be able to take advantage of Ajax unless you change them too.
Hope this made sense
David
Thanks David for quick reply. I try just to modified the draft not the generated metacontrol. here is my full code (I just modified the form_create):
protected function Form_Create() {
parent::Form_Create();
$this->txtBerita= new QFCKeditor($this); //override with Qfckeditor. the generated is Qtextbox
$this->txtBerita->Width="700px";
$this->txtBerita->Height="300px";
$this->btnSave = new QButton($this);
$this->btnSave->Text = QApplication::Translate('Save');
$this->btnSave-> AddAction(new QClickEvent(), new QServerAction('btnSave_Click6')); //override too. had change to Qserveraction from Qajaxaction
$this->btnSave->CausesValidation = true;
}
// the new override save button
protected function btnSave_Click6() {
// Delegate "Save" processing to the BeritaTerbaruMetaControl
$this->mctBeritaTerbaru->SaveBeritaTerbaru(); //error happen in here.it says null
$this->RedirectToListPage();
}
thanks. Danny.
Thanks David for quick reply. I try just to modified the draft not the generated metacontrol. here is my full code (I just modified the form_create):
protected function Form_Create() {
parent::Form_Create();
$this->txtBerita= new QFCKeditor($this); //override with Qfckeditor. the generated is Qtextbox
$this->txtBerita->Width="700px";
$this->txtBerita->Height="300px";
$this->btnSave = new QButton($this);
$this->btnSave->Text = QApplication::Translate('Save');
$this->btnSave-> AddAction(new QClickEvent(), new QServerAction('btnSave_Click6')); //override too. had change to Qserveraction from Qajaxaction
$this->btnSave->CausesValidation = true;
}
// the new override save button
protected function btnSave_Click6() {
// Delegate "Save" processing to the BeritaTerbaruMetaControl
$this->mctBeritaTerbaru->SaveBeritaTerbaru(); //error happen in here.it says null
$this->RedirectToListPage();
}
thanks. Danny.
First of all - welcome to the community! We're thrilled to have you here.
On your question: you're trying to save the $this->mctBeritaTerbaru - but is it defined somewhere? Did you say "$this->mctBeritaTerbaru = new ..."? I'm guessing not.
Please review the video screencasts, they will help you: http://qcu.be/content/video-screencasts
There was an old post regarding saving QFCKEditor using Ajax method. The content of QFCKEditor is not included well during triggered event.
Basically the code in the Save button must be like this:
$this->btnSave->AddAction(new QClickEvent(), new QJavaScriptAction('for (x in FCKeditorAPI.__Instances) {FCKeditorAPI.__Instances[x].UpdateLinkedField()};'));
$this->btnSave->AddAction(new QClickEvent(), new QAjaxAction('btnSave_Click'));
Cheers.
Thanks alex for the time ...
here the condition:
$this->mctBeritaTerbaru is the object that generated by Qcubed at metacontrol level. the problem here is after I change the control from Textbox (generated by Qcubed the name is txtberitaterbaru) to Qfckeditor (only by simple $this->txtberitaterbaru=new QFckeditor($this)) is that way true?the result when I render txtberitaterbaru at template the result is not Qtextboxt anymore but became Qfckeditor (as I wish).the problem is when I save the button, the component (Qfkceditor) content detected as null by save object.
I try resoleve the condition by creating the Qfckeditor with different name (example txtberita2) then the origin txtberita render at template I erase and change with txtberita2. at save function I append at first line: $this->txtberita->text=txtberita2->text; and save function work well.
Is that trick save?
thanks one more.
Danny
thanks Ravvi for the time.
So basically I need to add AddAction (new QClickEvent(), new QJavaScriptAction('for (x in FCKeditorAPI.__Instances) {FCKeditorAPI.__Instances[x].UpdateLinkedField()};'));
before $this->btnSave->AddAction(new QClickEvent(), new QAjaxAction('btnSave_Click')); this one?
what's x on function above ? can more specific?
thanks
Danny
Are you having the problem when saving using ServerAction in btnSave?
If still using Ajax, you may follow my previous comment.
As you are using your own custom QFCKEditor instead of using the generated metacontrol, please make sure you initialize the initial content QFCKEditor (or load the current data from database). You can have a look on the original generated code.
$this->txtBeritaterbaru = new QFCKEditor($this);$this->txtBeritaterbaru->Text = "empty"; // or load from the db
...
Another advice, you may modify the field: Beritaterbaru as NULL in your mysql. Then whenever it is still null, no error from mysql :)
the x in that JavaScript code is a variable that holds each instance of FCKEditor. Basically it requires whenever you are using Ajax (which are not recommended for QFCKEditor).
Reference: Other similar implementation can be found on old QCodo web: http://www.qcodo.com/forums/forum.php/0/3568/?search=FCKEditor
thanks revvi.
yes I have problem using serveraction (in draft level.but when create Qfckeditor at metacontrol level everything work fine.see my reply to alex above,but everything at metacontrol level will gone when we generate the project. so I decide the modification must be at draft level).
After trying around the code, the possibility of null from new component I override at draft level is because the component not right binding to the parent object,(in this case mctberitaterbaru/which generated from metacontrol).so right now I use trick above(my reply to alex),but I m still curious about safety of the code.
thanks...
danny
thanks revvi
I will try the code from http://www.qcodo.com/forums/forum.php/0/3568/?search=FCKEditor
thanks
Danny
I also thank you revvi. I beat my head against the wall all day, trying to understand why the contents from FCKEditor wouldn't save. Thanks very much to your information, it now works!
Glad can help you all :)
revvi, can you update the FCKEditor plugin - the example that ships with it - to include this piece of wisdom you've shared on this thread? It'd be extremely valuable for newbies.
Hi Alex, I have no write access to the repository. How do I do that?.
You actually do have write access - everyone has write access to the /plugins section of the repository. Just use your qcu.be username/password. Let me know if you need help getting to the SVN!
I didn't realize that plugins directory is writable by everyone. Alright I will try to update then. Thanks Alex.