JSP to import all acquisitions from a directory

Asked

Viewed 332 times

0

It is possible import all files in a directory with only one call working with JSP ?

Today I have the following:

<script src="../resources/js/angular/directive/layout/mensagem.js"
    charset="utf-8"></script>
<script src="../resources/js/angular/directive/layout/cabecalho-interno.js"
    charset="utf-8"></script>

I want something like that:

<script src="../resources/js/angular/directive/layout/*.js"
    charset="utf-8"></script>
  • It is not possible (JSP compatible)... you can create an outline solution to achieve this goal.

  • Could you specify what solution @Marllonnasser ? Thank you.

  • posted as "answer", Mayllon... I do not know if it will meet you :)

2 answers

0

Import all at once I’ve never seen it, but if it’s many Imports, you can isolate them in a file and import.

<%@ include file="imports.html" %>
<jsp:include page="imports.html" />
  • Thanks for the @Matheus Silva reply, but I already have a file where I will import all the files. I want a solution to not need to import file by file, also never seen it with JSP’s, but I’ve worked like this in C#.

0

Unfortunately this is not yet supported by JSP..

Some solutions of contour:

1- Override the method encodeEnd() of ScriptRenderer.. (This is kind of complicated.... and also depends on the JSF version..)

2- Put the list of files in the bean and make a repeat loop to traverse such a property and add to head, something like:

<ui:repeat value="#{seuBean.arquivos}" var="arq">
    <h:outputScript library="javascript" name="#{arq}" target="head" />
</ui:repeat>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.