Java DMI - Datasource configuration

Sure.

First, call setValues() on the dynamicForm to populate it with values that you can output via Struts tags.

To submit identically to a normal HTML form (including unloading the current page), set dynamicForm.action to the target URL, set canSubmit:true and call submit() to submit.

Note that this is a very, very incremental approach and it would probably be more fruitful to bind the form to a DataSource and use DMI to contact your business layer. This will allow you to, for example, return validation errors to the form without cause the page to reload. This is a useful first step even if, for now, you just transition to a new page on successful save.

Thanks a lot for your reply. We will defintiely adopt DMI approach for validations. But, can you let us know how to map only those fields which we want to validate or retrieve some objects in run time to go through DMI?

When we tested some samples, we were getting the values in the same java objects in the server side. With the below code, we are able to ge the values in Server in batch object

{ name:“batch.refNumber”, title: “Ref number”,
type: “text”, length: 60, defaultValue:“<s:property value=“batch.refNumber”/>”}

Now, we are facing another issue now. We want to show another list of values from Java and we want to show it using List grid. Is there any way that I can create ListGrid from the java array that my jsp has?

Regards,
Kumbesh

Hi Kumbesh,

Now that you’re past the installation hurdle, it’s a good idea to spend some quality time with the docs and examples. We’d recommend in particular the examples available under Examples -> Java Integration from the start page of the SDK (these are different and more in-depth than the examples found in the Feature Explorer).

In particular there are examples that show how you could dump data as XML in a .jsp. But again, this is a very incremental approach, and you would be better off binding to a DataSource that uses DMI and/or the RPCManager to contact the server on-the-fly, which allows data paging and many other behaviors.

Hi Isomorphic,

Thanks a lot for your timerly replies. As I had mentioed earlier, we have aframework workign across and we are using smart client for front end. SmartClient should talk to Struts, which then connects to SpringDAOs and all are managed by Spring, wrapped by Spring security.

I have few requirements to submit the form through Struts and displaying them back, which I was able to achieve through field values. My next step is to load the values of arraylist, which is comig from action in Struts using ListGrid, but cant acheieve this by mapping to data in Listgrid. Kindly suggest what could be done.

We also have few more issues

a) We can map long datatype from java object to SmartClient field types? Is there a way to overcome?
b) We tried making DMI calls and it is working properly. But, as our framework wraps around Spring Security, we are not able to connect to DAOs using DMIManager bean’s fetch method.
c) We want to include autocomplete feature and thought os using DMI calls to retrieve values. Kindly let us know if there is any readymade or proven ways to do it.

Regards,
Kumbesh

Once again, please try searching the docs. These are extremely basic use cases well covered by SmartClient’s documentation.

An ArrayList of Java Beans or HashMap is one of many acceptable values to pass to DSResponse.setData().

a) nothing to do here, just declare type:“int” and it works
b) search for “Spring”
c) ComboBox autocomplete works by way of a DataSource when you set optionDataSource. Get a DataSource working with a “fetch” operation and ComboBox autocomplete just works.

Hi,

We are facing another issue now. We kept a date field in dynamic form and we mapped it to java.util.Date and also with java.sql.Date and it was not submitting the form. We tried mapping int, String and float and they are working fine. kindly let us know how what we need to chnage.

See the field defintition below

{name:“batch.batchDate”, title: “<s:text name=“batchentry.batch.label.pickupdate” />”,
type: “date”, useTextField: “true” , defaultValue:“<s:property value=“batch.batchDate”/>”
}

mapping in Java is

class Batch{
:
:
Date batchDate;
}

As we are using it with Stuts2, we are accesing the fields like this.

Regards,
Kumbesh

Hi Kumbesh,

The “defaultValue” provided to a Date field should be an instance of Date (the JavaScript built-in). Most likely Struts is outputting a String (view source on the actual page to be sure), and it may be the case that simply adding “new Date(…)” around the Struts output will fix the problem - if not, see any good JavaScript reference for how to construct a Date.

