i want to migrate my struts 1 page to struts 2 but i am facing some problems while moving from one page to another page because i am not able to assign the value of my new page to the java object of the action class.
<% AccountInfoTab accountInfoTab = (AccountInfoTab) session.getAttribute(Constants.ACCOUNT_INFO_TAB_FORM_KEY); %>
function getPaymentHistoryPage(newPageNmber) {
document.accountInfoTab.paymentHistoryPageRequested.value = newPageNmber;
alert(document.accountInfoTab.paymentHistoryPageRequested);
document.accountInfoTab.submit();
}
The above code is working for Struts 1 but the same code is not working for struts 2 . Please give me suggestions how will i assign the new page value to my java object ?
Related
I'am new in Angular2 and now I would like to change my website to Angular2,and in cshtml file we can show specific HTML with razor like:
#if(User.IsInRole("Admin"))
{
<span>Admin can see here only!</span>
}
And now in Angular2 there's no cshtml,my choice is use AJAX to get the role and put in a variable or LocalStorage,is there any better practice?thanks
Yes, there is.
In Angular 2 you could use if conditions as well but in a different manner.
For example:
<div *ngIf="isAdmin" > Admin can see here only! </div>
This means that this div will be shown only when the isAdmin value is true.
And the is admin true should be set on your .ts (typescript) file where you actually will have the app logic.
I am using displaytag with struts 2 in my project, The problem is that displaytag pagination doesn't seem to work. The link generated are like
javascript:displaytagform('userListForm',[{f:'page',v:'2'}]) but when I click it the page parameter is not passed along with the request. It is not creating the hidden field page to store the page value, but if I add ?page=pagenum to the URL once, then the hidden field is created and afterwards it works fine. My question is why it is not creating the field for the first time itself.
I am creating web application for booking tickets. After querying from DB for given inputs now i have 230 records (ticket informations) which has been added to list ,as objects (pojo's) .in JSF i am using "ui:repeat" to iterate the list. Here got confused how to create pagination on this. (i want to display 40 records /page). I should not hit the backend for each and every "NEXT" or "PREVIOUS" click .. Any help would be thankful.
Note: when i hit search button my flow will navigate to result.jsf page where i passed the 230 records for display.
Technology: Spring web flow and JSF 2
simplest solution is to use PrimeFaces DataTable Pagination or equivalent without reinventing the wheel
I have a weird issue .I am using simple captcha in forms in my rails applications. If I am using one captcha in a web page I don't have any problem. But I have a scenario of using three(3) forms in one page in which all the three forms will have the captcha . So that when I refresh the page the captcha data of the three forms are equal.
When we come to database , once the page get loaded the captcha value for one particular id will be created, Without using the captcha if we refresh the page the record is getting updated instead of creating another record, And more over if I open the web page in two tabs and if I submit the form in the first page. It throws an exception which says “ Invalid Captcha”
Can anyone please let me know how to handle multiple captcha's in single page. I am using simple_captcha plugin.
Thanks in-advance
I can't see any point using more than one captcha for one page. (I assume that both your forms will submit at the same time.) Because the whole purpose of captcha is to avoid the automatic form submissions.
The second point is, I'm not sure why you want three forms in a single page. You might consider having a one form and filter the identify the parameters accordingly in the controller side.
Can you explain why do you need new record instead of updated (while refreshing page).
By the way, I had same issue with multiply forms on one page handled by simple_captcha. And my problem was in repeated use of simple_captcha's method show_simple_captcha. It caused repeated database insertions in this case. And Ive made minor changes to the plugin to solve this:
# Line 73 in lib/simple_captcha/view_helpers.rb (in show_simple_captcha method)
options[:field_value] = set_simple_captcha_data(simple_captcha_key, options[:code_type])
changed to:
options[:field_value] = options[:multi] ? simple_captcha_key : set_simple_captcha_data(simple_captcha_key, options[:code_type])
Now I use show_simple_captcha(:multi => true) to generate captcha without database hitting:
<!-- For first captcha on page -->
<%= show_simple_captcha(:object => :foo) %>
<!-- For next captchas on same page -->
<%= show_simple_captcha(:object => :bar, :multi => true) %>
I need to generate a datagrid using a Struts 2, i have found out Struts-Layout can do that, but its not supporting Struts 2. Can any one suggest me a way to generate a datagrid using Struts 2?
There are two out of the box solution available.
The first is Display Tag and the other is [Struts2 jQuery Plugin with the Grid Tag][2].
http://displaytag.sourceforge.net/1.2/
http://code.google.com/p/struts2-jquery/