update the codeMirror

Community Driven Extensions Project
Post Reply
rcy
Posts: 102
Joined: 28 May 2012, 06:05

25 Sep 2012, 22:48

Hi,

I recently change the my layout from <pe:layout> to <p:layout>
I assume the problem that I am facing is due to this change but I am not 100% sure (so if you have any ideas ...)

The problem:
In one of the internal jsf I am using <pe:codeMirror> in order to view xml files.
Apparently the codeMirorr is working only after I refresh the page or at the first time that I am pressing the button that will activate the dialog with codeMirror ,otherwise I will see the text area and the xml.

This functionality was working perfectly before changing the layout but then the main form wrap the center layout and the menu navigation was not done via ajax
Now I need to use 2 forms and I aso using ajax.

This is my main jsf:

Code: Select all

<p:layout fullPage="true">
            <p:layoutUnit position="north" size="60" resizable="fasle" closable="false" collapsible="false">      
                <ui:include src="header.xhtml"/>
            </p:layoutUnit>
            <p:layoutUnit header="Menu" position="west" size="200" resizable="true" closable="true" collapsible="true">
                <h:form id="menuForm">
                    <ui:include src="menu_bar.xhtml"/>
                </h:form>
            </p:layoutUnit>
            <p:layoutUnit position="center" >
                <h:form id="mainForm">
                    <h:panelGroup rendered="#{navMenuBean.menuName == messages.OS_MENU}">
                        <ui:include src="os.xhtml"/>
                    </h:panelGroup>
...
..
.
This is the jsf with the codeMirror (os.xhtml):

Code: Select all

 <p:panelGrid id="commandPanel" styleClass="buttonPanel" columns="1">
            <p:row>
                <p:commandButton id="rcButton" 
                                 oncomplete="rcWidgetVar.show()"
                                 update=":mainForm:rcForm:rcXml"
                                 style="float: left"/>
            </p:row>
        </p:panelGrid>
        <p:dialog id="rcDialog" 
                  widgetVar="rcWidgetVar"
                  position="left"
                  appendToBody="true"
                  dynamic="true">
            <h:form id="rcForm">
                <pe:codeMirror id="rcXml"
                               mode="xml" 
                               readOnly="true" 
                               theme="eclipse" 
                               value="#{Bean.selectedOs.rc}" 
                               lineNumbers="false"
                               lineWrapping="false"/> 
            </h:form>
        </p:dialog>
The menu jsf:

Code: Select all

 <p:slideMenu style="width:180px">  
        <p:menuitem value="#{messages.OS_MENU}" actionListener="#{navMenuBean.actionListener}" update=":mainForm" ajax="true"/> 
...
..
.
I hope I am clear enough with the description of the problem.

Any ideas why and how can I update the codeMirror

Thanks
Last edited by rcy on 25 Sep 2012, 22:53, edited 2 times in total.
Primefaces 5.0 | WebLogic Server Version: 12.1.1.0 | NetBeans 7.1| JDK 1.7.0_10 | Windows 7,FireFox,Google Chrome,IE 8+9

cagatay.civici
Prime
Posts: 18158
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

25 Sep 2012, 22:50

Moved to extensions forum.

tandraschko
PrimeFaces Core Developer
Posts: 3690
Joined: 03 Dec 2010, 14:11
Location: Bavaria, DE
Contact:

26 Sep 2012, 21:10

I could help you but please debug the JS code yourself and share your founds:

http://code.google.com/p/primefaces-ext ... /widget.js

41-56 are the important lines. Please debug this codelines on first page load and after ajax update.

(this js is merged into primefaces-extensions. Be sure to get uncompressed JS files: http://code.google.com/p/primefaces-ext ... _resources)
Thomas Andraschko

PrimeFaces | PrimeFaces Extensions

Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE

Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko

rcy
Posts: 102
Joined: 28 May 2012, 06:05

27 Sep 2012, 18:44

can you please explained how to debug the js ?

never did this task
Primefaces 5.0 | WebLogic Server Version: 12.1.1.0 | NetBeans 7.1| JDK 1.7.0_10 | Windows 7,FireFox,Google Chrome,IE 8+9

tandraschko
PrimeFaces Core Developer
Posts: 3690
Joined: 03 Dec 2010, 14:11
Location: Bavaria, DE
Contact:

27 Sep 2012, 21:28

Use firebug, select the js file and set a breakpoint :)
Thomas Andraschko

PrimeFaces | PrimeFaces Extensions

Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE

Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko

rcy
Posts: 102
Joined: 28 May 2012, 06:05

01 Oct 2012, 18:28

I did some debugging and I think the problem is in the refresh

Code: Select all

/** 
* Creates the widget or calls "refresh" if already available. 
* 
* @author Thomas Andraschko 
* @param {string} widgetName The name of the widget. For example: ImageAreaSelect. 
* @param {widgetVar} widgetVar The variable in the window object for accessing the widget. 
* @param {object} cfg An object with options. 
*/ 
initWidget : function(widgetName, widgetVar, cfg) { 
if (window[widgetVar]) { 
window[widgetVar].refresh(cfg); 
} else { 
window[widgetVar] = new PrimeFacesExt.widget[widgetName](cfg); 
} 
}, 
For now I removed the ajax from the menu so basically the refresh function will not be execute.
Primefaces 5.0 | WebLogic Server Version: 12.1.1.0 | NetBeans 7.1| JDK 1.7.0_10 | Windows 7,FireFox,Google Chrome,IE 8+9

Post Reply

Return to “Extensions”

  • Information
  • Who is online

    Users browsing this forum: w00f and 1 guest