public function __construct($userId)
    {
        parent::__construct();
        $form = new Form("send_message_form");
        $form->setAjax(true);
        $form->setAjaxResetOnSuccess(true);
        $form->setAction(OW::getRouter()->urlFor('BASE_CTRL_AjaxSendMessageToEmail', 'sendMessage'));
        $user = new HiddenField("userId");
        $user->setValue($userId);
        $form->addElement($user);
        $subject = new TextField('subject');
        $subject->setInvitation(OW::getLanguage()->text('base', 'subject'));
        $subject->setRequired(true);
        $form->addElement($subject);
        $textarea = new WysiwygTextarea("message");
        $textarea->setInvitation(OW::getLanguage()->text('base', 'message_invitation'));
        $requiredValidator = new WyswygRequiredValidator();
        $requiredValidator->setErrorMessage(OW::getLanguage()->text('base', 'message_empty'));
        $textarea->addValidator($requiredValidator);
        $form->addElement($textarea);
        $submit = new Submit('send');
        $submit->setLabel(OW::getLanguage()->text('base', 'send'));
        $form->addElement($submit);
        $form->bindJsFunction(Form::BIND_SUCCESS, ' function ( data ) {

            if ( data.result )
            {
                OW.info(data.message);
            }
            else
            {
                OW.error(data.message);
            }

            if ( OW.getActiveFloatBox() )
            {
                OW.getActiveFloatBox().close();
            }

        } ');
        $this->addForm($form);
    }
 /**
  * Class constructor
  *
  */
 public function __construct(MAILBOX_CMP_NewMessage $component = null)
 {
     $language = OW::getLanguage();
     parent::__construct('mailbox-new-message-form');
     $this->setId('mailbox-new-message-form');
     $this->setAjax(true);
     $this->setAjaxResetOnSuccess(false);
     $this->setAction(OW::getRouter()->urlFor('MAILBOX_CTRL_Ajax', 'newMessage'));
     $this->setEmptyElementsErrorMessage('');
     $this->setEnctype('multipart/form-data');
     $subject = new TextField('subject');
     //        $subject->setHasInvitation(true);
     //        $subject->setInvitation($language->text('mailbox', 'subject'));
     $subject->addAttribute('placeholder', $language->text('mailbox', 'subject'));
     $requiredValidator = new RequiredValidator();
     $requiredValidator->setErrorMessage($language->text('mailbox', 'subject_is_required'));
     $subject->addValidator($requiredValidator);
     $validatorSubject = new StringValidator(1, 2048);
     $validatorSubject->setErrorMessage($language->text('mailbox', 'message_too_long_error', array('maxLength' => 2048)));
     $subject->addValidator($validatorSubject);
     $this->addElement($subject);
     $validator = new StringValidator(1, MAILBOX_BOL_AjaxService::MAX_MESSAGE_TEXT_LENGTH);
     $validator->setErrorMessage($language->text('mailbox', 'message_too_long_error', array('maxLength' => MAILBOX_BOL_AjaxService::MAX_MESSAGE_TEXT_LENGTH)));
     $textarea = OW::getClassInstance("MAILBOX_CLASS_Textarea", "message");
     /* @var $textarea MAILBOX_CLASS_Textarea */
     $textarea->addValidator($validator);
     $textarea->setCustomBodyClass("mailbox");
     //        $textarea->setHasInvitation(true);
     //        $textarea->setInvitation($language->text('mailbox', 'message_invitation'));
     $textarea->addAttribute('placeholder', $language->text('mailbox', 'message_invitation'));
     $requiredValidator = new WyswygRequiredValidator();
     $requiredValidator->setErrorMessage($language->text('mailbox', 'chat_message_empty'));
     $textarea->addValidator($requiredValidator);
     $this->addElement($textarea);
     $user = OW::getClassInstance("MAILBOX_CLASS_UserField", "opponentId");
     /* @var $user MAILBOX_CLASS_UserField */
     //        $user->setHasInvitation(true);
     //        $user->setInvitation($language->text('mailbox', 'to'));
     $requiredValidator = new RequiredValidator();
     $requiredValidator->setErrorMessage($language->text('mailbox', 'recipient_is_required'));
     $user->addValidator($requiredValidator);
     $this->addElement($user);
     if (OW::getSession()->isKeySet('mailbox.new_message_form_attachments_uid')) {
         $uidValue = OW::getSession()->get('mailbox.new_message_form_attachments_uid');
     } else {
         $uidValue = UTIL_HtmlTag::generateAutoId('mailbox_new_message');
         OW::getSession()->set('mailbox.new_message_form_attachments_uid', $uidValue);
     }
     $uid = new HiddenField('uid');
     $uid->setValue($uidValue);
     $this->addElement($uid);
     $configs = OW::getConfig()->getValues('mailbox');
     if (!empty($configs['enable_attachments']) && !empty($component)) {
         $attachmentCmp = new BASE_CLASS_FileAttachment('mailbox', $uidValue);
         $attachmentCmp->setInputSelector('#newMessageWindowAttachmentsBtn');
         $component->addComponent('attachments', $attachmentCmp);
     }
     $submit = new Submit("send");
     $submit->setValue($language->text('mailbox', 'send_button'));
     $this->addElement($submit);
     if (!OW::getRequest()->isAjax()) {
         $this->initStatic();
     }
 }