Last week, I was required to quickly do maintenance to an ancient JSP page. The page basically is a spaghetti code that retrieve shipment data from Oracle, transform it into HTML output. The page itself is residing in an old Allaire JRun server. So yeah, it’s really that ancient 🙂
Due to the time constraint and my lack of familiarity with the overall Java EE environment, I decided to move it into my comfort zone 😀
To create the overall layout, we can always derive from Ext.NET MVC project. So I made a few changes and I have something like this:
When the user clicked the Search button, we need to submit to backend processing and show the output in the Result panel.
<ext:Button Width="100" Height="20" runat="server" ID="btnSearch" Text="Search"> <Listeners> <Click Fn="fnSearch" /> </Listeners> </ext:Button>
The click event handler is in JavaScript:
var fnSearch = function(sender, ev) { pnlResult.load({ url:'/Job/Search', params:{shipref: txtShipRef.getValue()}, callback:function(el){ el.applyStyles("overflow:scroll"); }, text:'loading...', timeout:30 }); }
Meanwhile at the backend, JobController.cs will have the following the action handler:
public ContentResult Search(String shipref) { var res = new ContentResult(); res.ContentType = "text/html"; var sb = new StringBuilder(); try { //Convert the Java code in JSP page into C# code //Highly recommended to use sb.Append() //instead of + operator for String concatenating res.Content = sb.ToString(); } catch (Exception ex) { res.Content = ex.ToString(); } return res; }
There you go, at least now we can move this application to a newer and better server. Which should translates as a better experience to the user 😀
I hope it helps. Cheers!
loading...
About Hardono
Incoming Search
asp.net, c#, ext.net, mvc