掲示板

Liferay UI taglib : suggestions for input-field tag

15年前 に Alf Høgemark によって更新されました。

Liferay UI taglib : suggestions for input-field tag

Junior Member 投稿: 34 参加年月日: 08/05/24 最新の投稿
Hi

I have been using the input-field tag in the UI part of the Liferay tag library.

Here are my suggestions to improving the tag, and also some questions as how it is working :

1.
The tag should support datatypes Integer and Double. Currently it supports int and double, but I would like to have support for the non primitive numeric types as well.
Why ? Because I want to be able to support numeric properties that does not have to have a value.

Currently, if i have a int property, the input-field tag will display "0" when the property has no value.
How do people use numeric properties in ServiceBuilder and using the input-field tag ?
Do you use "int" or "Integer" as the type ?

2.
The "fieldParam" property of the input-field does not seem to be working correctly. I assume this property is used to specify what the "fieldname" should be in the HTML generated. If you specify a fieldParam and the type is either String, int or double, the default value will always be displayed. There seems to be a bug in the tag.
To me, it seems like the code should be changed similar to this :
Index: portal-web/docroot/html/taglib/ui/input_field/page.jsp
===================================================================
--- portal-web/docroot/html/taglib/ui/input_field/page.jsp (revision 20078)
+++ portal-web/docroot/html/taglib/ui/input_field/page.jsp (working copy)
@@ -198,6 +198,10 @@

if (fieldParam == null) {
fieldParam = namespace + field;
+ }
+ else {
+ fieldParam = namespace + fieldParam;
+ }

if (type.equals("double")) {
value = String.valueOf(BeanParamUtil.getDouble(bean, request, field, GetterUtil.getDouble(defaultString)));
@@ -214,11 +218,6 @@
value = httpValue;
}
}
- }
- else {
- fieldParam = namespace + fieldParam;
- value = defaultString;
- }

boolean autoEscape = true;

If there is no comments to this, I will raise an issue as support.liferay.com for this.

3.
When the input-field is set up to display an numeric attribute, there does not seem to be any validation of input anywhere. I was expecting the framework to make sure the user only entered a valid numeric value, or displayed an error message if not.
Is there support for validating the input for numeric properties ?

4.
I also think that the "readonly" attribute on standard HTML input tag should be supported by the UI input-field tag.


Regards
Alf Hogemark
15年前 に Alf Høgemark によって更新されました。

RE: Liferay UI taglib : suggestions for input-field tag

Junior Member 投稿: 34 参加年月日: 08/05/24 最新の投稿
Hi

I just realized that since I'm writing Struts Portlets, I should rather use the struts html tags, instead of the Liferay tag library.
The struts tags have all the functionality I need, and I also think it makes the jsp page code look cleaner and nicer.

Regards
Alf Hogemark
14年前 に zahra karami によって更新されました。

RE: Liferay UI taglib : suggestions for input-field tag

New Member 投稿: 2 参加年月日: 09/03/10 最新の投稿
Hello Alf
first pardon me for my little english

to add custom validation on input tag in liferay (<liferay-ui:input-field ) ,
you can use of java Script codes , and on submit form you call your java Script function
for example if you want only nummeric format field , use this code :

==============================
in a jsp page in webapps\ROOT\html\portlet\login\
==============================
<script language="javascript">
function isNumeric (text)
{
var ch;
var Numbers = "1234567890";
for (var i=0;i<text.length;i++)
{
ch = Numbers.indexOf(text.charAt(i))
if (ch == -1)
return false;
}
return true;
}
----------------------------------------------------------------------------------------
function checkForm()
{
var MyNumber = document.form.MyFeild;
if(!isNumeric(MyNumber .value) )
{
alert(" Your input is not a number");
return false;
}
return true;
}
</script>
-----------------------------------------------------------------------------------
<form onSubmit="return checkForm();" action="<portlet:actionURL windowState="<%= WindowState.MAXIMIZED.toString() %>" name="form1">

