admin-template icon indicating copy to clipboard operation
admin-template copied to clipboard

Provide example of content loaded via Ajax instead of page redirect

Open tulkas85 opened this issue 6 years ago • 10 comments

I'm working on top of Admin-starter-tomcat project. I'm using "sidebar-menu tree" on the left, but I don't want it collapse when click on submenu link.

Same problem is in admin-showcase demo, If you click Ui Element-> Accordion and then UIElement ->AutoComplete , you can see UiElement close and open again. Maybe all sidemenu is reloaded.

It's possible to leave expanded submenu when click same submenu items ?

  • AdminFaces version: 4.0.0
  • PrimeFaces version: 7.0
  • JSF implementation:

tulkas85 avatar Jun 28 '19 09:06 tulkas85

Hi, can you take a screenshot to make sure we're talking about the same thing? Thanks

rmpestano avatar Jun 28 '19 10:06 rmpestano

I hope is clear in this example:

adminfaces_question

I don't want this menu refresh on click.

tulkas85 avatar Jun 28 '19 10:06 tulkas85

Well there is a page reload, that's why it refreshes. This is needed because you're navigating to a different page. If you stay on the same page and reload content via ajax (imitating a SPA), the menu will not refresh

rmpestano avatar Jun 28 '19 11:06 rmpestano

I thought only "content" div change when new page is selected. There is a way in admin-template to change only "content" div ?

tulkas85 avatar Jun 28 '19 12:06 tulkas85

yea but keep in mind that this is not a admin-template thing but how the web works.

You can reload the content div via ajax when you click on menu link instead of redirecting user to a new page but you'll need to take care of other things like the page url, how to bookmark pages, JSF viewScoped beans ( viewScope beans are alive as long the page doesn't change), you'll need to save the state somewhere to know what to render in content div, handle the browser back button and so on, probably there is a dozen of other problems to take care.

So I prefer to keep things simple and just redirect user to a new page which has its own JSF managed bean and it works pretty great.

PS: Some (5) years ago I did that (content reload via ajax) in an old framework I maintained using JSF, you still can see the example here where the pageControl panel is updated via ajax and statelessPersonMBean.beanState decides which pages (find, list, update, friends) will be rendered.

rmpestano avatar Jun 28 '19 13:06 rmpestano

I know how works SPA, I thought admin-template works as SPA, like AdminLTE.

Here you can see how AdminLTE left menu works : https://adminlte.io/themes/AdminLTE/

tulkas85 avatar Jun 28 '19 13:06 tulkas85

again, the template doesn't enforce it, it just turns out that we don't have examples where the content is loaded via ajax.

rmpestano avatar Jun 28 '19 13:06 rmpestano

ok, thank you. Maybe in future you can post some examples or an "admin-starter-ajax" project that works like AdminLTE using ajax ?

tulkas85 avatar Jun 28 '19 14:06 tulkas85

:+1:

rmpestano avatar Jun 28 '19 14:06 rmpestano

thank you

tulkas85 avatar Jun 28 '19 14:06 tulkas85