cancel
Showing results for 
Search instead for 
Did you mean: 

TinyMCE in Web Client

hbf
Champ on-the-rise
Champ on-the-rise
Hi,

A quick question: Am I right that there is no configuration setting for the Web Client to make a property of a type/aspect editable using the TinyMCE WYSIWYG editor?

I could not find any information regarding this; in particular, Simple Customizations (wiki) does not provide an answer.

I see, however, that the Forms Developer Guide mentions TinyMCE. But such forms can only be used for WCM projects. Correct?

So this means that the best way out (if you, like me, are not using WCM) is to write a component for the Component Generator Framework that loads TinyMCE, right?

Many thanks for a short answer! I'd be glad to learn wether I understand the situation correctly.

Kaspar
7 REPLIES 7

gavinc
Champ in-the-making
Champ in-the-making
Yes, you are correct in all your questions/presumptions.

hbf
Champ on-the-rise
Champ on-the-rise
Gavin, thank you very much for your answers.

Knowing that I am on the right track, I started working on a general-purpose AMP that provides a component-generator 'TinyMCETextAreaGenerator': Given a Web Client customization like this,

<show-property name="my:textproperty"
               component-generator="TinyMCETextAreaGenerator">

a TinyMCE text area will be generated.

Unfortunately, I've run into a problem – I think I almost got it, but need some more help.

Here's what I am trying to do: I have added a custom generator like this


package org.alfresco.module.WebClientTinyMCESupport.ui;
//…
public class TinyMCETextAreaGenerator extends TextAreaGenerator
{
  private static final Log logger = LogFactory
                                      .getLog(TinyMCETextAreaGenerator.class);

  public UIComponent generate(FacesContext context, String id)
  {
    logger.info("TinyMCETextAreaGenerator invoked.");
    UIComponent component = context.getApplication().createComponent(
        ComponentConstants.JAVAX_FACES_INPUT);
    component.setRendererType("org.alfresco.module.WebClientTinyMCESupport.ui.TinyMCETextArea"); // (*)
    FacesHelper.setupComponentId(context, component, id);
    return component;
  }
}
package org.alfresco.module.WebClientTinyMCESupport.ui;
//…
public class TinyMCETextAreaRenderer extends BaseRenderer {
  public void encodeBegin(FacesContext context, UIComponent component)
      throws IOException
  {
    logger.info("encodeBegin"); // never executed!!
  }
  // …
}

The log shows me that the generator is actually called. However, I don't manage to successfully install the renderer. Without the line marked (*), I get a normal text field – but with (*), I get nothing at all (no text field), no complaints about the renderer not being found, and also no log output "encodeBegin".

My module's faces-config.xml contains these elements:

 <managed-bean>
  <managed-bean-name>TinyMCETextAreaGenerator</managed-bean-name>
  <managed-bean-class>org.alfresco.module.WebClientTinyMCESupport.ui.TinyMCETextAreaGenerator</managed-bean-class>
  <managed-bean-scope>request</managed-bean-scope>
</managed-bean>

<render-kit>
  <renderer>
   <component-family>javax.faces.input</component-family>
   <renderer-type>org.alfresco.module.WebClientTinyMCESupport.ui.TinyMCETextArea</renderer-type>
   <renderer-class>org.alfresco.module.WebClientTinyMCESupport.ui.TinyMCETextAreaRenderer</renderer-class>
  </renderer>
</render-kit>

I would be very grateful for a short tip.

Also, how can I enable javax.faces logging information about what renderers have been registered and which ones are called?

Of course, I plan to add the final AMP to Alfresco Forge.

Thanks,
Kaspar

hbf
Champ on-the-rise
Champ on-the-rise
It seems I can accomplish the same thing without renderers, so no need to respond to my previous comment at present. Sorry for the confusion.

hbf
Champ on-the-rise
Champ on-the-rise
I created an AMP called "webclient-tinymce-support" that provides a component with TinyMCE support.

I've created a short documentation on the wiki, see http://wiki.alfresco.com/wiki/AMP_for_Web_Client_WYSIWYG_Textareas.
(Alfresco engineers: It might be that the wiki is not a good place for AMPs!? I tried to point out on the above wiki page that this is not an official thing, so I hope it is fine. But please move it/delete it in case it causes problems.)

I will upload the AMP itself to Alfresco Forge as soon as the project gets approval.

I hope this helps others,
Kaspar

paulhh
Champ in-the-making
Champ in-the-making
I've just ok'd the forge project, so upload away…

I'm looking forward to seeing this in action!  Is it something you'd contribute to the core?

Cheers
Paul.

hbf
Champ on-the-rise
Champ on-the-rise
It's on the Forge.

The contribution can be used wherever it makes sense. It comes without any license and is for free use.

And of course, suggestions are welcome!

Kaspar

hbf
Champ on-the-rise
Champ on-the-rise
I realize that I've only uploaded the .amp itself. Also the source is now on Forge: http://forge.alfresco.com/projects/webcl-tinymce/

Is it something you'd contribute to the core?

If desired: yes, of course!