I try to find pattern how to return 'prompt()' result in java like http://www.mysticcoders.com/blog/wicket-ajax-confirmation-modal-window/ (but in this case author using 'confirm' instead of 'prompt' and doesn't return anything from javascript). Now I am using hidden field in form and update this field before submit, but maybe you know how to solve this problem more elegant (for example using AJAX components in wicket). Thank you for your time.
If you just want so submit the prompted value within your form, your hidden field approach looks adequate to me. If you want to call some Wicket code on the server with the prompted value independently of the form submission, see How do I call Java code from JavaScript code in Wicket?
Related
I have a form in wicket which has two buttons. I would like one to have validation over the fields (if they are left null or not) which I already did. Now I would like the second button NOT to have this validation. I have seen few examples where people use the method setDefaultFormProcessing() which is a method of class Button in wicket.
However when I use this method my form seems to also ignore changes done in the fields of the form.
Any idea how I actually can achive bypassing the validation but still be able to see changes in my form??
Thanks!!
This is the defined behavoir. If data is not valid it is not possible update model anyway. Consider an example when you have a date field and you type there '99/9/YYYYY' that is not a valid date, thus wicket has no chance just to bypass validation and update model. The only chance is to keep input data as String and give you an option, how to convert or update model by your own implementation.
If you have a reference to your form components, you could invoke updateModel().
See http://apache-wicket.1842946.n4.nabble.com/Turn-off-form-validation-td1877661.html
And check API doc for FormComponent that is a base class of all fields and other form components. https://ci.apache.org/projects/wicket/apidocs/7.x/org/apache/wicket/markup/html/form/FormComponent.html
When user submits one page, I need to update hidden field values before submitting. How can I achieve that?
<af:button text="Continue" action="#{addAccount_backing.addBankAccountConfirm}" partialSubmit="true" onclick="goSubmit(this);"/>
Inside goSubmit java script function I need to update hidden field values before posting. I'm using ADF framework and JSF for view.
You can use f:ajax and do the stuff you need, See this example
Is there a way to call ids that are created in html page without specifically giving wicket:id in the component. If so, how can I do that?
What I am trying to accomplish is to get access of the component to assign a default value from CMS. I could assign the default value using JS, however I need that value to be populated to Java so that I could use that in my class to update my business logic depending on the defaulted value.
As I understand it, Wicket is component oriented which means that single component (piece of HTML code) can't see all the HTML. And my guess is that at some late stage, you want to look at the whole page HTML and do something with a DOM node with a specific ID.
I'm not sure what the correct solution should be. One way is to put the value into the user's session, so it's available for each component and your business logic.
There is a website,and it has a button on click checks for the value in the textbox and searches for it and displays the result.
How can i with my java code,prove the input and display the appropriate result on my java code.
On seeing the source of the website,i get to know the methods that gets called on the button click.But what and how to further trigger the event and pass the value to textbox and obtain the resut !!
Use a programmatic web browser like HtmlUnit.
I'm not 100% clear on what you're asking for, but it sounds to me like you're trying to get some sort of client-interaction emulation/automation.
Check out Selenium's Java API
I am trying to clear everything on my HTML form when I visit it from a hyperlink entry.
Any ideas? My development language is java.
are you using session-scoped data? if so, close your browser and open it again.
I'm not sure the application is, but one way to accomplish this would be to use JavaScript. For example, if it is acceptable to clear the form every time that page is visited you could write a quick function that clears the form when the page is loaded (i.e., using the onload event).
If you only want to clear the form when the page is hit from that link you could add a param to the URL (e.g., clearForm=true) and use JavaScript to pick up the query string and clear the form when that parameter is present.
This is, of course, a purely client-side solution. For a server-side solution it would be helpful to know what framework you are using.