Headless Client Examples

Share business templates, ideas, experiences, etc with fellow Servoy developers here

Headless Client Examples

Postby bcusick » Sat Jan 29, 2005 12:21 am

I've put together the headless client demos (2 of them) with 2 solutions. You can download from here:

http://developer.servoy.com/downloads/headless_client_examples.zip

Hope this helps inspire you to work with the headless client.
Bob Cusick
bcusick
 
Posts: 1255
Joined: Wed Apr 23, 2003 11:27 pm
Location: Thousand Oaks, CA USA

Postby Bert » Sat Jan 29, 2005 5:59 pm

Very nice work Bob 8) ... Thanks.
Looking forward putting Headless Clients on a Headless Mac Mini :idea:
Bert de Graaff
ATB Software Servoy Developer manage your business anywhere
User avatar
Bert
 
Posts: 201
Joined: Tue May 20, 2003 11:16 am
Location: Stramproy - NL

Postby Westy » Mon Jan 31, 2005 5:41 am

I have the two sample solutions up and running. Very impressive. More powerful than I expected and extremely easy for the end user.

One possible bug is that when I go to exit the solution, a dialog appears that states "Application server will be shutdown, please close within 3 minutes." Then Servoy appears to hang with the following message in the status bar at lower left of screen: "Informing clients about shutdown." However, all browser clients are already closed and no Servoy Clients are open. I am still not sure how to make the Headless Client work with Servoy's built-in security.

Otherwise, everything works extremely well. Everyone should be sure to take a look at these two samples. The first one shows a Customer list, Company details, and Orders per Company with sum totals, all viewable in a browser via desktop, laptop or PDA device, using a single JSP page. The second example shows how to edit and update data, and also how to retrieve valuelist information from your solution and build a pop-up menu. Nice stuff!

I have one coding question. In the Contacts detail what would be the syntax for including a list of phone numbers from a related file?

Great job!
Westy
 
Posts: 852
Joined: Fri Feb 13, 2004 5:27 am
Location: Lynnfield, Massachusetts USA

Postby Karel Broer » Mon Jan 31, 2005 10:46 am

Really great feature! Can't wait to build something nice with it! I do have a slight little problem;
http://localhost:8080/jsp_files/simplelistview.jsp is working perfectly, but I get
Code: Select all
Access is denied or Error occurred

at http://localhost:8080/jsp_files/headless_client_formtest.jsp.

Could it be that this does not work on OS X?
I found out that OS X does not have a separate 'tools.jar'....
Would be to bad, 'cause I host my solutions and websites on an OS X Server...
Karel Broer
ServoyCamp - http://www.servoycamp.com
User avatar
Karel Broer
 
Posts: 779
Joined: Mon May 03, 2004 12:49 am
Location: Doetinchem

Postby bcusick » Tue Feb 01, 2005 2:47 am

Westy wrote:I have the two sample solutions up and running. Very impressive. More powerful than I expected and extremely easy for the end user.


AND for the coder! I mean, if you had to write all of that in JSP - it's tons of work. With Servoy = EASY!

Westy wrote:One possible bug is that when I go to exit the solution, a dialog appears that states "Application server will be shutdown, please close within 3 minutes." Then Servoy appears to hang with the following message in the status bar at lower left of screen: "Informing clients about shutdown." However, all browser clients are already closed and no Servoy Clients are open.


Best thing to do is to log into the Servoy Server (http://yourIP:8080/servoy-admin/) then go to the "clients" tab and DISCONNECT the headless client (click the red "X"). You need to do that when you make changes to your .jsp page or to a method in your solution that gets called by the page. This will force JSP to create a new session.

Westy wrote:I am still not sure how to make the Headless Client work with Servoy's built-in security.


I'll have to write a sample that shows you how to do that - it EASY to create a method and then use the "Security" settings to check a password. :D

Westy wrote:I have one coding question. In the Contacts detail what would be the syntax for including a list of phone numbers from a related file?


Same as when using a label: relationName.fieldName
Bob Cusick
bcusick
 
Posts: 1255
Joined: Wed Apr 23, 2003 11:27 pm
Location: Thousand Oaks, CA USA

Postby bcusick » Tue Feb 01, 2005 2:49 am

freecolours wrote:I get
Code: Select all
Access is denied or Error occurred

at http://localhost:8080/jsp_files/headless_client_formtest.jsp.

Could it be that this does not work on OS X?


Does work on OS X - David Workman (servoy magazine) has it working. I haven't tried it on my mac yet - but will do.

If you look at the code - it means that the application can't reference that FORM. Did you import both solutions?
Bob Cusick
bcusick
 
Posts: 1255
Joined: Wed Apr 23, 2003 11:27 pm
Location: Thousand Oaks, CA USA

Postby Karel Broer » Tue Feb 01, 2005 2:23 pm

bcusick wrote:Did you import both solutions?


Yes, I did.
Karel Broer
ServoyCamp - http://www.servoycamp.com
User avatar
Karel Broer
 
Posts: 779
Joined: Mon May 03, 2004 12:49 am
Location: Doetinchem

Postby bcusick » Tue Feb 01, 2005 3:01 pm

Rather than put the LOGIN example in another solution and make you download it - I'm going to just post the code.

To make this example work:

1) Make a new solution called "example_headless_client_03" and make a form called "login" (doesn't have to have anything on it).

2) Make a FORM-BASED method called "login" with this code:
Code: Select all
var noPass = "<font color='#990000'><b>Invalid Login.</b> Try again.</font><br>"
var isOK = "<font color='#009900'><b>VALID LOGIN!</b> Contratulations.</font><br>"
var isEmpty = "<font color='#990000'><b>No criteria entered.</b> Try again.</font><br>"

