Note that there are some explanatory texts on larger screens.

plurals
  1. POGWT capture Textbox onload event
    primarykey
    data
    text
    <p>I have a form where the user can enter information in several Textboxes.</p> <p>The textboxes are created like so -</p> <pre><code>GroupSection courseNumber = new GroupSection(getH4Title("")); courseNumber.addStyleName(LUUIConstants.STYLE_SECTION); courseNumber.addStyleName(LUUIConstants.STYLE_SECTION_DIVIDER); // KSTextBox extends TextBox incidentally // I've added some custom functionality in my version of this class KSTextBox subjectCodeTextBox = new KSTextBox(); KSTextBox courseNumberTextBox = new KSTextBox(); . . . addField(courseNumber, COURSE + "/" + SUBJECT_AREA, generateMessageInfo(LUUIConstants.SUBJECT_CODE_LABEL_KEY), subjectCodeTextBox); addField(courseNumber, COURSE + "/" + COURSE_NUMBER_SUFFIX, generateMessageInfo(LUUIConstants.COURSE_NUMBER_LABEL_KEY), courseNumberTextBox); . . . courseNumber.addSection(generateCrossListed_Ver_Joint_Section()); return courseNumber; </code></pre> <p>Here's what it looks like rendered: <img src="https://i1328.photobucket.com/albums/w524/amberkoff/snapCourse_zps3c2887fc.png" alt="2 Text boxes"></p> <p>This same page on which these Text boxes are located is re-used in my application in for different scenarios; however, for one particular scenario, I need to make them read-only.</p> <p>The way that I have identified this scenario is checking the title of the page. If there is the keyword "Modify" located on the page - I do not want the user to be able to change the values that are being auto-filled in those text boxes.</p> <p>I've almost achieved this by implementing this -</p> <pre><code>subjectCodeTextBox.addBlurHandler(new BlurHandler() { @Override public void onBlur(BlurEvent blurEvent) { NodeList&lt;Element&gt; elements = Document.get().getElementsByTagName("div"); for (int i = 0; i &lt; elements.getLength(); i++) { Element elem = elements.getItem(i); String innerHTML = elem.getInnerHTML(); if (innerHTML.contains("Modify")) { subjectCodeTextBox.setReadOnly(true); courseNumberTextBox.setReadOnly(true); } break; } } }); courseNumberTextBox.addBlurHandler(new BlurHandler() { @Override public void onBlur(BlurEvent blurEvent) { NodeList&lt;Element&gt; elements = Document.get().getElementsByTagName("div"); for (int i = 0; i &lt; elements.getLength(); i++) { Element elem = elements.getItem(i); String innerHTML = elem.getInnerHTML(); if (innerHTML.contains("Modify")) { subjectCodeTextBox.setReadOnly(true); courseNumberTextBox.setReadOnly(true); } break; } } }); </code></pre> <p>The above code works, but it will only fire after the user has clicked in and then out of one of those 2 text boxes. But by then, they could have changed the values and don't want that --- I'd prefer those boxes to be disabled when the page gets first rendered.</p> <p><strong>How do I setup those textboxes to already be READONLY when the page first renders for the user?</strong></p> <p>I figure it has something to do with the ONLOAD event, but how do I set it up properly?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload