Forums de discussion

Liferay UI taglib : suggestions for input-field tag

Alf Høgemark, modifié il y a 15 années.

Liferay UI taglib : suggestions for input-field tag

Junior Member Publications: 34 Date d'inscription: 24/05/08 Publications récentes
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
Alf Høgemark, modifié il y a 15 années.

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

Junior Member Publications: 34 Date d'inscription: 24/05/08 Publications récentes
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
zahra karami, modifié il y a 15 années.

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

New Member Publications: 2 Date d'inscription: 10/03/09 Publications récentes
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
mohammed azam, modifié il y a 13 années.

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

Regular Member Publications: 159 Date d'inscription: 06/11/09 Publications récentes
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.
vikas suresh thakre, modifié il y a 14 années.

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

Junior Member Publications: 97 Date d'inscription: 18/05/09 Publications récentes
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.
Cesar Gutierrez, modifié il y a 13 années.

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

New Member Publications: 5 Date d'inscription: 17/08/10 Publications récentes
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
Umer Sayeed, modifié il y a 11 années.

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

Junior Member Publications: 51 Date d'inscription: 08/08/12 Publications récentes
$(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>
Cesar Gutierrez, modifié il y a 13 années.

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

New Member Publications: 5 Date d'inscription: 17/08/10 Publications récentes
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]
Ming Wu, modifié il y a 11 années.

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

New Member Envoyer: 1 Date d'inscription: 17/06/12 Publications récentes
<aui:input name="xxx" label="xxx" readonly="readonly"></aui:input>
thumbnail
Massimiliano Assante, modifié il y a 11 années.

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

Junior Member Publications: 53 Date d'inscription: 04/03/10 Publications récentes
Ming Wu:
<aui:input name="xxx" label="xxx" readonly="readonly"></aui:input>


this does not work (liferay 6.0.6 CE)
Jorge García, modifié il y a 10 années.

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

New Member Publications: 12 Date d'inscription: 11/05/12 Publications récentes
Have you tried the disabled property?

<liferay:ui-input name="name" label="label" disabled="true"/>
Reinaldo Silva, modifié il y a 13 années.

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

New Member Publications: 3 Date d'inscription: 03/12/09 Publications récentes
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.