We apologize for untranslated text, you can use the Google Translation button to get an automatic translation of the web page in the language of your choice.

Affichage d'un contenu dans une sidebar

Guillaume Clément · on 7/4/19 at 5:47 PM

Bonjour

Je suis actuellement sur le développement d'un module.

J'ai réussi à créer ce qu'il faut pour ouvrir une sidebar sur le clic d'un contenu.

Mon souci c'est que je ne vois pas comme faire pour afficher ce contenu dans cette sidebar.

Par avance merci,

#1

Bonjour, 

pour ouvrir cette sidebar vous : 

  • Utilisez les attributs data ?
  • Utilisez l'API Javascript ?
Kevin Bransard · on 7/4/19 at 6:04 PM
#2

Ouvrir, il n'y a pas de souci, ce que je voudrais c'est que ce soit le contenu que j'ai cré qui s'affiche dedans

Guillaume Clément · on 7/5/19 at 9:12 AM
#3

il y a un attribut particulier pour passer une variable peut-etre ?

J'ai essayé avec l'attribut "id="toto"" mais il ne remonte que le dernier de mon tableau

Guillaume Clément · on 7/5/19 at 9:16 AM
8 pts
Olivier Jaquemet · on 7/4/19 at 5:55 PM

Bonjour, 

Vous trouverez la documentation des sidebars sur notre site de documentation technique, docs.jalios.com :

https://docs.jalios.com/jplatform10/jcms/fr/front-end/composants/panneau-lateral-du-membre-45597

#1

Oui j'ai vu tout ça mais je n'y trouve pas la réponse dont j'ai besoin... La création + l'ouverture pas de problème.

C'est l'affichage d'un contenu que j'ai créé que je n'arrive pas à faire...

Guillaume Clément · on 7/5/19 at 10:17 AM
1 pt
Kevin Bransard · on 7/5/19 at 3:12 PM

Voici ce que j'utilise dans certains développements : 

!(function($) {

var selectedItemId;


$(document).ready(function() {
  $(document).on("click", ".item", function(event) {
    selectedItemId = $(event.currentTarget).data("jalios-data-id");
    // Ouverture programmatique de la sidebar
  });


  $(document).on("show.jalios.sidebar", function(event) {
    let $sidebar= $(event.target);
    if (!$sidebar.hasClass("my-sidebar-selector")) {
      return;
    }
    $(".my-sidebar-inner-ajax-div").refresh({
      itemId: selectedItemId
    });
  });
});

})(window.jQuery);

Qui fonctionnerait donc avec le DOM suivant : 

<div>
  <a class="item" data-jalios-data-id="ItemId"></a>
  
</div>
<div class="sidebar3 sidebar-component is-closed sidebar-left" data-jalios-sidebar-direction="left" data-jalios-sidebar-overlay="false">
  <a class="btn btn-default pull-right" data-jalios-sidebar-action="close" data-jalios-sidebar-target=".sidebar3">
    Fermer la sidebar
  </a>
  <jalios:include jsp="ajaxJsp.jsp" />
</div>

et ajaxJsp : 

<%@ include file='/jcore/doInitPage.jspf' %><%

Publication item = getPublicationParameter("itemId"); 

%>
<div class="ajax-refresh-div" data-jalios-ajax-refresh-url="ajaxJsp">
  <%= item.getTitle() %>
</div>
#8

C'est bizarre... Tout se passe plutôt bien mais il me met une erreur sur la ligne 140

Exception in 'APP Portal - Selection'

Message: org.apache.jasper.JasperException: An exception occurred processing JSP page [/plugins/CCPC19PetiteEnfance/jsp/AppRPE/demandesRpe_outilsDuRpe.jsp] at line [140]

137: <div>
138: <%Publication item = getPublicationParameter("itemId");%>
139: <div class="ajax-refresh-div" data-jalios-ajax-refresh-url="ajaxJsp">
140: <%= item.getId() %>
141: </div>
142: </div>
143: <%-- <%String var_id = request.getParameter("id"); %>
Guillaume Clément · on 7/8/19 at 3:00 PM
#9

Le paramètre est censé être envoyé en ajax via cette ligne : 

    $(".my-sidebar-inner-ajax-div").refresh({
      itemId: selectedItemId
    });

Il faut regarder ce qui se passe dans votre JS, si il n'y a rien dans la requête XHR envoyée, c'est que le javascript n'a pas réussi à récupérer l'id stocké sur le data attribute.

Kevin Bransard · on 7/8/19 at 3:04 PM
#10

XHR ? comment le vérifer ?

Guillaume Clément · on 7/9/19 at 4:48 PM
1 pt
Guillaume Clément · on 7/10/19 at 2:25 PM

Bonjour @Kevin Bransard 

Alors j'ai réussi à sortir quelque chose en bricolant avec ce que tu m'a donné et d'autre chose... et bizarrement il me remonte l'id du portail racine...

J'ai l'impression que je passe à côté e quelque chose parce que je parviens à pousser l'id du contenu vers la jsp mais il ne l'ouvre pas en sidebar... Bizarre 

0 pts
Guillaume Clément · on 7/17/19 at 11:10 AM

Bonjour @Kevin Bransard 

Voilà le point d'étape ... Je te confirme que ce que tu m'as donné fonctionne dans sa grande partie .... Mais j'ai l'impression que la donnée ne passe pas dans le tuyau...😉

[Capture d ecran][GClément]2019-07-17 Image numero 01 

Voilà le message d'erreur complet :

Exception in 'plugins/CCPC19PetiteEnfance/jsp/AppRPE/ajaxJsp.jsp'

Message: An exception occurred processing JSP page [/plugins/CCPC19PetiteEnfance/jsp/AppRPE/ajaxJsp.jsp] at line [8]

5:
6: %>
7: <div class="ajax-refresh-div" data-jalios-ajax-refresh-url="ajaxJsp">
8: <%= item.getTitle() %>
9: </div>


Stacktrace:

Stack Trace:
java.lang.NullPointerException
at org.apache.jsp.plugins.CCPC19PetiteEnfance.jsp.AppRPE.ajaxJsp_jsp._jspService(ajaxJsp_jsp.java:1075)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:443)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:728)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:590)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:524)
at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:895)
at org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:648)
at com.jalios.jcms.taglib.IncludeTag.include(IncludeTag.java:424)
at com.jalios.jcms.taglib.IncludeTag.include(IncludeTag.java:322)
at com.jalios.jcms.taglib.IncludeTag.doEndTag(IncludeTag.java:286)
at org.apache.jsp.plugins.CCPC19PetiteEnfance.jsp.AppRPE.demandesRpe_005foutilsDuRpe_jsp._jspx_meth_jalios_005finclude_005f3(demandesRpe_005foutilsDuRpe_jsp.java:2236)
at org.apache.jsp.plugins.CCPC19PetiteEnfance.jsp.AppRPE.demandesRpe_005foutilsDuRpe_jsp._jspService(demandesRpe_005foutilsDuRpe_jsp.java:1810)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:443)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:728)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:590)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:524)
at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:895)
at org.apache.jsp.types.PortletSelection.doPortletSelectionFullDisplay_jsp._jspService(doPortletSelectionFullDisplay_jsp.java:1193)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:443)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:728)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:590)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:524)
at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:895)
at org.apache.jsp.types.AbstractPortletSkinable.doAbstractPortletSkinableFullDisplay_jsp._jspService(doAbstractPortletSkinableFullDisplay_jsp.java:1115)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:443)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:728)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:590)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:524)
at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:895)
at org.apache.jsp.types.PortletPortal.doPortletPortalFullDisplay_jsp._jspService(doPortletPortalFullDisplay_jsp.java:1510)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:443)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:728)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:590)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:524)
at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:895)
at org.apache.jsp.types.AbstractPortletSkinable.doAbstractPortletSkinableFullDisplay_jsp._jspService(doAbstractPortletSkinableFullDisplay_jsp.java:1115)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:443)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:728)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:590)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:524)
at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:895)
at org.apache.jsp.display_jsp._jspService(display_jsp.java:1647)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:443)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at com.jalios.jcms.servlet.InitFilter.doFilter(InitFilter.java:85)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at com.jalios.jcms.servlet.FinallyFilter.doFilter(FinallyFilter.java:22)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:728)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:467)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:392)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:311)
at com.jalios.jcms.servlet.DisplayServlet.doGet(DisplayServlet.java:100)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at com.jalios.jcms.servlet.FriendlyURLFilter.doFilter(FriendlyURLFilter.java:92)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at com.jalios.jcms.servlet.GZIPFilter.doFilter(GZIPFilter.java:65)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at com.jalios.jcms.servlet.InitFilter.doFilter(InitFilter.java:211)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at com.jalios.jcms.db.HibernateSessionFilter$1.execute(HibernateSessionFilter.java:40)
at com.jalios.jcms.db.HibernateSessionFilter$1.execute(HibernateSessionFilter.java:34)
at com.jalios.jcms.db.HibernateUtil.executeTransaction(HibernateUtil.java:348)
at com.jalios.jcms.db.HibernateSessionFilter.doFilter(HibernateSessionFilter.java:34)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at com.jalios.jcms.upload.MultipartFilter.doFilter(MultipartFilter.java:186)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at com.jalios.jcms.servlet.FinallyFilter.doFilter(FinallyFilter.java:27)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)

J'ai l'impression que c'est dans ce fichier que ça coince :

!(function($) {

var selectedItemId;


$(document).ready(function() {
$(document).on("click", ".item", function(event) {
selectedItemId = $(event.currentTarget).data("jalios-data-id");
// Ouverture programmatique de la sidebar
});


$(document).on("show.jalios.sidebar", function(event) {
let $sidebar= $(event.target);
if (!$sidebar.hasClass("my-sidebar-selector")) {
return;
}
$(".my-sidebar-inner-ajax-div").refresh({
itemId: selectedItemId
});
});
});

})(window.jQuery);

Qu'en pense tu ?

0 pts