Ok...it worked after upgrading to Wicket 1.3.4
So, the problem was what Richard mentioned below "that in wicket 1.3.3
enclosure wouldn't call isVisible() after first time"
Thanks again.
Rachit
nanotech wrote:
>
> Hi Richard,
>
> Thanks for the reply. I am using 1.3.3
> I will update to 1.3.4 and try again.
>
> Thanks,
> Rachit
>
>
> richardwilko wrote:
>>
>> There was a bug in enclosure in 1.3.3, where it wouldn't call isVisible
>> after the first time (fixed in 1.3.4) which version are you using?
>>
>>
>>
>>
>> nanotech wrote:
>>>
>>> The line below
>>> pojo.setSampleText(pojo.getSampleText());
>>> should be ignored.
>>>
>>> Thanks,
>>>
>>>
>>>
>>> nanotech wrote:
>>>>
>>>> Hi All,
>>>>
>>>> I have a simple requirement in which I want to display two different
>>>> messages on Form Submit depending on whether or not the text field is
>>>> filled in . The way I thought it should work is if I use combination of
>>>> AjaxButton, WebMarkupContainer,<wicket:enclosure> and by overriding
>>>> isVisible().
>>>> The flow of sample application is. ..
>>>> 1. When the Page Loads(first-time) it displays.."Not found" (which
>>>> means nothing has been entered in textfield).[This is working as
>>>> expected]
>>>> 2. When I type in something to textfield and submit the form--it should
>>>> display "Found" but its not displaying that message.[Not working as
>>>> expected]
>>>> 3. Also, When i clear the textfield and re-submit the form it should
>>>> display "Not found".But this also does not happen.[Not working as
>>>> expected]
>>>>
>>>> In short, the state of the WebMarkupcontainer never gets updated after
>>>> intial load.
>>>> Can someone point out what am I missing?
>>>>
>>>> Here is the code.
>>>>
>>>> SamplePage.html
>>>>
>>>> <body>
>>>> <form wicket:id="myForm">
>>>> <input type="text" wicket:id="sampleText" />
>>>> <input type="submit" wicket:id="sampleSubmit" />
>>>> <div wicket:id="resultContainer">
>>>> <wicket:enclosure>
>>>> [YES]
>>>> </wicket:enclosure>
>>>> <wicket:enclosure>
>>>> [NO]
>>>> </wicket:enclosure>
>>>> </div>
>>>> </form>
>>>> </body>
>>>>
>>>> SamplePage.java
>>>>
>>>> public class SamplePage extends WebPage {
>>>> public SamplePage() {
>>>> add(new SampleForm("myForm"));
>>>> }
>>>>
>>>> private class SampleForm extends Form {
>>>> public SampleForm(String id) {
>>>> super(id);
>>>> final SimplePOJO pojo = new SimplePOJO();
>>>> setModel(new CompoundPropertyModel(pojo));
>>>> add(new TextField("sampleText", new PropertyModel(pojo,
>>>> "sampleText")));
>>>>
>>>> final WebMarkupContainer resultContainer = new
>>>> WebMarkupContainer(
>>>> "resultContainer");
>>>> resultContainer.setOutputMarkupId(true);
>>>> resultContainer.add(new Label("gotResults", "Found...")
>>>> {
>>>> public boolean isVisible() {
>>>> return pojo.getSampleText() != null;
>>>> }
>>>> });
>>>> resultContainer.add(new Label("noResults", "Not
>>>> found...") {
>>>> public boolean isVisible() {
>>>> return pojo.getSampleText() == null;
>>>> }
>>>> });
>>>>
>>>> add(new AjaxButton("sampleSubmit") {
>>>> protected void onSubmit(AjaxRequestTarget
>>>> target, Form f) {
>>>> // If javascript is enabled on user's
>>>> browser.
>>>>
>>>> pojo.setSampleText(pojo.getSampleText());
>>>> if (target != null) {
>>>> // refresh the component.
>>>>
>>>> target.addComponent(resultContainer);
>>>> }
>>>> }
>>>> });
>>>>
>>>> add(resultContainer);
>>>> }
>>>>
>>>> }
>>>> }
>>>>
>>>>
>>>> SimplePOJO.java
>>>>
>>>> public class SimplePOJO implements Serializable{
>>>>
>>>> private String sampleText;
>>>>
>>>> /**
>>>> * @return the sampleText
>>>> */
>>>> public String getSampleText() {
>>>> return sampleText;
>>>> }
>>>>
>>>> /**
>>>> * @param sampleText the sampleText to set
>>>> */
>>>> public void setSampleText(String sampleText) {
>>>> this.sampleText = sampleText;
>>>> }
>>>>
>>>> }
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>
--
View this message in context:
http://www.nabble.com/Enclosure-%2B-AjaxButton-tp18338994p18342163.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]