adminfaces / admin-template

JSF responsive admin template based on Bootstrap and AdminLTE
https://adminfaces.github.io/docs/latest/#admin_template
MIT License
212 stars 102 forks source link

Provide example of content loaded via Ajax instead of page redirect #185

Open tulkas85 opened 5 years ago

tulkas85 commented 5 years ago

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 ?

rmpestano commented 5 years ago

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

tulkas85 commented 5 years ago

I hope is clear in this example:

adminfaces_question

I don't want this menu refresh on click.

rmpestano commented 5 years ago

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

tulkas85 commented 5 years ago

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

rmpestano commented 5 years ago

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.

tulkas85 commented 5 years ago

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/

rmpestano commented 5 years ago

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

tulkas85 commented 5 years ago

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

rmpestano commented 5 years ago

:+1:

tulkas85 commented 5 years ago

thank you