« Return to Thread: Re: Netbeans/Hidden field question

Re: Netbeans/Hidden field question

by Neil B. Cohen-3 :: Rate this Message:

Reply to Author | View in Thread

Rick Fincher wrote:
> Hi Neil,

Morning Rick - I followed the steps you laid out below and it worked for
me as well. I have switched back to NB6.1 and now that I know about
having to add the binding routines, that seems to be working too. Not
sure what was causing the problem yesterday - I must have missed a step
somewhere - but I think I'm on the right track now.

Thanks again for all the help!

nbc

>
> Below is an OnClick() script that I just tried that worked.  One thing
> I found out was that in 6.1 you have to right-click on the hidden
> field and select "add binding attribute".  Otherwise it never assigns
> the value to the field that you set in the "text" parameter of the
> visual editor.
>
> I put a hidden field on the page named hiddenField1.  After I added
> the binding attribute I set the text of the field to "alert" in the
> parameter window for the field.  The field can have text even though
> you can't see it.  To stuff a value in it in Java use
> hiddenField1.setText("your text");
>
> WARNING- Do Not put a value in for "text" for your textField or
> hiddenField in the visual editor if you set the value in your
> program.  If you do it will override whatever you set programatically
> for the initial load of the page.  I went nuts trying to figure that
> one out.
>
> I set the value of the hiddenField in the visual editor just for this
> test.  It's OK to do this  if you always want the page to do its first
> load with a fixed value.
>
> The Javascript for onClick is:
>
> var hiddenText=document.getElementById("form1:hiddenField1").value;
>
> if (hiddenText=="alert"){
>    alert("Hidden Field is alert");
> } else {
>    alert("Hidden field is not alert");
> }
>
> You can look in HTTP Monitor in Netbeans and click on the last POST
> for Page1.jsp to see what is in the fields before and after the page
> is submitted.  Clear the entrie in HTTP Monitor if you have too much
> stuff in there (right-click the "All Records" or "Current Records"
> folder icon and select "Delete All").
>
> The component names are all there too.  Only textField components have
> the "_field" added to the name.  It is hard to see the underscore in
> the HTTP Monitor but it is there.
>
> To set "clean/dirty" initialize it in the init() method with something
> like:
>
> if (!this.isPostBack()) {
>    hiddenField1.setText("clean");
> }
>
> This will only set "clean" on the first load (not a postBack).
>
> Then for each component that can "dirty" it up, put this in the
> onChange() Javascript:
>
> document.getElementById("form1:hiddenField1").value="dirty";
>
> You can change a visible textField like:
>
> document.getElementById("form1:textField1_field").value="changed in
> Javascript";
>
> You can open the error console on your browser to see if there are any
> errors in your Javascript when it executes.
>
> Hope this helps!
>
> Rick
> -------------------
>
> Neil B. Cohen wrote:
>> Hi Rick - Sorry to bother you again, but I need another nudge...
>>
>> I've attached a screen shot which shows the page I'm building and the
>> javascript I'm trying to use.
>>
>> A few notes:
>>
>> 1) I created a hidden field called 'hidePageStatus' and initialized
>> it to 'dirty'. Obviously that is not correct for the long run, but
>> for now it lets me bring up the page and just hit the return button
>> for testing....
>>
>> 2) When I tried 'dflag =
>> document.getElementById("form1.hidePageStatus") or
>> "form1.hidePageStatus_field" (or "form1:hidePageStatus_field" or... I
>> think I tried them all) it never even printed the 'alert' message -
>> it simply executed the return button event handler. Not sure why that
>> would be...
>>
>> 3) I looked at the html for the page and found a 'hidden field' named
>> 'form1_hidden'. As you can see, it has a value of 'form1_hidden'.
>> When I set the javascript to look for that (as in the screen dump),
>> then the alert displays and the confirm dialog executes properly - so
>> the javascript is ok, but my attempts to use it within Netbeans is
>> wrong somehow...
>>
>> So my questions are:
>>
>> 1) How do I get the mapping from form1_hidden to hideStatusPage?
>>
>> 2) How do I get the value set correctly to clean/dirty?
>>
>> I think if I can get over this hump, I should be mostly ok...
>>
>> Much obliged,
>>
>> nbc
>>
>>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...

 « Return to Thread: Re: Netbeans/Hidden field question

LightInTheBox - Buy quality products at wholesale price