Just to reiterate - you are taking a slower, more challenging path with an inferior final result. The recommended approach is to use a DataSource connected into your business logic layer to retrieve the data for display in the form.

If you are using Smart Client as the front end I don’t see any reason why you would integrate it with Struts or any other MVC layer. As Isomorphic mentioned you are better of working directly with your Spring service layer.

Hi,

Thanks a lot for your suggestions and rpelied. We will see what would be the best model to go ahead as we are using the current framework across the projects. Specifically for these reasons, we want to integrate this.

Apart from this, whne we tried to copy the whole project from one develipment machine to the other and tried deploying the same in Tomcat 5.5, it is giving 'isc is undefined" error. Same war file, when it is deployed in another machie, it is perfectly working. Both are Windows XP machines and IE running in these machies are 6.0 versions and same. kindly let us know what setting we need to make to overcome these error. it is so wierd for us and preventing us from sharing the work.

Regards,
Kumbesh

One more observation, if we deploy the project in localhost and load the pages, it works in few machines. But, if we access remotely, it is throwing isc is undefined issues. Kindly recommend how to fix this as we have a demoo on monday and this is casuign a lot to us now.

Regards,
Kumbesh

On your “isc is undefined” error - this indicates that you page is simply not loading SmartClient successfully, most likely because the <script src=> tags at the beginning of the page are not pointing to the correct URLs to get SmartClient runtime files like ISC_Core.js.

If you haven’t already installed Firebug, you really need to do so - Firebug’s “Net” tab makes this kind of issue trivial to understand, as you will see clearly labeled 404 error for this files.

How you could make this happen on one machine and not another is not clear. Perhaps the URLs include “localhost” or similar, and some machines cannot DNS resolve localhost.

Finally, about your existing framework - as a community member kindly and correctly pointed out (thanks Mike!) it makes sense to connect SmartClient to the business logic and/or data services of your existing framework, but trying to drive SmartClient from Struts MVC doesn’t make sense. It’s kind of like driving an airplane from one city to another via surface roads - it works but that’s not what a plane is for, there’s a faster way :slight_smile:

Thanks for your reply. I will install the firebug and try. But, we are getting these working with local host and not with IP getting mentioned. To be very clear, we kave kept isomorphic folder under root and tried accessing them with a jspx file in the root itself. We will check it again.

Regards,
Kumbesh

Another thing to try - check your Tomcat logs carefully, it’s possible that SmartClient is not loading properly because of a server-side issue.

Thanks..See below the traces we get when we run with proper URL (with IP)

=== 2008-09-27 19:28:16,729 [or21] INFO RequestContext - URL: ‘/dbfcweb/sc.jspx’, User-Agent: ‘Mozi
lla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)’: MSIE with Accept-Encoding h
eader, ready for compressed JS
=== 2008-09-27 19:28:16,792 [or21] INFO Download - Returning 304: Not modified on conditional get o
f: C:\softwares\apache-tomcat-5.5.26\webapps\dbfcweb\isomorphic\system\modules\ISC_Core.js
=== 2008-09-27 19:28:16,807 [or21] INFO Download - Returning 304: Not modified on conditional get o
f: C:\softwares\apache-tomcat-5.5.26\webapps\dbfcweb\isomorphic\system\modules\ISC_Foundation.js
=== 2008-09-27 19:28:16,823 [or21] INFO Download - Returning 304: Not modified on conditional get o
f: C:\softwares\apache-tomcat-5.5.26\webapps\dbfcweb\isomorphic\system\modules\ISC_Containers.js
=== 2008-09-27 19:28:16,839 [or21] INFO Download - Returning 304: Not modified on conditional get o
f: C:\softwares\apache-tomcat-5.5.26\webapps\dbfcweb\isomorphic\system\modules\ISC_Grids.js
=== 2008-09-27 19:28:16,854 [or21] INFO Download - Returning 304: Not modified on conditional get o
f: C:\softwares\apache-tomcat-5.5.26\webapps\dbfcweb\isomorphic\system\modules\ISC_Forms.js
=== 2008-09-27 19:28:16,870 [or21] INFO Download - Returning 304: Not modified on conditional get o
f: C:\softwares\apache-tomcat-5.5.26\webapps\dbfcweb\isomorphic\system\modules\ISC_DataBinding.js
=== 2008-09-27 19:28:16,886 [or21] INFO Download - Returning 304: Not modified on conditional get o
f: C:\softwares\apache-tomcat-5.5.26\webapps\dbfcweb\isomorphic\skins\standard\load_skin.js

