How to show the saved text in text field - html

In my HTML page, there is a button new and a button modify, when I click the button new, a new page will show with an empty single line text field, the code of the text field is:
<input type="text" name="functionInfo.paramsText"/>
so I can input some text in the text field and save it into the database (the data will be put to Java and saved into a database), this is exactly what I want, but when I click modify to modify a text which has been stored in the database, the new page is shown with an empty text field, how can I get a text field with the stored text shown on it? So I can see what I have saved before.

If you use Struts tags then it's simply
<s:textfield name="functionInfo.paramsText"/>
The value will be set via evaluating OGNL expression in the name attribute. You only need to provide a bean functionInfo with property paramsText and getters for both.
If you put a bean to the action class, then using a getter it's accessible from the value stack via OGNL since the action bean is on top of the value stack.

Related

Putting code in a text box (MS Access)

I am using a textbox for the header of my report, and based on what the user selects it will be "Baseline 8", "Baseline 9", etc. What I would like to do is have the text box coded so whatever number the user selects is entered into the text box. I managed to do it by using two text boxes, one just says "baseline" and the other text box says "=[Forms]![Navigation Form]![NavigationSubform]![Combo21]" and it will enter the correct value. But what I want to do is put it all in one box, and when I put "Baseline =[Forms]![Navigation Form]![NavigationSubform]![Combo21]" in the text box it doesn't work, it just leaves the code as the header when I generate the report. Is there something I'm not doing correctly?
First of all, when you state that a "textbox says", you really mean that "the Control Source property of the textbox equals." For a textbox (and some other controls), the value that you see on the actual form IS the Control Source property. I am not being picky for its own sake, rather it is important to recognize what value you are editing.
The Control Source property can essentially contain two types of values. The first is without an equals sign and it indicates the name of a field from the form Record Source. In that case, it binds the control to the field directly so that it automatically loads from the field and saves changes back to the field.
The second type of value always starts with =. It is a VBA code expression and can include calls to functions and other VBA operators. In your case, you want to concatenate (i.e. combine) two strings: one literal "Baseline" and one pulled from an access object [Forms]![Navigation Form]![NavigationSubform]![Combo21], so you need to use the string concatenation operator &.
="Baseline " & [Forms]![Navigation Form]![NavigationSubform]![Combo21]

Input Field with text already populated on page load

I have a custom Visual Force page that on load has a name field that is supposed to have {Auto} printed inside the input text box that the user can delete or leave or not. I have been using a html-placeholder however the text just disappears and is gray.
My VF inputfield:
<apex:inputfield required="true"
value="{!EventPackageRevenueBreakdown__c.Name}" html-placeholder="{!Auto}"></apex:inputfield>
What it looks like with that code:
What I need it to look like (notice the cursor is after the closing scope)
Thanks in advance I'm still very new to this!
I suggest you to set Name field in controller with '{Auto}' value.
The placeholder attribute will disappear when there is a value in the field, what you want is to actually set the VALUE of the field to {Auto}.
Try this:
If you want it to automatically clear the field if a user clicks into it, you could add some javascript to handle that.

copy value entered in unbound textbox to label after pressing button

I have an unbound text box on my form which the admin can enter a date of when records were last updated. I want this date to be copied to a label after pushing a button so that it holds the date instead of it do disappear after closing the form.
does anyone know if this is possible and how it is possible?
For creating a variable that can be used AFTER the form is closed:
Create a new module (in code window, click 'Insert | Module'
Insert the variable name(s) and types you want available everywhere. i.e.
Global dtLastUpdated As Date
Global strSaveSomeName As String
Save the module as mdl_Globals
Add code wherever needed to set the variable, then can reference anywhere.
If for use during the form, use the following: where 'lblForUnbound' is the Label field and 'txtUnbound' is your unbound text box
Me.lblForUnbound.Caption = Me.txtUnbound.Text

Unable to get the updated text of text box

I've one text box and one update button:
Text box:
<asp:TextBox ID="txtFName" runat="server"></asp:TextBox>
update button:
<asp:Button ID="btnUpdFName" runat="server"Text="Update" onclick="btnUpdFName_Click"/>
What I am doing in page load event I am getting the first name from database and assinging it to text box as follows:
txtFName.Text = dt.Rows[0][1].ToString();
Now when i earases the text set at page load event in text box as above and write another name and press update button, i am trying to get the new text entered in the text box in the button click event as follows:
string FName = txtFName.Text;
But the problem is that every time I write new text in text box, I am still getting the same text as set form database (dt.Rows[0][1].ToString()).
I am not able to get the current text from the text box and getting only the intial value set from db in page load event.
What I encountered that after compilation my text box markup becomes as follows:
<input id="CPHcontent_txtFName" type="text" value="value set from db i.e. dt.Rows[0] [1].ToString()" name="ctl00$CPHcontent$txttxtFName"></input>
the text box alway has the same value set from the db. Thats why i am getting each time the same value regardless of value entered by user in text box.
Now tell me how to get the updated value of text box in my page behind.
Thanx in advance
In asp.net webforms you should separate code for setting data to control and for saving data to db. One of ways to set data to control - use check
if (!IsPostBack)
{
txtFName.Text = dt.Rows[0][1].ToString();
}
in page load event.
Otherwise you will overwrite your newly entered text for textbox on every page load.
You are probably overwriting the text you entered in your Page Load event, because you are not checking if it is a PostBack.
Please read ASP.NET Page Life Cycle Overview for further information.
Set the textbox to empty or null before you try to set/read it again onpageload.

How do I edit a text field in Selenium 2?

I can type text into a field using WebElement.sendKeys() but editing doesn't work: I can neither move the cursor nor delete the last character that I typed with e.sendKeys( Keys.BACK_SPACE )
How do I modify the value of a text field in Selenium 2 (WebDriver)?
You can definitely do that by either of the two methods. I have tried and it works.
e.click() # Positions the cursor at the end of the string
e.sendKeys(Keys.BACK_SPACE )
Or you could simply clear the text, and start over again:
e.clear()
e.sendKeys("What you want to send")
I found this solution that seems to work pretty well. It basically clicks on the text field WebElement, then sends Ctrl-End to put the cursor at the end of the text. Then sends the string that I had previously initialized.
(quickReplyTextArea is a text field WebElement that I have previous found, as is postQuickReplyButton (button instead of text field, obviously). replyText is a String that I initialized earlier)
quickReplyTextArea.click();
quickReplyTextArea.sendKeys(Keys.chord(Keys.CONTROL, Keys.END));
quickReplyTextArea.sendKeys(replyText);
postQuickReplyButton.click();
You can try clicking first into that text box, and use sendKeys() afterwards.