var name = arguments[0]
var pass = arguments[1]

if(name == null || name == '' || pass == null || pass == '')
{
   //something is blank - return false
   return isEmpty
}

var userId = security.getUserId(name)

if(security.checkPassword(userId, pass))
{
   //they were ok
   return isOK
}
else
{
   //no match
   return noPass
}


3. Create a new text document and paste in the code below and save inside the servoy/server/webapps/root/example/ folder:

Code: Select all
<%@ page import = "java.util.*" %>
<%@ page import = "com.servoy.j2db.server.headlessclient.*" %>
<%@ 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,"example_headless_client_03");
      session.setAttribute("servoy",servoy_hc);
   }
   boolean ok = servoy_hc.setMainForm("login");
   if (!ok)
   {
      servoy_hc = HeadlessClientFactory.createSessionBean(request,"example_headless_client_03");
      session.setAttribute("servoy",servoy_hc);
   }
   
   String theTable = null;
   String isSubmit = request.getParameter("isSubmit");
   
   if (null!=isSubmit)
   {
      theTable = (String)servoy_hc.executeMethod(null,"login",new Object[]{request.getParameter("username"),request.getParameter("password")});
   }

%>
<html>
<head>

<style type="text/css">
<!--
body {
   font-family: Verdana, Arial, Helvetica, sans-serif;
   font-size: 24px;
   color: #333333;
}
a{
   text-decoration: none;
   font-size: 11px;
   font-family:  verdana, sans-serif;
}
A:link
{
   color: #036;
}

A:visited
{
   color: #036;
}

A:active
{
   text-decoration: underline;
   color: #F90;
}

A:hover
{
   text-decoration: underline;
   color: #F90;
}

td
{
   font-size: 11px;
   border-color: #CCCCCC;
   border-width: 1;
   border-style: solid;
}
td.sub
{
   background-color: #003366;
   color: #FFFFFF;
}
td.red
{
   background-color: #990000;
   color: #FFFFFF;
}
table
{
   border-color: #CCCCCC;
   border-width: 1;
   border-style: solid;
}
td.lg
{
   color: #FFFFFF;
   background-color: #999999;
}
.small
{
   font-size: 10px;
}
.x-small
{
   font-size: 8px;
}
-->
</style>

<title>Servoy Headless Client Login Example</title>
</head>
<body onload="javascript:document.loginform.username.focus()">
  <%
     if (theTable!=null) out.println(theTable);
%>
  <form name="loginform" method="post" action="simplelogin.jsp">
    <table border="0" cellspacing="0" cellpadding="2">
      <tr>
        <td colspan="2" class="sub">&nbsp;<b>Login</b></td>
      </tr>
      <tr>
        <td>Username</td>
        <td><input name="username" type="text" id="username" size="15" maxlength="30"></td>
      </tr>
      <tr>
        <td>Password</td>
        <td><input name="password" type="password" id="password" size="15" maxlength="30"></td>
      </tr>
      <tr>
        <td colspan="2" align="right">
          <input name="Submit" type="submit" value="Submit">
        <input type="hidden" name="isSubmit" value="1">
        </td>
      </tr>
    </table>
  </form>
</body>
</html>


4. Open a browser and enter the URL: http://yourIP:8080/examples/simplelogin.jsp If you enter ANY valid username and password (in YOUR Servoy Security) - you should get a "Valid Login" message.

Hope this helps.
Bob Cusick
bcusick
 
Posts: 1255
Joined: Wed Apr 23, 2003 11:27 pm
Location: Thousand Oaks, CA USA

Re: Headless Client Examples

Postby garry.mack » Mon Feb 04, 2013 12:47 am

Hey Bob,

I was wondering if you have a unbroken link to these headless client solutions mentioned above?
garry.mack
 
Posts: 6
Joined: Wed Nov 14, 2012 12:48 am

Re: Headless Client Examples

Postby david » Mon Feb 04, 2013 4:34 pm

garry.mack wrote:Hey Bob,

I was wondering if you have a unbroken link to these headless client solutions mentioned above?


Headless client examples are an installation option when you install Servoy developer. You'll find a headless client directory in your "Servoy/application_server/server/webapps/ROOT" directory if installed them.
David Workman, Kabootit

Image
Everything you need to build great apps with Servoy
User avatar
david
 
Posts: 1727
Joined: Thu Apr 24, 2003 4:18 pm
Location: Washington, D.C.


Return to Sharing Central

Who is online

Users browsing this forum: No registered users and 2 guests

cron