Kombinierte Ansicht Flache Ansicht Baumansicht
Threads [ Zurück | Nächste ]
toggle
hamza jemai
Redefine a javaScript file
2. April 2013 10:08
Antwort

hamza jemai

Rang: Junior Member

Nachrichten: 40

Eintrittsdatum: 4. Dezember 2012

Neue Beiträge

I want to redefine a javascript file in my liferay project, i'm using a jar thats contains this file but i want to add same modification to this file so how can i do it ? Thanks
Riggy D
RE: Redefine a javaScript file
2. April 2013 10:41
Antwort

Riggy D

Rang: New Member

Nachrichten: 2

Eintrittsdatum: 2. April 2013

Neue Beiträge

At least to my knowledge you have to extract the contents of the jar file, do you modifications, and jar the file again.

Also check out http://stackoverflow.com/questions/1224817/modifying-a-file-inside-a-jar for different suggestions and comments. emoticon
hamza jemai
RE: Redefine a javaScript file
2. April 2013 11:55
Antwort

hamza jemai

Rang: Junior Member

Nachrichten: 40

Eintrittsdatum: 4. Dezember 2012

Neue Beiträge

I will explain, in my example i'am using the Mindmap from Primefaces, and i want to change the position of node, i successfully get the javascript file for displaying
component and i keep him in my /js folder and of course in liferay-portlet.xml "<header-portal-javascript>/js/mindmapJS.js</header-portal-javascript>" but when i run my portlet i have this in the consol :
WARN [http-localhost-127.0.0.1-8080-6][404_jsp:101] /js/mindmapJS.js
Thanks
Neil Griffin
RE: Redefine a javaScript file
2. April 2013 12:07
Antwort

Neil Griffin

LIFERAY STAFF

Rang: Liferay Legend

Nachrichten: 2145

Eintrittsdatum: 26. Juli 2005

Neue Beiträge

I might be able to provide some help, but when you get a chance, I need to confirm something first. Can you please confirm that mindmapJS.js is contained inside of primefaces.jar and that it is automatically added to the <head>...</head> section of the portal page automatically when you use the p:mindMap component in your XHTML view?
hamza jemai
RE: Redefine a javaScript file
3. April 2013 02:14
Antwort

hamza jemai

Rang: Junior Member

Nachrichten: 40

Eintrittsdatum: 4. Dezember 2012

Neue Beiträge

Thanks Neil,
- in the jar i have mindmap.js i just rename it.
- i have declared the file in my XHTML :
<h:head>
<script type="text/javascript" src="/js/mindmapJS.js"></script>
</h:head>
Juan Gonzalez
RE: Redefine a javaScript file
3. April 2013 05:08
Antwort

Juan Gonzalez

LIFERAY STAFF

Rang: Liferay Legend

Nachrichten: 1970

Eintrittsdatum: 28. Oktober 2008

Neue Beiträge

Hi Hamza,

How did you rename the js? Did you copied the js outside the jar file?

BTW, for resources guess you have to declare it this way:

<h:outputScript ... />

instead of using <script>
Neil Griffin
RE: Redefine a javaScript file
3. April 2013 05:22
Antwort

Neil Griffin

LIFERAY STAFF

Rang: Liferay Legend

Nachrichten: 2145

Eintrittsdatum: 26. Juli 2005

Neue Beiträge

Hi Hamza,

Juan is right -- it is a good idea to use h:outputScript if possible.

One concern I have, is that your current approach of <h:head><script ... /></h:head> doesn't address the problem of having two copies of mindMap.js being downloaded: 1) from the primefaces.jar file and 2) your customized one.

When you get a chance, can you verify my concern? If there are two on the page, then I can recommend a way to use a JSF2 ResourceHandler to fix that.

Neil
hamza jemai
RE: Redefine a javaScript file
3. April 2013 06:15
Antwort

hamza jemai

Rang: Junior Member

Nachrichten: 40

Eintrittsdatum: 4. Dezember 2012

Neue Beiträge

Hi Juan , hi Neil
I tried your approch and i keep this in my xhtml file : <h:outputScript library="js" name="mindmap.js" target="head" />
and i have this error :
ERROR [MissingResourceImpl:112] Resource handler=[com.liferay.faces.bridge.application.ResourceHandlerOuterImpl@59a7f372] was unable to create a resource for resourceName=[mindmap.js] libraryName= contentType=
ERROR [BaseURLEncodedStringImpl:57] URL path must start with a '/' or include '://'
java.lang.IllegalArgumentException: URL path must start with a '/' or include '://'


Thanks a lot
Neil Griffin
RE: Redefine a javaScript file
3. April 2013 06:22
Antwort

Neil Griffin

LIFERAY STAFF

Rang: Liferay Legend

Nachrichten: 2145

Eintrittsdatum: 26. Juli 2005

Neue Beiträge

Hi Hamza,

When you get a chance, please revert back to your <h:head><script ...></script></h:head> solution and let me know if you see the mindMap.js file appearing twice in the <head>...</head> section of the portal page.

Thanks,

Neil
Juan Gonzalez
RE: Redefine a javaScript file
3. April 2013 06:22
Antwort

Juan Gonzalez

LIFERAY STAFF

Rang: Liferay Legend

Nachrichten: 1970

Eintrittsdatum: 28. Oktober 2008

Neue Beiträge

Can you post what's your resources tree inside your project?

By convention, you should have a js folder inside a "resources" folder.
hamza jemai
RE: Redefine a javaScript file
3. April 2013 06:31
Antwort

hamza jemai

Rang: Junior Member

Nachrichten: 40

Eintrittsdatum: 4. Dezember 2012

Neue Beiträge

HI Neil, sorry but it's not appear
Hi Juan, i attache a picture to explain the tree project
Anhänge:
Juan Gonzalez
RE: Redefine a javaScript file
3. April 2013 06:34
Antwort

Juan Gonzalez

LIFERAY STAFF

Rang: Liferay Legend

Nachrichten: 1970

Eintrittsdatum: 28. Oktober 2008

Neue Beiträge

Can you try moving mimdmap.js to webapp/resources/js ?

Remember that your file is mindmap.js NOT mindmapJS.js when adding <h:outputScript ../>
Neil Griffin
RE: Redefine a javaScript file
3. April 2013 06:48
Antwort

Neil Griffin

LIFERAY STAFF

Rang: Liferay Legend

Nachrichten: 2145

Eintrittsdatum: 26. Juli 2005

Neue Beiträge

Hi Hamza,

I just looked at the source code for org.primefaces.component.mindmap.MindMap and saw this:

1@ResourceDependency(library="primefaces", name="mindmap/mindmap.js")


So if you have the <p:mindMap ... /> component tag in your XHTML view, then the mindmap.js resource should automatically be included in the <head>...</head> section of the portal page.

Neil
Juan Gonzalez
RE: Redefine a javaScript file
3. April 2013 06:56
Antwort

Juan Gonzalez

LIFERAY STAFF

Rang: Liferay Legend

Nachrichten: 1970

Eintrittsdatum: 28. Oktober 2008

Neue Beiträge

Neil Griffin:
Hi Hamza,

I just looked at the source code for org.primefaces.component.mindmap.MindMap and saw this:

1@ResourceDependency(library="primefaces", name="mindmap/mindmap.js")


So if you have the <p:mindMap ... /> component tag in your XHTML view, then the mindmap.js resource should automatically be included in the <head>...</head> section of the portal page.

Neil


Seems that's the best option.

Good catch! :-)