B4J Question include/require on B4J server?

Douglas Farias

Expert
Licensed User
Longtime User
Hi all.
i m trying to use the B4J Server to replace the PHP/Apache.

so far I'm enjoying it, everything is easy.
A small doubt, I have been using PHP for some time and I got used to some functions, one of which is require or include.
is there any way to do include or require in B4J?

Sometimes it is very useful as, for example, on a website, I usually create a topMenu.php page and use this menu on all other pages like index, contact etc ..., when I need to edit the menu I edit only mine topMenu.php, without having to update page by page.

the code of my PHP pages is usually like this


include "header.php";

include "topMenu.php";

website Content

include "footer";

its possible make this (includes) on B4J? without having to compile .jar all the time?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
One way to do it is by creating a "menu" class and create a class instance in each of the handlers.
You will need to recompile and restart the server after each change. Note that if #MergeLibraries is set to False then the server code jar will be small.

If there is a page that needs to be change frequently then it makes sense to use a database or file to store the information needed to build the page. This way you will not need to compile or restart the server.
 
Upvote 0

Douglas Farias

Expert
Licensed User
Longtime User
One way to do it is by creating a "menu" class and create a class instance in each of the handlers.
You will need to recompile and restart the server after each change. Note that if #MergeLibraries is set to False then the server code jar will be small.

If there is a page that needs to be change frequently then it makes sense to use a database or file to store the information needed to build the page. This way you will not need to compile or restart the server.


OK perfect.
let's assume I compiled the .jar with the topMenu and footer class.
Would it be possible to call the menu class in the middle of a page? (call it via HTML?)
What runs first? the handler or the html content?


for example (index.html):

HTML:
<! DOCTYPE html>
<html>
<head>
<title> Page Title </title>
</head>
<body>

[B]call b4j class menu here <<<<< (chose the place i want to load the class on the code)[/B]

<h1> This is a Heading </h1>
<p> This is a paragraph. </p>

[B]call b4j class footer here <<<<< (chose the place i want to load the class on the code)[/B]

</body>
</html>

i have a big page, with a lot of content in html, a lot of text and images, i wanted to add b4j codes in small parts of this page, it would be a little complicated to transform the entire giant html page into b4j .write.

would there be a way to not have to build the entire page in b4j?


thx
 
Upvote 0
Top