Kindly suggest what need to be done to overcome them.

Regards,
Kumbesh

That looks normal. Look for warnings about missing files and soforth, and for Java stacktraces. If nothing there, I’m afraid you’re back to checking what’s coming over the wire with Firebug (Fiddler is just as useful, if you prefer to use IE)

Are you using the FileLoader and/or the <isc:loadISC> tag with defer=“true”? Used improperly that could create a timing issue where your code that uses SmartClient loads before SmartClient itself.

If not, posting all the <script src=> tags from your HTML would help (the generated HTML, not the JSP file - use View Source).

I am using only loadISC and please see below the list of includes I am getting.
Should I download Firebug? I am using IE, so you suggect Fiddler is it?

<html><head><SCRIPT>window.isomorphicDir=‘isomorphic/’;</SCRIPT>
<SCRIPT SRC=isomorphic/system/modules/ISC_Core.js?isc_version=6.5.1.js></SCRIPT><SCRIPT>isc._lastModule=‘Core’;</SCRIPT>
<SCRIPT SRC=isomorphic/system/modules/ISC_Foundation.js?isc_version=6.5.1.js></SCRIPT><SCRIPT>isc._lastModule=‘Foundation’;</SCRIPT>
<SCRIPT SRC=isomorphic/system/modules/ISC_Containers.js?isc_version=6.5.1.js></SCRIPT><SCRIPT>isc._lastModule=‘Containers’;</SCRIPT>
<SCRIPT SRC=isomorphic/system/modules/ISC_Grids.js?isc_version=6.5.1.js></SCRIPT><SCRIPT>isc._lastModule=‘Grids’;</SCRIPT>
<SCRIPT SRC=isomorphic/system/modules/ISC_Forms.js?isc_version=6.5.1.js></SCRIPT><SCRIPT>isc._lastModule=‘Forms’;</SCRIPT>
<SCRIPT SRC=isomorphic/system/modules/ISC_DataBinding.js?isc_version=6.5.1.js></SCRIPT><SCRIPT>isc._lastModule=‘DataBinding’;</SCRIPT>
<SCRIPT SRC=isomorphic/skins/standard/load_skin.js?isc_version=6.5.1.js></SCRIPT>
</head>

But, eventually, the clients may use any user? In that case, should we ask them to run these?

Regards,
Kumbehs

Those are both development tools that will help you understand why you cannot load a JavaScript file (which is all that is happening here - this is not SmartClient-specific). Firebug in particular has many, many features that aid in modern web development and should be considered a required install for a developer using SmartClient. Your end users will not need to install these tools.

Hi,

I am using Fiddler and I am not able to get inputs towards this. We are getting it loaded when I give http://localhost:8080/dbfcweb/sc.jspx, but, when I give http://x.y.z.a:8080/dbfcweb/sc.jspx (even for the local PC), it doesn’t work. I really can’t understand what exactly is happening here. Really has made us get struck with showing a demo.

Regards,
Kumbesh

Hi,

When we searched in ISC_DataBinding.js, there is a reference to localhost or location.hostname and returning the results. Is it anyway related to this issue?

Regards,
Kumbesh