I have a form that requires multiple user inputs. One of them is a drop down list from which the User has to choose. Now I have to set the next input field as required depending on the options chosen in the first field.
For ex: There are 4 input options to be chosen for the first input field - A,B,C,D
I want the next input field to become mandatory when the user chooses option A and D.
How do I build the expression for the required field in this case?
I have tried doing this but that doesn't work
https://stackoverflow.com/a/48089828/15161963
1). Assume that, the name of first field() is 'FirstField' and next input field id 'SecondField' .
2). Then on 'SecondField'component's Required property , write EL as below .
Required = #{bindings.FirstField.attributeValue eq 'A' || bindings.FirstField.attributeValue eq 'B'}
3). And ensure that , 'SecondField's partialTrigger property points to 'FirstField' component .
I think you can binding your dopdownlist to a bean.
binding=#{yourBean.firstDropdowList}
Create method isDisableInputField
Boolean isRequireYourInputField(){
Boolean dropdownValue=firstDropdowList.getValue();
if("A".equals(dropdownValue) ||"D".equals(dropdownValue)) {
return true:
}
return false
}
In your af dropdown tag. Set
require=#{yourBean.isRequireYourInputField()}
Related
I have an input field in my form that when it is empty and form is submitted, I want to allow the form to submit. And the field is not empty, I want it to be validated. This is the code I have so far, but the field gets a validation error when I submit the form and field is empty:
binder.forField(field)
.withValidator(field-> field.matches(REGEX),
FORMAT_ERROR_MSG)
.bind("field");
The straightforward way is to make your validator accept the value if it's empty or if it matches your regular expression.
binder.forField(field)
.withValidator(value -> value.isEmpty() || value.matches(REGEX),
FORMAT_ERROR_MSG)
.bind("field");
In a jsff file a component has been designed and the values are being fetched from a Static VO. There are only two values in the static Vo. I need the first option to be set as default. But there is a empty value that is being set. I have written a condition to disable it. And when it is disabled the value must be set to the first one.
I have tried the List UI Hints and tried to enable the Include No selection item: Labeled Item first of list, I tried creating a new vo which only has one value and rendered it in Jsff(But it will make the code more complex for the future development) I have tried creating the switcher. But none of them worked as they should.
Can anyone suggest me a alternative where the code complexity does not increase and by default there is a first value selected. And disable if there is condition for disable tag in jsff is true.
PS: Once the field is disabled the first value must be the default value to be set by default.
There don't seem to be any default way to do this with Oracle ADF without adding code to your view Object. Here's how to automatically select First value in your ADF LOV (detail from here https://cedricleruth.com/autoselect-first-value-in-adf-lov-inside-a-table/) :
Generate the RowImpl Java class of your View Object and Static VO
In this RowImpl.java add the following function to return the first value if no value is already selected
public String defaultNextStatus() {
String value = (String) getAttributeInternal(AttributesEnum.NextStatus.index());
if (value == null) {
XxcrWorkflowUvVORowImpl nextStatut = (XxcrWorkflowUvVORowImpl) getWfkVA().first();
//Wkfva is the VO of the LOV
if (nextStatut != null) {
return nextStatut.getTxtValeur();
}
}
return value;
}
In the Detail panel of the attribute add the following Default Value Expression: adf.object.defaultNextStatus()
In the Detail panel of the attribute set the refresh Expression Value to false to avoid picking the first value again in case of ppr/refresh
I declared String variables in my grammar, vAttributeName and vClassName, and I assign them with the text values of the tokens : className and attributeName. When I use one of the variables that should normally contain a value in an error alternative so in another rule, it returns a null in the message ... Why do not my variables keep the values? How can I fix that?
grammar TestExpression;
#parser::members {
String vAttributeName;
String vClassName;
}
/* SYNTAX RULES */
textInput : classifierContext ;
classifierContext : 'context' c=className attributeContext {vClassName = $c.text;};
attributeContext : '::' a=attributeName ':' dataType initDefinition {vAttributeName = $a.text;};
initDefinition : 'init' ':' initExpression ;
initExpression : boolExpression
| decimalExpression
| dateTimeExpression
| .+? {notifyErrorListeners("Corriger - "l'attribut "+vAttributeName+" de l'entité "+vClassName+" ne correspond pas");}
I'm trying to parse an expression who describe a class with an attribute that has a false value.
And the message i expected was : "Corriger - l'attribut seat de l'entité Car ne correspond pas".
But the actual message was : "Corriger - l'attribut null de l'entité null ne correspond pas".
If you have a rule like a: b c {action}; and an input that matches that rule, events will happen in the following order:
The rule b is applied and its action is executed if it has one.
The rule c is applied and its action is executed if it has one.
The action action is executed and is able to access the results of the b and c rules (including anything set by their actions, which is why it's important that those have run first).
If you have a: b {action} c; instead, then the action will be executed after b, but before c (and will consequently be unable to access c's result).
So for your code that means that the action of initExpression is run before those of classifierContext and attributeContext and that's why the variables aren't set. You can fix the problem by moving the action, so that it happens directly after the needed part (i.e. className/attributeName) has been parsed.
You could also get rid of the variables altogether and instead get the desired information by getting it from your grandparent contexts.
Im creating a graph using JanusGraph.Creating a Vertex and added a property to it.I have assigned value to the property.The value is having more than 20 characters. After the graph commit, when I query the particular property of the graph, Im getting only first 20 characters.
Kindly help me on How to store more than 20 characters as a value to the property.
PFB the example for the above scenario
//Creating Graph
public JanusGraph graph = JanusGraphFactory.open("janusGraphBatch.properties");
JanusGraphManagement manageSystem = graph.openManagement();
//Adding Vertex
Vertex remitterV= graph.addVertex();
//Adding value(more than 20 characters) to the Property "NAME"
remitterV.property("NAME", "abcdefghijklmnopqrstuvwxyz");
manageSystem.commit();
//Querying property "NAME"
System.out.println("Value for NAME Property:"+remitterV.property("NAME"));
Result:
Value for NAME Property:abcdefghijklmnopqrst
You're using the toString method because of the System.out.println there. That calls the StringFactory in TinkerPop. The string factory method cuts off after 20 characters If you call .value() you should get what you expect.
Im new to this so here goes.
Trying to get a user called "Bob" from the MongoDb.
I have the:
UserData ud = MonConMan.instance().getDb().find(UserData.class, "name","bob").get();
The "bob" cannot be found if it has capital "Bob".
I understand i can get a List and do equalsIgnoreCase but are
there some Operators i can use?
I have users logging on and must test to see if they are registered. A user can type his name anyway he likes so must find a way to equalsIgnoreCase. Yea this is a problem, i cannot get all names and do equalsIgnoreCase, if there are like 10,000. One could of course initially save all user names in lowercase but that would destroy the visual appearance of the name.
looking at the wiki but cannot see any..
http://code.google.com/p/morphia/wiki/Query
Use java regex, like this.
String name = "bob";
Pattern pattern = Pattern.compile("^" + bob + "$", Pattern.CASE_INSENSITIVE);//This line will create a pattern to match words starts with "b", ends with "b" and its case insensitive too.
Query<UserData> query = createQuery().field("name").equal(pattern).retrievedFields(true, "id");//Replace `id` with what ever name you use in UserData for '_id'
UserData user = query.get();
if(user!=null){
//he is already registered
}
else{
//He is a new guy
}
(I am not good at regex, so you may have read about$&^somewhere. )
You should be sure that the user names you are using to validate a new user should be unique across your system.
Ended up keeping two fields like
- lowercaseusername
- originalusername
This way i could search for a user using the lowercaseusername
You can make find a name of a UserData using this code :
Query<UserData> query = createQuery().filter("name","bob");
find(query);
In my application, this code return all UserData that haves a field name with "bob" value.
The code can be this way too :
Query<UserData> query = createQuery().field("name").equal("bob");
find(query);
These codes will be in a UserDataDao that extends BasicDao, and receives in the construtor the datastore from morphia.