Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!

Philip Thamaravelil

Ranch Hand
+ Follow
since Feb 09, 2006
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
6
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Philip Thamaravelil

So, do your business users need create/read/update/delete access to lot's of tables in your database?

Tired of programming over and over the same interfaces?

Problem solved!

The NOELLE framework does all the heavy lifting. Providing a 100% configurable front-to-backend solution for create/read/update/delete - No Coding Required!

http://www.noelleframework.com

4 years ago
Sounds like a job for web services... SOAP or REST will do the job.
4 years ago
You should use index of and substring method in Java.
4 years ago
The alternative is to use getters and setters. The value behind getters and setters is they hide the implementation details behind a given class.

For example, if you have a Person class to store some information. You could set static variables for firstName or lastName. But getters and setters allow us to apply behind the scenes business logic seamlessly to the calling class..

The getFirstName or getLastName methods could ... Check for null.. do Max length handling... etc..



Plus, you should read about thread synchronization in Java. Storing variables as static isn't thread safe.

Cheers,
Philip
4 years ago
Hi Ramya,
You certainly can use the edit or view mode of the portlet for this purpose. At a high level, in your Portlet class you will have a method to implement doEdit(...) just as you have doView(...), and doAction(). When you define youre link to edit the record in the view, you'll need to specify in the link to use "doEdit". Of course, these method names are only a high-level view and vary based on your portlet container specification/implementation (JSR 168, JSR 286, IBM, etc..). Hope that helps.

Cheers,
Philip
5 years ago
In general, this is done by passing a parameter to the jsp to determine how to display the page DOM elements.

For example, passing a "mode" parameter ('view', 'update') to the jsp would allow for this.

If "mode" == "view" then
display readonly..
else if "mode"== "update"
display form elements to save the data.
end
5 years ago
try..


<\/\w+Request>




Cheers,
Philip
5 years ago

Alexey Timokhin wrote:Side-note: to be honest, I expected less from this forum, so thanks a lot guys. It has a bigger "educational" emphasis than other communities.



Couldn't agree more. Great community full of sharp folks.
6 years ago
JSP

Alexey Timokhin wrote:
I'm kind of stumped. May you provide an example?



I noticed before, your using jQuery notation, so I assume you've selected that for your javascript code.


the jQuery website has lot's of realworld examples of what your trying to do:

http://api.jquery.com/jQuery.ajax/


One of the advantages of jQuery is it's asynchronous components that enable to you to communicate to the back-end without leaving the current page.

I suggest playing with both methods (form submittal and jQuery ajax) to better understand the difference in approaches. There are a very different paradigm, both useful and have their own place.


Cheers,
Philip



6 years ago
JSP

Alexey Timokhin wrote:
Would that mean I need to create some memory spaces inside JS and store the values there, and on Submit or page reload, store the values inside the bean, do the needed processing, and display what needs to be displayed?



Alexey,
I believe your mixing two separate approaches for saving the data.

1. Form submission
- You'll need to store your Bean values in the DOM (as input/checkbox/etc.. elements inside your <form> tag) NOT as javascript variable.
- Once the user clicks submit, because they are in the DOM, they would be visible to your destination page/servlet/etc...

2. Ajax
- You would not require the submission of the form. You don't require the form tag at all most likely.
- With the triggering of an event (onclick, onchange, etc..) you can make an ajax call (with Jquery or javscript) and access your bean values store as javascript variables to save your data.

Make sense?

Also, to Bear's point, your bean is long gone by the time the page renders. So you would not be able to "store the values inside the bean."


Cheers,
Philip
6 years ago
JSP

Bear Bibeault wrote: They could be if that makes sense, but if the bean values don't need to be associated with particular elements, I'd just create a JavaScript construct that captures the required values.



Again... you COULD create a construct if that makes sense,but is not necessarily the best way. obviously there is more than one way to accomplish the goal. A construct is simply your opinion and personal preference, but it would be splitting hairs to discuss the advantages either way.
6 years ago
JSP