制作像“Backspace”一样的 JSF 按钮和“输入” inputTextArea 的键?
更新:为了清楚起见,我在这里进行了更新,而不是在评论中写入或发表答案。
这是这些按钮将如何操作的代码的一部分:
我制作了这样的按钮:
<h:commandButton value="Delete" onclick="return addBackspace();">
<f:ajax execute="@form" render="formula"/>
</h:commandButton> //the backspace button
textArea:
<h:inputTextarea id="formula" value="#{output.formula}" />
我制作了一些简单的按钮,这些按钮会将它们的值写入 textArea,以便用户在构建公式时看到公式:
<h:commandButton value="+ " onclick="return checkButtons(this.value);">
<f:ajax execute="@form" render="formula"/>
</h:commandButton>
I我不完全确定我放在那里的 ajax 部分,用它来停止每次点击时的页面刷新。
我使用的 selectBox 现在有一些硬编码值,但最终将填充从 WS 获取的数据。
Property:
<h:selectOneMenu value ="#{output.propertyReferenceValue}" id="selectTwo" onchange="return checkItem(this.value);">
<f:selectItems value="#{property.propertyReference.keySet()}"/>
</h:selectOneMenu>
现在,如果我将 textArea 禁用或只读,我仍然可以在其中写入 selctBoxes 的内容(这很好),但是如果我尝试像“+”这样的简单按钮,它们的值将很快出现然后消失一样快。如果我尝试退格键,它将删除文本区域的全部内容,如果我将选择框的一些内容放入文本区域,然后如果我单击“+”按钮(例如),则删除文本区域的全部内容区域将被删除。我仍在深入研究代码,看看是什么导致了它的行为方式:)
更新结束
是否可以在 JSF 中制作一些命令按钮,这些按钮将在 inputTextArea 上进行操作,就像“Enter”和“Backspace”键?例如:
按下“输入按钮”时,会将光标移动到文本区域的新行。 “退格按钮”将删除光标后面的下一个字母或空格。
我已经搜索了一段时间,但我似乎只找到了如何使所有文本消失的详细信息。
谢谢, 丹尼尔
UPDATE: I updated here for clarity, instead of writing in the comments or making an answer post.
This is a piece of how the code those buttons will operate upon looks:
I made the buttons like this:
<h:commandButton value="Delete" onclick="return addBackspace();">
<f:ajax execute="@form" render="formula"/>
</h:commandButton> //the backspace button
The textArea:
<h:inputTextarea id="formula" value="#{output.formula}" />
I made some simple buttons which would write their value to the textArea so the user sees the formula as he builds it:
<h:commandButton value="+ " onclick="return checkButtons(this.value);">
<f:ajax execute="@form" render="formula"/>
</h:commandButton>
I'm not entirely sure about the ajax part i put in there, used it to stop the page refresh on every click.
And the selectBoxes I use which have some hardcoded values now but will eventually be filled with data taken from a WS.
Property:
<h:selectOneMenu value ="#{output.propertyReferenceValue}" id="selectTwo" onchange="return checkItem(this.value);">
<f:selectItems value="#{property.propertyReference.keySet()}"/>
</h:selectOneMenu>
Now if i make the textArea disabled or readOnly, I'm still able to write the content of the selctBoxes in it(which is good) but if i try the simple buttons like "+" their value will just appear quickly and then dissapear just as fast. If i try the backspace , it will delete the whole content of the textArea, same if i put some of the content of the selectboxes in the textArea and then if I click the "+" button (for example), the whole content of the area will be deleted. I'm still digging through the code to see what it is that makes it behave this way :)
END OF UPDATE
Would it be possible to make some commandButtons in JSF which will operate on an inputTextArea just like the "Enter" and "Backspace" keys? For example:
The "Enter Button" when pressed, will move the cursor to a new line of the textArea.
The "Backspace Button" will delete the next letter or space which is behind the cursor.
I've been searching for a while , but i seem to find only details on how to make all the text dissapear.
Thanks,
Daniel
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 JavaScript 来完成此操作。
例如
具有这些功能
You could just use JavaScript for this.
E.g.
with those functions