i want set preset value in struts 2 password tag, can anybody tell me advance for thanks
for presetting value of any component all you need to do is set value attribute to whatever value you want or keep the name attribute equal to the bean property name in the calling action. this works as the value attribute is set to the name attribute by default.
For password there is one other thing you need to do i.e- set showPassword attribute of password component to true. it will then show the password in the masked form
Related
In Thymeleaf I would like to generate following HTML
<span data-my-attr>
</span>
I would like to display data-my-attr conditionally, but there seems to be no way how to display or NOT to display an empty attribute conditionally.
In case of required attribute there is th:required but for custom attributes there is nothing.
I tried to use th:attr="'data-my-attr'=${value}" and value is true or false, but it does not work.
Let's assume condition is true when your attribute should be shown and false when it shouldn't. You can have following:
<span data-my-attr th:attr="${condition} ? 'meaningless' : 'data-my-attr'=''"></span>
Explanation:
According to this thread when you specify the empty value for an attribute within th:attr then Thymeleaf will delete this attribute. So in above snippet:
data-my-attr is added by default.
The empty value is assigned to an attribute using th:attr.
The name of the attribute overriden with empty value is selected accordingly to ${condition}.
When ${condition} is true then data-my-attr should stay so any meaningless name (not present within the tag) should be picked.
Otherwise data-my-attr should be deleted so this name is picked.
Feels hacky but such a way of attribute removal seems working since 2012. Therefore I'd consider it stable.
I want to set the form fields like name and email from data though url query string . I have rendered the form through macro . how i can do that
my macro rendering code is
#Umbraco.RenderMacro("renderUmbracoForm", new {FormGuid="ccebfbe8-aa28-497e-8078-c3577c88f47a", FormTheme="" ,
ExcludeScripts="0"} )
My form fields are Name, Email , EventName
and url query is
http://localhost:17402/register?eventId=1342&eventName=you%20cant%20save%20the%20world%20alone
In Umbraco Forms, you can set the Default Value of a field.
For example, set the Default Value to something like [#queryName]. The 'queryName' will be your querystring parameter name in the URL (http://www.website.com/contactus?queryName=Foo) - Umbraco does the rest.
I referred to this and it was pretty straight forward:
https://our.umbraco.org/forum/umbraco-pro/contour/14340-Set-value-of-radiobuttonlist-from-querystring
I am using Icefaces 3.2. I would like to know how to reset the styleClass attribute of a component e.g textarea from the backing bean method.
USECASE: I have an ace:textAreaEntry which has a validator method in the backing bean. In this backing bean I am doing some validation. If the validation fails I want a particular CSS class applied to the component. So I want to reset the value of the styleclass attribute.
You can set the styleClass conditionally ,like this
<ace:textAreaEntry
styleClass="#{facesContext.validationFailed?'failedClass':'validClass'}"/>
or assign fail class only and otherwise no class at all
<ace:textAreaEntry
styleClass="#{facesContext.validationFailed?'failedClass':''}"/>
If you manually set message to be displayed in your page you can check if facesContext.messageList is empty or not, like this
<ace:textAreaEntry
styleClass="#{(not empty facesContext.messageList)?'filedClass':'validClass'}"/>
If you want to test for some specific internal logic validation you can check for some boolean for example
<ace:textAreaEntry
styleClass="#{(myBean.someComponentFailed)?'filedClass':'validClass'}"/>
where someComponentFailed is some property that you set to true/false upon validation failure
HiddenFor description is:
Returns an HTML hidden input element for each property in the object that is represented by the specified expression.
I read that it is useful for fields in your Model/ViewModel that you need to persist on the page and have passed back when another call is made but shouldn't be seen by the user.
HiddenInput description is:
Represents an attribute that is used to indicate whether a property or field value should be rendered as a hidden input element.
Can you please tell me when is HiddenInput useful? and when to use it instead of Html.HiddenFor?
Thanks!
HiddenFor is determined by the view - the view creates a Hidden input value from any element of the viewmodel or data.
HiddenInput is an attribute on a field in the (view)model - which means that it can be used across multiple views and indicates that this field should be hidden wherever it is rendered by an EditorFor helper
I am using JSF 2.0/CDI and PrimeFaces 2.2.1 for a number of CRUD forms that let the user view or update the attributes of an existing entity by clicking on a link in a datatable, where the identifier of the entity is passed to the CRUD form as a View Parameter. I display the entity's ID (often just an integer) on the CRUD form in a PrimeFaces InputText field with the readonly attribute set to true (since I can't let them change it), so the user knows which entity they're editing. The backing bean of the CRUD form is RequestScoped, which works fine except when validation fails. In that case, the value of the View Parameter is lost, so a 0 is displayed in the entity ID field on validation failure.
I am able to maintain the actual entity ID in a hidden field so it's available to update the database once validation succeeds, but it's rather maddening that I've not been able to find a way to maintain the value in a visible field of some sort after a validation failure. Ideally the InputText field would retain its functionality as an inputted and validated field even with its readonly (or disabled) attribute set to true, which would let me forgo the hidden field entirely. But it doesn't appear that I can make it work that way. Any suggestions besides making the backing bean ConversationScoped, which I'd prefer to avoid?
Actually, after stating what I'm looking for a little differently in a Google search I found a novel suggestion at the link below that seems to work cleanly. Instead of making the entity ID field readonly or disabled, I leave it enabled but blur it as soon as it receives focus. I'm able to get rid of the hidden field, the user can't change the value and it survives a validation failure.
<p:inputText id="entid" value="#{RequestBean.entityID}" onfocus="blur();" />
http://www.codingforums.com/archive/index.php/t-1738.html