well,
response.renderJavascript("var wicketNicEditor; function
wicketNicEditorUpdate() {
wicketNicEditor.nicInstances[0].saveContent(); };", null);
could just be
response.renderJavascript("var wicketNicEditor;", null);
francisco
On Tue, Jun 17, 2008 at 6:12 PM, francisco treacy
<[EMAIL PROTECTED]> wrote:
> hey don,
>
> i'm sorry, i just published it too fast :) i was having some trouble
> with my persistence layer so i thought the model was getting updated
> cause wasn't hitting the db.
>
> ajax or not, it wouldn't work either way. before calling the submit
> button, contents have to be updated.
>
> so here i came up with a new version that works (i believe with ajax
> only, and with one textarea for the moment). i'm by no means an ajax
> expert (hmm, in fact, i dislike javascript :) so this is a call to
> wicket ajax gurus: could you help me improve this code?
>
> usage:
>
> (...)
> final NicEditTextAreaBehavior behavior = new NicEditTextAreaBehavior();
> textarea.add(behavior);
> (...)
>
> form.add(new AjaxFallbackButton("submit", form) {
>
> @Override
> protected IAjaxCallDecorator getAjaxCallDecorator() {
> return behavior.NICEDIT_AJAX_BUTTON_DECORATOR;
> }
>
> (...)
>
> });
>
> (...)
>
>
>
>
> public class NicEditTextAreaBehavior extends AbstractAjaxBehavior {
>
> private Boolean fullPanel = Boolean.TRUE;
>
> private static final ResourceReference NICEDIT_JAVASCRIPT =
> new JavascriptResourceReference(NicEditTextAreaBehavior.class,
> "nicEdit.js");
>
> private static final ResourceReference NICEDIT_ICONS = new
> ResourceReference(NicEditTextAreaBehavior.class,
> "nicEditorIcons.gif");
>
> public static final AjaxCallDecorator NICEDIT_AJAX_BUTTON_DECORATOR =
> new AjaxCallDecorator() {
> @Override
> public CharSequence decorateScript(final CharSequence script) {
> return
> "wicketNicEditor.nicInstances[0].saveContent();" + script;
> }
> };
>
> public NicEditTextAreaBehavior() {
> }
>
> public NicEditTextAreaBehavior(Boolean fullPanel) {
> this.fullPanel = fullPanel;
> }
>
> @Override
> protected void onBind() {
> super.onBind();
> getComponent().setOutputMarkupId(true);
> }
>
> @Override
> public void onRequest() {
> }
>
> @Override
> public void renderHead(IHeaderResponse response) {
> super.renderHead(response);
> response.renderJavascriptReference(NICEDIT_JAVASCRIPT);
> response.renderJavascript("var wicketNicEditor; function
> wicketNicEditorUpdate() {
> wicketNicEditor.nicInstances[0].saveContent(); };", null);
> response.renderOnDomReadyJavascript("wicketNicEditor = new
> nicEditor({iconsPath : '"+ RequestCycle.get().urlFor(
> NICEDIT_ICONS) +"', fullPanel : "+ fullPanel
> +"}).panelInstance('"
> + getComponent().getMarkupId() + "');");
> }
>
> }
>
> give it a shot and please keep me updated.
>
> francisco
>
>
> On Mon, Jun 16, 2008 at 9:17 PM, Don Hass <[EMAIL PROTECTED]> wrote:
>>
>> Have you tried using this in a ajax based form in Wicket? It seems that it
>> does not like ajax based submits but the "solutions" in the nicedit forums
>> seems to be fail as well.
>>
>> The problem is that the model for the textarea you add the nic behavior to,
>> never gets updated when you submit the form. In the scenario I was testing,
>> it is AjaxButton for submission.
>>
>>
>>
>> francisco treacy-2 wrote:
>>>
>>> hi,
>>>
>>> i thought i'd like to share a simple behaviour for NicEdit
>>> (http://nicedit.com/).
>>>
>>> to use it, just download nicedit and modify NICEDIT_JAVASCRIPT and
>>> NICEDIT_ICONS accordingly. (i chose to put them together in the same
>>> package).
>>> if you download the basic version (without xhtml/ code view), when
>>> adding the behaviour pass 'false' into the constructor, in order not
>>> to use the full panel.
>>>
>>> of course, you can use it with multiple textareas in the same page.
>>>
>>> let me know if you run into some problem using it. should this belong
>>> to the wiki as well?
>>>
>>> francisco
>>>
>>>
>>> public class NicEditTextAreaBehavior extends AbstractBehavior {
>>>
>>> private Component<TextArea<String>> textArea;
>>> private Boolean fullPanel = Boolean.TRUE;
>>>
>>> private static final ResourceReference NICEDIT_JAVASCRIPT =
>>> new JavascriptResourceReference(NicEditTextAreaBehavior.class,
>>> "nicEdit.js");
>>>
>>> private static final ResourceReference NICEDIT_ICONS = new
>>> ResourceReference(NicEditTextAreaBehavior.class,
>>> "nicEditorIcons.gif");
>>>
>>> public NicEditTextAreaBehavior() {
>>> }
>>>
>>> public NicEditTextAreaBehavior(Boolean fullPanel) {
>>> this.fullPanel = fullPanel;
>>> }
>>>
>>> @Override @SuppressWarnings("unchecked")
>>> public void bind(Component component) {
>>> this.textArea = component;
>>> component.setOutputMarkupId(true);
>>> }
>>>
>>> @Override
>>> public void renderHead(IHeaderResponse response) {
>>> super.renderHead(response);
>>> response.renderJavascriptReference(NICEDIT_JAVASCRIPT);
>>> response.renderOnDomReadyJavascript("new nicEditor({iconsPath
>>> : '"+
>>> RequestCycle.get().urlFor(
>>> NICEDIT_ICONS) +"', fullPanel : "+ fullPanel
>>> +"}).panelInstance('"
>>> + textArea.getMarkupId() + "');");
>>> }
>>>
>>> }
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>>> For additional commands, e-mail: [EMAIL PROTECTED]
>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/NicEditTextAreaBehavior-tp17840648p17871532.html
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]