I'm having trouble in getting the exact value of href only |
It's a little known (maybe) fact that most browsers convert Anchor node elements into Location objects as well. So you can access all parts available to Location too; |
Suppose consider below html code: |
<body> HELLO '59 IS PRESENT <a href="test2.html">HI</a> <a href="https://stackoverflow.com/questions/domain">Another LINK</a> </body> |
In above html, two link exists, one for self domain and another for stackoverflow, now if I look through them, below output would be generated: |
PROTOCOL=http:, HOST=localhost, PORT= LINK PATH=/test2.html PROTOCOL=https:, HOST=stackoverflow.com, PORT= LINK PATH=/questions/domain |
Showing posts with label domain. Show all posts
Showing posts with label domain. Show all posts
Friday, June 22, 2018
Get URL and URL Parts in JavaScript | Get an Absolute URL with JavaScript | How to get the exact href value only without their domain | How to check if any Link is for some specific domain | Link attribute HOST > PATHNAME > Filter links by domain | host name
Thursday, November 16, 2017
JavaScript Regex To Match Domain Name | Domain Validator Regex
Below is the required regex to validate any domain name, its simple so you can modify if you need to extend it.
^((http|https):\/\/)?([a-zA-Z0-9_][-_a-zA-Z0-9]{0,62}\.)+([a-zA-Z0-9]{1,10})$
^((http|https):\/\/)?([a-zA-Z0-9_][-_a-zA-Z0-9]{0,62}\.)+([a-zA-Z0-9]{1,10})$
Wednesday, August 3, 2016
Hibernate evict an persistent object from hibernate session
package com.pkm.evict_entity import grails.util.Holders import org.hibernate.SessionFactory /** * Created by pritom on 3/08/2016. */ class EvictEntityInstance { public static void _evict(def domainInstance) { getBean(SessionFactory).currentSession.evict(domainInstance) } public static <T> T getBean(Class<T> requiredType) { try { return Holders.applicationContext.getBean(requiredType) } catch (Exception e) { return null } } }
Wednesday, March 5, 2014
Use transients domain attributes with Grails
In latest versions of Grails, transient attributes are not binded with form by default. This is the documentation of the bindable constraint. This is how the code would become (you need to add bindable: true):
static
transients
=
['confirmarPassword']
static constraints = { password blank: false, password: true, size:5..15, matches:/[\S]+/ confirmarPassword bindable: true, blank:false, password: true, size:5..15, matches:/[\S]+/, validator:{ val, obj -> if (obj.password != obj.confirmarPassword) return 'password.dontmatch' } }
Tuesday, October 29, 2013
Grails/GORM createCriteria.list to get specific/selected columns only | Alias To Entity Map ALIAS_TO_ENTITY_MAP | Grails Projections | Projections Data
Grails/GORM createCriteria.list to get specific/selected columns only | Alias To Entity Map ALIAS_TO_ENTITY_MAP | Grails Projections | Projections Data.
Below is a example of get some specific field instead of all fields for domain.
And you can left join another domain that is belongsTo or hasMany of parent domain.
You have to import below reference:
import org.hibernate.criterion.CriteriaSpecification
Below is a example of get some specific field instead of all fields for domain.
And you can left join another domain that is belongsTo or hasMany of parent domain.
You have to import below reference:
import org.hibernate.criterion.CriteriaSpecification
List list = DomainName.createCriteria().list {
resultTransformer(CriteriaSpecification.ALIAS_TO_ENTITY_MAP)
"in"("id", [1L, 2L])
createAlias('x', 'x_alias', CriteriaSpecification.LEFT_JOIN)
projections {
property("id", "id")
property("x_alias.field", "field_reference");
}
}
Output would be like below:
[
[id:1, field_reference:value1],
[id:2, field_reference:value2]
]
Monday, September 30, 2013
Grails: how to get/set a meta-constraint on domain class property such as belongsTo or other variables
In the scaffolding templates there is a property domainClass from
type org.codehaus.groovy.grails.commons.DefaultGrailsDomainClass. These
object has the property constrainedProperties. To have access to any properties such in this example: 'readonly' you have to do this:
Your domain class:
The DefaultGrailsDomainClass has a constructor with a attribute from type Class maybe you can do this:
Your domain class:
class Contact { static belongsTo = [subscription: Subscription] static constraints = { subscription(nullable: false, attributes: [readonly: true]) } String description }
The DefaultGrailsDomainClass has a constructor with a attribute from type Class maybe you can do this:
def domainClass = new DefaultGrailsDomainClass(Contact.class) def ro = domainClass.constrainedProperties.subscription.attributes.readonly
def domainClass = new DefaultGrailsDomainClass(it.metaClass.getTheClass()) def constrainedProperties = domainClass.constrainedProperties; if(constrainedProperties.containsKey("subscription")) { ConstrainedProperty v = (ConstrainedProperty) constrainedProperties.get("subscription"); /** * Now check */ if(v.isNullable()) { println "Nullable"; } if(v.isBlank()) { println "Blank"; } /** * There are may other constraints * http://grails.org/doc/latest/api/org/codehaus/groovy/grails/validation/ConstrainedProperty.html
* Java/Grails Class ConstrainedProperty
*/
}
Sunday, February 17, 2013
validate domain name using php regex
<?php function isValidDomainName($name = null) { if(isValidString($name)) { if(preg_match("/^(?:[-A-Za-z0-9]+\.)+[A-Za-z]{2,6}$/", getValidString($name))) { return true; } } return false; } function isValidString($text = null) { if ($text == null) { return false; } if (is_null($text)) { return false; } if (is_string($text)) { if (strlen(trim(strval($text))) 0) { return true; } } return false; } function getValidString($text = null) { if (isValidString($text)) { return trim(strval($text)); } return null; } ?>
Subscribe to:
Posts (Atom)