I am trying to build a webshop with the headless client.
At first I hard coded the menu and everything worked fine.
But then I placed the menu in another .jsp, retreived the menu items from my db and included it in my index file.
Now the data in my main grid isn't loaded anymore ??
Here is my full code :
index.jsp
- Code: Select all
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ page import = "java.util.*" %>
<%@ page import = "com.servoy.j2db.server.headlessclient.*" %>
<%@ page import = "com.servoy.j2db.util.*" %>
<%@ page import = "com.servoy.j2db.dataprocessing.IDataSet" %>
<%@ page errorPage="errorpage.jsp" %>
<%
ISessionBean servoy_hc = (ISessionBean)session.getAttribute("servoy");
if (servoy_hc == null)
{
servoy_hc = HeadlessClientFactory.createSessionBean(request,"headless_client_demo");
session.setAttribute("servoy",servoy_hc);
}
boolean ok = servoy_hc.setMainForm("article");
if (!ok)
{
out.print("error cannot work on required form");
return;
}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Globis Online</title>
<link href="style/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="header_top"></div>
<div id="container">
<div id="header">
<div id="header_top"></div>
<div id="header_logo">
<div id="header_nav">
<p class="nav_top"><a href="#">Account</a></p>
<p class="nav_top"><a href="#">Zoeken</a></p>
<p class="nav_top"><a href="#">Winkelwagen</a></p>
<p class="nav_top_nospacer"><a href="#">Inloggen</a></p>
</div>
<div id="header_search">
<form method="post">
<input id="search_field" type="text" name="search_keywords" value=""/>
</form>
</div>
<div id="header_cart">
<h1>WINKELWAGEN</h1>
Geen artikelen
</div>
</div>
</div>
<div id="content_container">
<div id="sidebar">
<ul id="nav_menu">
<%@ include file="navigation_maingroups.jsp" %>
</ul>
<div id="spotlight">
</div>
</div>
<div id="mainContent">
<h1 id="titleMain">ARTIKEL CATALOGUS</h1>
<%
String s;
int number;
for (int i = 0 ; i < 70 ; i++)
{
number = i%3;
s = "<div class=\"grid"+number+"\"><h1>"+servoy_hc.getDataProviderValue(null,"article_code")+"</h1>";
s += "<h2>"+servoy_hc.getDataProviderValue(null,"article_to_articletranslations$full_description$language_code_user.description")+"</h2>";
s += "<div class=\"detail_link\"><a href=\"article_detail.jsp?id="+servoy_hc.getDataProviderValue(null,"article_id")+"\">Detail</a></div></div>";
servoy_hc.executeMethod(null,"nextRecord",null);
if(number == 2)
{
s += "<div><hr /></div>";
}
out.print(s);
}
%>
</div>
</div>
</div>
</body>
</html>
navigation_maingroups.jsp
- Code: Select all
<%
ISessionBean servoy_hc_nav = (ISessionBean)session.getAttribute("servoy");
if (servoy_hc_nav == null)
{
servoy_hc_nav = HeadlessClientFactory.createSessionBean(request,"headless_client_demo");
session.setAttribute("servoy",servoy_hc_nav);
}
boolean ok_nav = servoy_hc_nav.setMainForm("navigation_maingroups");
if (!ok_nav)
{
out.print("error cannot work on required form");
return;
}
%>
<ul id="nav_menu">
<%
int i_nav = 1;
String s_nav = "";
servoy_hc_nav.executeMethod(null,"getFirstRecord",null);
while(i_nav<27)
{
servoy_hc_nav.executeMethod(null,"getNextRecord",null);
s_nav += "<li><a href=\"#\">"+servoy_hc_nav.getDataProviderValue(null,"articlemaingroup_code")+"</a></li>";
i_nav++;
}
out.print(s_nav);
%>
</ul>
I have no idea what is happening here..Maybe something with the controller?
Thank you.
Robrecht Van Melckebeke