I am trying to display the fields on a jsf page dynamically on load by taking the page source from the database.
Based on some query the page source will be taken from the database and be put onto the screen and the components should be displayed on the screen dynamically.
So there will be a single screen but the screen source data will be coming from the database and the all the components on the screen will be displayed on the screen dynamically.
How can this be done?
To be honest, doing it in JSF or JSP is unlikely to be very easy/ or performant.
You may as well skip the hassle, and just write some simple Java classes to bind inputs & render HTML output yourself.
I've done a lot of 'advanced UI' work with big/ tree-structured/ configurable UI in different projects. Mostly with JSP, JSTL and Spring -- but the performance problems will be the same.
Another area you'll have to address, is loading all the components quickly. Typically we've use 'bulk loading' queries in Hibernate to load all children/ subtrees in a single query. This has been very effective.
Related
I'm new to web development with Java, so please excuse me if I'm butchering the terminology:
I'm building a web app with JSPs/servlets using the Java MVC model. I'm including a register/login option on the top menu that will of course need to communicate with the server (handle registering/logging in or retreiving the user's name).
I want to reuse both the JSP and controller code for the top menu as it should be on every page. I'm able to reuse the menu page using <c:import>. However, the menu will appear on pages that have their own functionality and therefore their own controllers. I can't figure out how to reuse the controller code for the menu on these pages as I can only map one servlet to a URL.
I don't have much code to show as an example at this point. What's the best practice for reusing common functionality like this without interfering with page specific functionality?
Not sure if I understand the problem correctly.
What about passing a hidden field in your form(which, from my understanding would point to the same mapping in your controller) specifying which jsp the request is coming from ? That way you know which jsp to call back from your controller.
I am developing an application where I will have only loader.jsp which will load all other jsp files from the database. Like I am having all the coding for jsp file in database so that i can able to change the html content without restart the server in database itself.
Is there any framework already existing to implement this and what is the best way to achieve this?
If yes for render .jsp file dynamically, how to render css and js dependency also dynamically?
So my exact requirement is, I will have only loader.jsp which will load all other pages stored in database based on the path param.
http://localhost:8081/myApplication?page=mypage
TECHNOLOGIES USING: java spring boot
NOTE 1: I am not gonna render based of conditions or some parts of the file, I need to render entire page as it is from the database columns.
NOTE 2: if loading .jsp is not possible since jsp code need to be compiled, then can i load .html file? ex: loader.jsp will load a.html, b.html, c.html from database
NOTE 3: Am building application where user can able to drag and drop UI elements to create webpages and once if they save, their changes need to reflect on run time without restart. like they have one page in their own application itself to change their UI elements.
By multipage I mean separate HTML files, say index.html, admin.html etc.
Now one solution to achieve this is to have this in the EntryPoint class:
if (!Window.Location.getPath().toLowerCase().endsWith("myhtmlpage.html") {
return;
}
The thing I want to understand deeply here is what is my GWT app have the main app, admin app, etc. The tendency of the app nocache.js file will get bigger, thus longer to load.
The question would be, does the code above prevent other parts of the compiled GWT app to load unnecessary parts of the app, say athe code for the Index EntryPoint or the Admin EntryPoint are loaded separately?
No, your if/return statement would not prevent any unnecessary javascript code to load.
The standard way to partition the UI javascript code is through code splitting.
The standard way to emulate multiple pages is by managing history & hyperlinks. Basically use tokens to manage your app states with hash code at the end of url -- e.g., #home, #admin.
A pattern I like is a combination of the above two. For a page that does not need to load initially, I hide it behind a GWT.runAsync code-splitting call to server with a distinct history token. For pages for which I want to dynamically control the content on the server side without having to recompile the javascript, I create a server call I fully control that returns html displayed on the browser through GWT HTMLPanel -- of course no need to recompile as long as the html structure and corresponding HTMLPanel code do not change. A side advantage of the latter is that you may control your server side logging to track page load statistics.
Finally, you may want to read up on GWT Activities & Places, from what I read a standard for dealing with history & such.
Right Patrick,
In addition, there is no way to use the code splitting method for js libraries that are not in your project (not GWT). So splitting pages is right to avoid js libraries you use for your admin code but you don't use in your front office, that's ok if you include the js in the page and you don't inject it through GWT. Otherwise it's your responsibility to split the code (have a common package that is available to all, but individual loads per 'page')
In theory, they say, the good split point is an activity (but I'm not convinced, since I have many activities in my pages, and loading each script alone could be bad for performance, so it's a per case analysis), you can see all what is included in your split in the compiler report
Take the time to look this video, it will save you a lot of troubles
https://www.youtube.com/watch?v=0F5zc1UAt2Y
I am a new developer in Android. Currently I have started working on an app. I dont have any colleagues in Android so for my doubts and queries I am depended only on Stack overflow.
In my app I have placed three Edit boxes as follows with an ok button at last
FirstName:_____________
LastName:______________
DOB:___________________
When the user enters all data above and clicks the OK button at last, I am going to do the following process
Store the datas in a database
Send it to a particular URL
the data send to the URL will be get saved there
i just want to know how to implement this. What concept to be used.....
The actions, views and activies in Android are the baked in way of working with the Android UI and are an implementation of a model-view-viewmodel pattern, which is structurally similar (in the same family as) model view controller.
To the best of my knoweledge, there is no way to break out of this model. It can probably be done, but you would likely lose all the benefit that the existing model has, and have to rewrite your own UI layer to make it work.
You can find MVC in the followings:
You define your user interface in various XML files by resolution/hardware etc.
You define your resources in various XML files by locale etc.
You store data in SQLite or your custom data in /assets/ folder, read more about resources and assets
You extend clases like ListActivity, TabActivity and make use of the XML file by inflaters
You can create as many classes as you wish for your model, and have your own packages, that will act as a structure
A lot of Utils have been already written for you. DatabaseUtils, Html,
There is no single MVC Pattern you could obey to. MVC just states more or less that you don't should mingle data and view, so that e.g. views are responsible for holding data or classes which are processing data are directly affecting the view.
But nevertheless, the way Android deals with classes and resources, you're sometimes even forced to follow the MVC pattern. More complicated in my oppinion are the activites which are responsible sometimes for the view but nevertheless act as an controller in the same time.
If you define your views and layouts in the xml files, load your resources from the res folder, and if you avoid more or less to mingle this things in your code, then your anyway following a MVC pattern.
Google has tutorials for doing simple forms and taking actions when buttons are pressed. You should start there.
Next try the URL thing and next try the save data thing. If you follow the form tutorial you'll know where put code to execute when button is pressed (read the data tutorial).
If you follow others tutorials (to navigate) you'll know how to redirect to a URL (I would read "intents" but I'm not pretty sure, I'm not very prepared on Android). I guess that you should only "redirect to http://" and the system will decide (or ask the user) to open it in a browser or something diferent (like the youtube app). If you want to control the window navigation read this (but I don't recommend it).
But the bottom line is: read the tutorials and try things until you feel that you grasp the philosophy of the technology. Then search for specific things link redirecting, saving data, or taking a special action.
I am trying to write a web-app to manage references for my PhD thesis.
I used to manage this information inside a personal Confluence (fantastic tool! - http://www.atlassian.com/software/confluence/) instance however I'm fed-up with the opening of PDF's and cutting and pasting values into fields that I wish to record.
I have exposed a webservice that will return me images based on a PDF filename and a page number. The same webservice also exposes a method that will return the text inside of a provided rectangle (top left x-y coord, bottom right x-y coord).
I would like to be able to drag a rectangle over part of the PDF image and then call the webservice to give me the text (which I will then store on a EntityBean). I am looking at using the JBoss application stack (Application Server, Hibernate, Seam and Richfaces). Does anybody know how I could go about achieving this? I have seen the ability to draw custom images in other RIA toolkits (e.g. dojo), but I can't see a way of doing this inside of Richfaces.
Hopefully somebody out there could prove me wrong, or provide some idea about what I can do (as I am not a web developer - I'm mainly building this tool because the RIA frameworks available now have got me interested!)
I already have the code to extract the text, my problem is purely how can I get the user to draw a "selection rectangle" inside the web browser over the top of the image?
Many Thanks,
Aidos
Try using the RichFaces Paint 2D tag
It exposes the Graphics2D package to the user interface.
Track user drag events on the image using javascript, then post the co-ordrdinates to the backing bean to re-render the image with a drawn on selection box.
Have you considered Mendeley ? It will try to parse and extract bibliographic information from your pdfs.
you can do it with itext (http://www.lowagie.com/iText/)