<liferay-ui:input-field model="<%= Contact.class %>" bean="<%= contact2 %>" field="middleName" name="MyFeild" />
------------------------------------------------------------------------------------
I hope this code help you and solve part of your problem
-----------------------------------------------------------------------------------
I use this code but Icould not get the name of the input field . can any body help me?
thumbnail
13年前 に mohammed azam によって更新されました。

RE: Liferay UI taglib : suggestions for input-field tag

Regular Member 投稿: 159 参加年月日: 09/11/06 最新の投稿
Hi,

I used your piece of code in order to understand how to get the value of the inputfield in javascript.
here is the solution--
function checkForm(){
		var MyNumber = document.getElementById('<portlet:namespace />middleName');

		if(!isNumeric(MyNumber .value) )
		{
			alert(" please enter a valid phone number");
			return false;
		}
		return true;
	}

this will serve your purpose.
14年前 に vikas suresh thakre によって更新されました。

How to make liferay-ui:input-field readonly ?

Junior Member 投稿: 97 参加年月日: 09/05/18 最新の投稿
Hi All,

is it possible to make <liferay-ui:input-field /> this field readonly.

i get disabled from the tld, it's also solved my purpose but when i try to save that page it can't able to read the text field. For example i had made screen name disabled in the user profile information page and then try to save that page, it is giving me the validation error that "Please enter a valid screen name."

any help here is really appreciable

thanks
Vikas Thakre.
13年前 に Cesar Gutierrez によって更新されました。

RE: How to make liferay-ui:input-field readonly ?

New Member 投稿: 5 参加年月日: 10/08/17 最新の投稿
vikas suresh thakre:
Hi All,

is it possible to make <liferay-ui:input-field /> this field readonly.

i get disabled from the tld, it's also solved my purpose but when i try to save that page it can't able to read the text field. For example i had made screen name disabled in the user profile information page and then try to save that page, it is giving me the validation error that "Please enter a valid screen name."

any help here is really appreciable

thanks
Vikas Thakre.


i have the same problem, u fix it? or anyone else?, thx.
thumbnail
11年前 に Umer Sayeed によって更新されました。

RE: How to make liferay-ui:input-field readonly ?

Junior Member 投稿: 51 参加年月日: 12/08/08 最新の投稿
$(document).ready(function(){
document.getElementById('name').readOnly=true
});

<tr><td>Name<b style="color: red;">*</b></td><td> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td> <aui:input label="" name="name" /></td></tr>
13年前 に Cesar Gutierrez によって更新されました。

RE: How to make liferay-ui:input-field readonly ?

New Member 投稿: 5 参加年月日: 10/08/17 最新の投稿
well searching in liferay forum i got the solution xD, adding a hidden input field solve my problem

<liferay-ui:input-field model="<%= User.class %>" bean="<%= selUser %>" field="screenName" disabled="<%= true %>" />
[b]<input name="<portlet:namespace />screenName" type="hidden" value="<%=selUser.getScreenName()" %>" /&gt;[/b]
11年前 に Ming Wu によって更新されました。

RE: How to make liferay-ui:input-field readonly ?

New Member 投稿: 1 参加年月日: 12/06/17 最新の投稿
<aui:input name="xxx" label="xxx" readonly="readonly"></aui:input>
thumbnail
11年前 に Massimiliano Assante によって更新されました。

RE: How to make liferay-ui:input-field readonly ?

Junior Member 投稿: 53 参加年月日: 10/03/04 最新の投稿
Ming Wu:
<aui:input name="xxx" label="xxx" readonly="readonly"></aui:input>


this does not work (liferay 6.0.6 CE)
10年前 に Jorge García によって更新されました。

RE: How to make liferay-ui:input-field readonly ?

New Member 投稿: 12 参加年月日: 12/05/11 最新の投稿
Have you tried the disabled property?

<liferay:ui-input name="name" label="label" disabled="true"/>
13年前 に Reinaldo Silva によって更新されました。

RE: Liferay UI taglib : suggestions for input-field tag

New Member 投稿: 3 参加年月日: 09/12/03 最新の投稿
For <aui:input> Date type fields:

* Allow render without a predefined date to avoid lazy users for critical input.
* Once set, also allow blank / nullify dates for null/non-required date fields.