JSF page splitting - jsf

During working with JSF 1.2 one page code is too large and JDeveloper gave too large code in service method exception. Now I want to split my JSF file in smaller files. During splitting I need some help and suggestion.
Beacuse the whole page binds with a single bean, is it also necessary to split the bean? If not, then how to overcome this? What is the best way to split JSF file and include in main page?

You don't need to split the bean. You could just split the page fragments over multiple files which you include by <jsp:include> (and not by #include as that happens during compiletime and you would end up with still the same exception!). Note that you should store those include files in /WEB-INF folder to prevent direct access by enduser.
So given this example of an "extremely large" page,
<%#taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%#taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div>
large chunk 1
</div>
<div>
large chunk 2
</div>
<div>
large chunk 3
</div>
</body>
</html>
You could split it as follows while keeping the beans:
<%#taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%#taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<jsp:include page="/WEB-INF/includes/include1.jsp" />
<jsp:include page="/WEB-INF/includes/include2.jsp" />
<jsp:include page="/WEB-INF/includes/include3.jsp" />
</body>
</html>
and /WEB-INF/includes/include1.jsp:
<%#taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%#taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<div>
large chunk 1
</div>
and /WEB-INF/includes/include2.jsp:
<%#taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%#taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<div>
large chunk 2
</div>
and /WEB-INF/includes/include3.jsp:
<%#taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%#taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<div>
large chunk 3
</div>

Related

Node js .ejs files main index

I followed this tutorial on sctoch.io to use ejs files but I'm looking for a main index to include the current page.
In the tutorial we will add head, header and footer inside all news pages.
But I want to write this once. For example :
<html lang="en">
<head>
<% include ../partials/head %>
</head>
<body class="container">
<header>
<% include ../partials/header %>
</header>
<main>
<!-- Here is that I want -->
<% include ../partials/main %>
</main>
<footer>
<% include ../partials/footer %>
</footer>
</body>
</html>
How can I do load the good page inside the main file when I clic on different link of my navbar ?
First of all you will have to use Express and his template engine(views),so just add header and footer in every new file you make
<% include header %>
<!-- yout html code -->
<% include footer %>
And when you render it simply say
res.render('YourNewFile');
Your header should look something like this..
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<title><%- title %></title>
<link rel="stylesheet" href="/css/style.css">
</head>
<body>
And footer ..just close all tags ..and load some scripts if u want in it
<script src="..."></script>
</body>
</html>

Customizing spree layouts

I'm new to spree and stuck in layouts.
I created a new application and installed spree in it.
I wanted to create a totally static home page.
What I did is I copied following files to my application views directory and edited them:
spree\layouts\spree_application.html.erb
spree\shared\_head.html.erb
spree\shared\_head.htmler.erb
I was able to display the new page but the problem is that it affected admin page as well.
What I want to do is just select a particular layout file for my frontend pages so that admin remains as it is.
Update:
I did this for now:
Copied the _head.html.erb file and edited like this:
<meta charset="utf-8">
<title><%= title %></title>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1" name="viewport">
<%== meta_data_tags %>
<%= canonical_tag(current_store.url) %>
<%= favicon_link_tag 'favicon.ico' %>
<%= stylesheet_link_tag 'spree/frontend/all', media: 'screen' %>
<%= yield :header_css %>
<%= csrf_meta_tags %>
<%= javascript_include_tag 'spree/frontend/all' %>
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.6/html5shiv.min.js"></script>
<![endif]-->
<%= yield :head %>
<%= yield :header_js %>
This way, I'm able to include my custom css and js
Still my question remains the same.

No image showup using expressJs

I do have a small issue i can't solved despite reading on internet.
I'm learning node.js, express.js, ejs.
I create a small app that tries to display a dynamic webpage on my local server.
The code is working but not the display of the pictures! (the stylesheet works fine)
here is my index.ejs
<!DOCTYPE html>
<html lang="en">
<head>
<% include partials/head %>
</head>
<body class="container">
<header>
<% include partials/header %>
</header>
<main>
<h1><%= title %> </h1>
<img scr="/images/logo_small.jpg" alt="logo" />
<p> Welcome to <%= title %></p>
</main>
<footer>
<% include partials/footer %>
</footer>
</body>
</html>
In the main apps i wrote:
app.use(express.static(path.join(__dirname, 'public')));
And finally i put the images in ./public/images/logo_small.jpg.
The display shows "logo" instead of the pictures. When I go this URL
http://localhost:3000/images/logo_small.jpg
Firefox shows me the image. it is frustrating!
I miss something here, but i don't see what. Any idea ?

how to single h:panelgrid into apply colspan?

USe lib <%# taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
how to apply single panel grid in colspan?

Is there a way to ignore tags in a dustJS template

We have a lot of spring, jsp and jstl tags in our templates that we wish to include. Can we make dust ignore these tags?
<sec:authorize access="!hasRole('ROLE_USER')">
<a>Blah</a>
</sec:authorize>
<sec:authorize access="hasRole('ROLE_USER')">
<a>Foo</a>
</sec:authorize>
or
<%# taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%#taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%#taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%#taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%# taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%# taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
Use the parser expression grammar to ignore special delimiters, which would look something like this:
= ld [^%] ws* [#?^><+%:#/~%] ws* (!rd !eol .)+ ws* rd
References
dustjs / src / dust.pegjs
dust.pegjs is a bunch of regexes that output an array
peg.js Online Tester

Resources