Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

dynamic load of jsp pages in div

843844Mar 26 2010 — edited Mar 29 2010
Hello all, this is my first post so i hope everything goes well.
I started to learn JSF and i'm developing a small application.

Well my problem is with <jsp:include>. Is it possible to deploy dynamic pages into div layers in my page? i have a sidebar (a tag layer as well) where i have some commandLinks with operations and what i want to do is when i click one of them it loads a .jsp page, dynamically, into a container div i have on the right. Those pages are subviews and they are loading if i call them directly with jsp:inclu.
It has been 3 long days of search about this issue.

I tried javascript, ajax, etc (however i think it is a little bit insecure) after that i tried with listeners but it doesnt load the page. Is there a way of doing this? (i hope im being explicit).

First attempt:
main.jsp
<div class="sidebar_div">
				<h3>Operations</h3>
				<h:form>
					<h:commandLink actionListener="#{dynamicDivListener.processAction}" id="users" value="Users" immediate="true" action=""></h:commandLink>
					<p>
					<h:commandLink actionListener="#{dynamicDivListener.processAction}" id="add_user" value="Add User" immediate="true" action=""></h:commandLink>
					</p>
				</h:form>
			</div>
			<div class="content_div">				
				<jsp:include page="#{dynamicDivListener.path}" flush="true"></jsp:include>
			</div>
I use the listeners to change the page and when i click the commandLinks they are working well, in the console i have some prints when i click:
INFO: Server startup in 1618 ms
users
add_user
users
add_user

But in the container div where i want to load the pages i get this error:
*The requested resource (/JSFProject/#{dynamicDivListener.path}) is not available*

The listener:
public class dynamicDivListener implements ActionListener {

	private String path = "/scriptlets/searchUser.jsp";

	public String getPath() {
		return path;
	}

	@Override
	public void processAction(ActionEvent arg0) throws AbortProcessingException {
		UIComponent uic = arg0.getComponent();
		String id = uic.getId();
		if (id.equalsIgnoreCase("add_user"))
			path = "/scriptlets/registerUser.jsp";
		if (id.equalsIgnoreCase("users"))
			path = "/scriptlets/searchUser.jsp";

		System.out.println(id);

		FacesContext context = FacesContext.getCurrentInstance();
		context.renderResponse();
	}

	public void setPath(String path) {
		this.path = path;
	}
}
I really hope that i could learn something from the community, if this doesnt work how can i manage to get this?
JSF only support tipical pageflow?

[EDIT]: i sorry if this doubt was to be posted in the JSP section, if so my bad and im sorry. I didnt know where should i put it.
Regards.

Edited by: t.pateiro on Mar 26, 2010 3:29 PM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 26 2010
Added on Mar 26 2010
1 comment
1,085 views