Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
hamza jemai
Redefine a javaScript file
April 2, 2013 10:08 AM
Answer

hamza jemai

Rank: Junior Member

Posts: 40

Join Date: December 4, 2012

Recent Posts

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
April 2, 2013 10:41 AM
Answer

Riggy D

Rank: New Member

Posts: 2

Join Date: April 2, 2013

Recent Posts

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
April 2, 2013 11:55 AM
Answer

hamza jemai

Rank: Junior Member

Posts: 40

Join Date: December 4, 2012

Recent Posts

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
April 2, 2013 12:07 PM
Answer

Neil Griffin

LIFERAY STAFF

Rank: Liferay Legend

Posts: 2363

Join Date: July 26, 2005

Recent Posts

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
April 3, 2013 2:14 AM
Answer

hamza jemai

Rank: Junior Member

Posts: 40

Join Date: December 4, 2012

Recent Posts

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
April 3, 2013 5:08 AM
Answer

Juan Gonzalez

LIFERAY STAFF

Rank: Liferay Legend

Posts: 2892

Join Date: October 28, 2008

Recent Posts

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
April 3, 2013 5:22 AM
Answer

Neil Griffin

LIFERAY STAFF

Rank: Liferay Legend

Posts: 2363

Join Date: July 26, 2005

Recent Posts

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
April 3, 2013 6:15 AM
Answer

hamza jemai

Rank: Junior Member

Posts: 40

Join Date: December 4, 2012

Recent Posts

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
April 3, 2013 6:22 AM
Answer

Neil Griffin

LIFERAY STAFF

Rank: Liferay Legend

Posts: 2363

Join Date: July 26, 2005

Recent Posts

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
April 3, 2013 6:22 AM
Answer

Juan Gonzalez

LIFERAY STAFF

Rank: Liferay Legend

Posts: 2892

Join Date: October 28, 2008

Recent Posts

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
April 3, 2013 6:31 AM
Answer

hamza jemai

Rank: Junior Member

Posts: 40

Join Date: December 4, 2012

Recent Posts

HI Neil, sorry but it's not appear
Hi Juan, i attache a picture to explain the tree project
Attachments:
Juan Gonzalez
RE: Redefine a javaScript file
April 3, 2013 6:34 AM
Answer

Juan Gonzalez

LIFERAY STAFF

Rank: Liferay Legend

Posts: 2892

Join Date: October 28, 2008

Recent Posts

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
April 3, 2013 6:48 AM
Answer

Neil Griffin

LIFERAY STAFF

Rank: Liferay Legend

Posts: 2363

Join Date: July 26, 2005

Recent Posts

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
April 3, 2013 6:56 AM
Answer

Juan Gonzalez

LIFERAY STAFF

Rank: Liferay Legend

Posts: 2892

Join Date: October 28, 2008

Recent Posts

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! :-)